summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-24 23:01:00 +0100
committermathieui <mathieui@mathieui.net>2011-11-24 23:03:43 +0100
commitcd9684043f72ec8f7ae7e500096d356662de7f49 (patch)
tree972aeed598a9a674c7d2a55ebcb164741fa289f5 /src
parent8652e80ebb30dbf47a74890612bc522ab0b38671 (diff)
downloadpoezio-cd9684043f72ec8f7ae7e500096d356662de7f49.tar.gz
poezio-cd9684043f72ec8f7ae7e500096d356662de7f49.tar.bz2
poezio-cd9684043f72ec8f7ae7e500096d356662de7f49.tar.xz
poezio-cd9684043f72ec8f7ae7e500096d356662de7f49.zip
Add a /invite command
Diffstat (limited to 'src')
-rw-r--r--src/core.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/core.py b/src/core.py
index 8a903a8f..4d40a0da 100644
--- a/src/core.py
+++ b/src/core.py
@@ -136,6 +136,7 @@ class Core(object):
'presence': (self.command_presence, _('Usage: /presence <JID> [type] [status]\nPresence: Send a directed presence to <JID> and using [type] and [status] if provided.'), self.completion_presence),
'rawxml': (self.command_rawxml, _('Usage: /rawxml\nRawXML: Send a custom xml stanza.'), None),
'set_plugin': (self.command_set_plugin, _("Usage: /set_plugin <plugin> <option> [value]\nSet Plugin: Set the value of the option in a plugin configuration file."), self.completion_set_plugin),
+ 'invite': (self.command_invite, _("Usage: /invite <jid> <room> [reason]\nInvite: Invite jid in room with reason."), self.completion_invite),
}
self.key_func = {
@@ -314,6 +315,30 @@ class Core(object):
"""
self.status = Status(show=pres, message=msg)
+ def command_invite(self, arg):
+ args = common.shell_split(arg)
+ if len(args) < 2:
+ return
+ reason = args[2] if len(args) > 2 else ''
+ to = args[0]
+ room = args[1]
+ self.xmpp.plugin['xep_0045'].invite(room, to, reason)
+
+ def completion_invite(self, the_input):
+ txt = the_input.get_text()
+ args = common.shell_split(txt)
+ n = len(args)
+ if txt.endswith(' '):
+ n += 1
+ if len(args) == 1:
+ return the_input.auto_completion([contact.bare_jid for contact in roster.get_contacts()], '')
+ elif len(args) == 2:
+ rooms = []
+ for tab in self.tabs:
+ if isinstance(tab, tabs.MucTab) and tab.joined:
+ rooms.append(tab.get_name())
+ return the_input.auto_completion(rooms, '')
+
def on_data_form(self, message):
"""
When a data form is received