Commit 0f344b89 authored by Maxime Buquet's avatar Maxime Buquet

Initial impromptu command

Add a command that invites people to a newly created room, with a random
localpart. The muc component is currently static. The interface
for the command might also change later on.
Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <>
parent c3e9130d
......@@ -763,6 +763,20 @@ class CommandCore:
self.core.invite(to.full, room, reason=reason)
self.core.information('Invited %s to %s' % (to.bare, room), 'Info')
@command_args_parser.quoted(1, 0)
def impromptu(self, args):
"""/impromptu <jid> [<jid> ...]"""
if args is None:
jids = []
for jid in common.shell_split(' '.join(args)):
self.core.information('Invited %s to a random room' % (' '.join(jids)), 'Info')
@command_args_parser.quoted(1, 1, [''])
def decline(self, args):
"""/decline <room@server.tld> [reason]"""
......@@ -289,6 +289,19 @@ class CompletionCore:
return Completion(
the_input.new_completion, rooms, n, '', quotify=True)
def impromptu(self, the_input):
"""Completion for /impromptu"""
n = the_input.get_argument_position(quoted=True)
onlines = []
offlines = []
for barejid in roster.jids():
if len(roster[barejid]):
comp = sorted(onlines) + sorted(offlines)
return Completion(the_input.new_completion, comp, n, quotify=True)
def activity(self, the_input):
"""Completion for /activity"""
n = the_input.get_argument_position(quoted=True)
......@@ -13,6 +13,7 @@ import pipes
import sys
import shutil
import time
import uuid
from collections import defaultdict
from typing import Callable, Dict, List, Optional, Tuple, Type
......@@ -868,6 +869,28 @@ class Core:
jid=jid, timeout=5, callback=callback)
def impromptu(self, jids: List[JID]) -> None:
Generates a new "Impromptu" room with a random localpart on the muc
component of the user who initiated the request. One the room is
created and the first user has joined, send invites for specified
contacts to join in.
# Use config.default_muc as muc component if available, otherwise
# find muc component by disco#items-ing the user domain. If not, give
# up
default_muc = ''
nick = self.own_nick
room = uuid.uuid4().hex + '@' + default_muc
self.open_new_room(room, nick).join()
self.information('Room %s created' % room, 'Info')
for jid in jids:
self.invite(jid, room)
def get_error_message(self, stanza, deprecated: bool = False):
Takes a stanza of the form <message type='error'><error/></message>
......@@ -1788,6 +1811,13 @@ class Core:
desc='Invite jid in room with reason.',
shortdesc='Invite someone in a room.',
usage='<jid> [<jid> ...]',
desc='Invite people into an impromptu room',
shortdesc='Invite someone in a room.',
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment