diff --git a/src/core/xmpp.py b/src/core/xmpp.py index 9113aef0..9c5f0720 100644 --- a/src/core/xmpp.py +++ b/src/core/xmpp.py @@ -106,7 +106,7 @@ class SatMessageProtocol(xmppim.MessageProtocol): def onMessage(self, message): debug (_(u"got message from: %s"), message["from"]) - if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile): + if not self.host.trigger.point("MessageReceived", message, profile=self.parent.profile): return for e in message.elements(): if e.name == "body": diff --git a/src/plugins/plugin_misc_text_commands.py b/src/plugins/plugin_misc_text_commands.py index 97913aa2..0d799b56 100755 --- a/src/plugins/plugin_misc_text_commands.py +++ b/src/plugins/plugin_misc_text_commands.py @@ -27,7 +27,7 @@ PLUGIN_INFO = { "import_name": "text-commands", "type": "Misc", "protocols": [], -"dependencies": ["XEP-0045"], +"dependencies": ["XEP-0045", "EXP-PARROT"], "main": "TextCommands", "handler": "no", "description": _("""IRC like text commands""") @@ -159,6 +159,48 @@ class TextCommands(): return False + def cmd_parrot(self, mess_data, profile): + """activate Parrot mode between 2 entities, in both directions.""" + debug("Catched parrot command") + + try: + link_left_jid = jid.JID(mess_data["unparsed"].strip()) + if not link_left_jid.user or not link_left_jid.host: + raise jid.InvalidFormat + except jid.InvalidFormat: + self._feedBack("Can't activate Parrot mode for invalid jid", mess_data, profile) + return False + + link_right_jid = mess_data['to'] + + self.host.plugins["EXP-PARROT"].addParrot(link_left_jid, link_right_jid, profile) + self.host.plugins["EXP-PARROT"].addParrot(link_right_jid, link_left_jid, profile) + + self._feedBack("Parrot mode activated for %s" % (unicode(link_left_jid),), mess_data, profile) + + return False + + def cmd_unparrot(self, mess_data, profile): + """remove Parrot mode between 2 entities, in both directions.""" + debug("Catched unparrot command") + + try: + link_left_jid = jid.JID(mess_data["unparsed"].strip()) + if not link_left_jid.user or not link_left_jid.host: + raise jid.InvalidFormat + except jid.InvalidFormat: + self._feedBack("Can't deactivate Parrot mode for invalid jid", mess_data, profile) + return False + + link_right_jid = mess_data['to'] + + self.host.plugins["EXP-PARROT"].removeParrot(link_left_jid, profile) + self.host.plugins["EXP-PARROT"].removeParrot(link_right_jid, profile) + + self._feedBack("Parrot mode deactivated for %s and %s" % (unicode(link_left_jid), unicode(link_right_jid)), mess_data, profile) + + return False + def cmd_help(self, mess_data, profile): """show help on available commands""" commands=filter(lambda method: method.startswith('cmd_'), dir(self))