diff src/plugins/plugin_misc_text_commands.py @ 928:73873e9b56f7

plugin XEP-0045: added user information to /whois text command
author Goffi <goffi@goffi.org>
date Mon, 24 Mar 2014 14:46:18 +0100
parents cd150dd947e3
children 059b56cbd247
line wrap: on
line diff
--- a/src/plugins/plugin_misc_text_commands.py	Mon Mar 24 13:49:37 2014 +0100
+++ b/src/plugins/plugin_misc_text_commands.py	Mon Mar 24 14:46:18 2014 +0100
@@ -84,7 +84,7 @@
 
         """
         self._whois.append((priority, callback))
-        self._whois.sort(key=lambda item: item[0])
+        self._whois.sort(key=lambda item: item[0], reverse=True)
 
     def sendMessageTrigger(self, mess_data, pre_xml_treatments, post_xml_treatments, profile):
         """ Install SendMessage command hook """
@@ -165,9 +165,12 @@
         entity = mess_data["unparsed"].strip()
 
         if mess_data['type'] == "groupchat":
-            room = mess_data["to"]
-            if self.host.plugins["XEP-0045"].isNickInRoom(room, entity, profile):
-                entity = u"%s/%s" % (room, entity)
+            room = mess_data["to"].userhostJID()
+            try:
+                if self.host.plugins["XEP-0045"].isNickInRoom(room, entity, profile):
+                    entity = u"%s/%s" % (room, entity)
+            except KeyError:
+                warning("plugin XEP-0045 is not present")
 
         if not entity:
             target_jid = mess_data["to"]
@@ -187,7 +190,7 @@
 
         d = defer.succeed(None)
         for ignore, callback in self._whois:
-            d.addCallback(lambda ignore: callback(whois_msg, target_jid, profile))
+            d.addCallback(lambda ignore: callback(whois_msg, mess_data, target_jid, profile))
 
         def feedBack(ignore):
             self.feedBack(u"\n".join(whois_msg), mess_data, profile)