From b13f8786cf2ef229e5dcaa3c5fd8770ec0c6ee10 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 11 Nov 2011 22:36:43 +0100 Subject: [PATCH] Modify /presence --- src/core.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/core.py b/src/core.py index a4211a3f..04f89172 100644 --- a/src/core.py +++ b/src/core.py @@ -132,7 +132,7 @@ class Core(object): 'load': (self.command_load, _('Usage: /load \nLoad: Load the specified plugin'), self.plugin_manager.completion_load), 'unload': (self.command_unload, _('Usage: /unload \nUnload: Unload the specified plugin'), self.plugin_manager.completion_unload), 'plugins': (self.command_plugins, _('Usage: /plugins\nPlugins: Show the plugins in use.'), None), - 'presence': (self.command_presence, _('Usage: /presence\nPresence: Send a directed presence.'), None), + 'presence': (self.command_presence, _('Usage: /presence [type] [status]\nPresence: Send a directed presence to and using [type] and [status] if provided.'), None), } self.key_func = { @@ -1160,12 +1160,21 @@ class Core(object): def command_presence(self, arg): """ - /presence + /presence [type] [status] """ - if not arg: + args = common.shell_split(arg) + if len(args) == 1: + jid, type, status = args[0], None, None + elif len(args) == 2: + jid, type, status = args[0], args[1], None + elif len(args) == 3: + jid, type, status = args[0], args[1], args[2] + else: return + if type == 'available': + type = None try: - self.xmpp.Presence(xml=ET.fromstring(arg)).send() + self.xmpp.make_presence(pto=jid, ptype=type, pstatus=status).send() except : import traceback self.information(_('Could not send directed presence'), 'Error')