changeset 600:c5451501465b

plugin text commands: basic /whois command (just show jid so far)
author Goffi <goffi@goffi.org>
date Wed, 20 Feb 2013 20:37:17 +0100
parents 8d8a2ad163e2
children a4f6f78f0620
files src/plugins/plugin_misc_text_commands.py
diffstat 1 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_misc_text_commands.py	Wed Feb 20 20:36:09 2013 +0100
+++ b/src/plugins/plugin_misc_text_commands.py	Wed Feb 20 20:37:17 2013 +0100
@@ -24,7 +24,7 @@
 
 PLUGIN_INFO = {
     "name": "Text commands",
-    "import_name": "text-commands",
+    "import_name": "TEXT-COMMANDS",
     "type": "Misc",
     "protocols": [],
     "dependencies": ["XEP-0045", "EXP-PARROT"],
@@ -209,6 +209,35 @@
 
         return False
 
+    def cmd_whois(self, mess_data, profile):
+        """show informations on entity"""
+        debug("Catched whois command")
+    
+        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)
+            
+        if not entity:
+            target_jid = mess_data["to"]
+        else: 
+            try:
+                target_jid = jid.JID(entity)
+                if not target_jid.user or not target_jid.host:
+                    raise jid.InvalidFormat
+            except (jid.InvalidFormat, RuntimeError):
+                self._feedBack(_("Invalid jid, can't whois"), mess_data, profile)
+                return False
+
+        whois_msg = [_(u"whois for %(jid)s") % {'jid': target_jid}]
+        #TODO: add informations here (client version, vcard, etc)
+        
+        self._feedBack(u"\n".join(whois_msg), 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))