plugin text commands: basic /whois command (just show jid so far)
This commit is contained in:
parent
b9cd83ac51
commit
f9ef9a4f4a
1 changed files with 30 additions and 1 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue