From f9ef9a4f4ab242a433426b44e0e275493a676fb8 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 20 Feb 2013 20:37:17 +0100 Subject: [PATCH] plugin text commands: basic /whois command (just show jid so far) --- src/plugins/plugin_misc_text_commands.py | 31 +++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin_misc_text_commands.py b/src/plugins/plugin_misc_text_commands.py index ee688c5d..b181966b 100755 --- a/src/plugins/plugin_misc_text_commands.py +++ b/src/plugins/plugin_misc_text_commands.py @@ -24,7 +24,7 @@ from logging import debug, info, warning, error 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 @@ class TextCommands(object): 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))