From e53446a7b2061f7e52dfbf19b0ad23b18b213bda Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 11 Nov 2011 22:15:04 +0100 Subject: Add a /presence command for directed presences --- src/core.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index 50acf784..a4211a3f 100644 --- a/src/core.py +++ b/src/core.py @@ -15,6 +15,7 @@ import threading import traceback from datetime import datetime +from xml.etree import cElementTree as ET from inspect import getargspec @@ -131,6 +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), } self.key_func = { @@ -1156,6 +1158,19 @@ class Core(object): if isinstance(current, tabs.MucTab) and current.joined and show not in ('away', 'xa'): current.send_chat_state('active') + def command_presence(self, arg): + """ + /presence + """ + if not arg: + return + try: + self.xmpp.Presence(xml=ET.fromstring(arg)).send() + except : + import traceback + self.information(_('Could not send directed presence'), 'Error') + log.debug(_("Could not send directed presence:\n") + traceback.format_exc()) + def completion_status(self, the_input): return the_input.auto_completion([status for status in possible_show], ' ') -- cgit v1.2.3