plugin XEP-0045: added user information to /whois text command
This commit is contained in:
parent
9ac686c0a9
commit
b826dd7c10
1 changed files with 32 additions and 7 deletions
|
|
@ -55,6 +55,7 @@ class UnknownRoom(Exception):
|
|||
|
||||
|
||||
class XEP_0045(object):
|
||||
# TODO: this plugin is messy, need a big cleanup/refactoring
|
||||
|
||||
def __init__(self, host):
|
||||
info(_("Plugin XEP_0045 initialization"))
|
||||
|
|
@ -77,6 +78,7 @@ class XEP_0045(object):
|
|||
self.__submit_conf_id = host.registerCallback(self._submitConfiguration, with_data=True)
|
||||
try:
|
||||
self.host.plugins[C.TEXT_CMDS].registerTextCommands(self)
|
||||
self.host.plugins[C.TEXT_CMDS].addWhoIsCb(self._whois, 100)
|
||||
except KeyError:
|
||||
info(_("Text commands not available"))
|
||||
|
||||
|
|
@ -432,6 +434,26 @@ class XEP_0045(object):
|
|||
"""just a synonym of /title"""
|
||||
return self.cmd_title(mess_data, profile)
|
||||
|
||||
def _whois(self, whois_msg, mess_data, target_jid, profile):
|
||||
""" Add MUC user informations to whois """
|
||||
if mess_data['type'] != "groupchat":
|
||||
return
|
||||
if target_jid.userhost() not in self.clients[profile].joined_rooms:
|
||||
warning(_("This room has not been joined"))
|
||||
return
|
||||
user = self.clients[profile].joined_rooms[target_jid.userhost()].getUser(target_jid.resource)
|
||||
whois_msg.append(_("Nickname: %s") % user.nick)
|
||||
if user.entity:
|
||||
whois_msg.append(_("Entity: %s") % user.entity)
|
||||
if user.affiliation!='none':
|
||||
whois_msg.append(_("Affiliation: %s") % user.affiliation)
|
||||
if user.role!='none':
|
||||
whois_msg.append(_("Role: %s") % user.role)
|
||||
if user.status:
|
||||
whois_msg.append(_("Status: %s") % user.status)
|
||||
if user.show:
|
||||
whois_msg.append(_("Show: %s") % user.show)
|
||||
|
||||
|
||||
class SatMUCClient (muc.MUCClient):
|
||||
#implements(iwokkel.IDisco)
|
||||
|
|
|
|||
Loading…
Reference in a new issue