# HG changeset patch # User Goffi # Date 1361389037 -3600 # Node ID c5451501465bffe76e84c54fa4a1b969daa1c97e # Parent 8d8a2ad163e2a4f8fdc2cd579e3c2e1369da94a9 plugin text commands: basic /whois command (just show jid so far) diff -r 8d8a2ad163e2 -r c5451501465b src/plugins/plugin_misc_text_commands.py --- 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))