plugin XEP-0045: added user information to /whois text command

This commit is contained in:
Goffi 2014-03-24 14:46:18 +01:00
commit b826dd7c10

View file

@ -84,7 +84,7 @@ class TextCommands(object):
"""
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 @@ class TextCommands(object):
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 @@ class TextCommands(object):
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)