diff options
author | mathieui <mathieui@mathieui.net> | 2017-10-14 15:55:53 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2017-10-14 15:55:53 +0200 |
commit | 67b850096ecaa150a68e8270a706521af6a6c0b4 (patch) | |
tree | c18cc419c44a71cab7ca04766a760e5a858102c7 | |
parent | a2440a8b21a5e52020257bea4d53ce5df1ba377f (diff) | |
download | poezio-67b850096ecaa150a68e8270a706521af6a6c0b4.tar.gz poezio-67b850096ecaa150a68e8270a706521af6a6c0b4.tar.bz2 poezio-67b850096ecaa150a68e8270a706521af6a6c0b4.tar.xz poezio-67b850096ecaa150a68e8270a706521af6a6c0b4.zip |
Split command_info in muctab
-rw-r--r-- | poezio/tabs/muctab.py | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index ec22cf15..9d83ec67 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -222,6 +222,40 @@ class MucTab(ChatTab): muc.set_user_role(self.core.xmpp, self.name, nick, reason, role, callback=callback) + @refresh_wrapper.conditional + def print_info(self, nick): + """Print information about a user""" + user = self.get_user_by_name(nick) + if not user: + return False + + theme = get_theme() + inf = '\x19' + dump_tuple(theme.COLOR_INFORMATION_TEXT) + '}' + if user.jid: + user_jid = '%s (\x19%s}%s\x19o%s)' % ( + inf, + dump_tuple(theme.COLOR_MUC_JID), + user.jid, + inf) + else: + user_jid = '' + info = ('\x19%(user_col)s}%(nick)s\x19o%(jid)s%(info)s: show: ' + '\x19%(show_col)s}%(show)s\x19o%(info)s, affiliation: ' + '\x19%(role_col)s}%(affiliation)s\x19o%(info)s, role: ' + '\x19%(role_col)s}%(role)s\x19o%(status)s') % { + 'user_col': dump_tuple(user.color), + 'nick': nick, + 'jid': user_jid, + 'info': inf, + 'show_col': dump_tuple(theme.color_show(user.show)), + 'show': user.show or 'Available', + 'role_col': dump_tuple(theme.color_role(user.role)), + 'affiliation': user.affiliation or 'None', + 'role': user.role or 'None', + 'status': '\n%s' % user.status if user.status else ''} + self.add_message(info, typ=0) + return True + def on_input(self, key, raw): if not raw and key in self.key_func: self.key_func[key]() @@ -1073,36 +1107,8 @@ class MucTab(ChatTab): if args is None: return self.core.command.help('info') nick = args[0] - user = self.get_user_by_name(nick) - if not user: - return self.core.information("Unknown user: %s" % nick, "Error") - theme = get_theme() - inf = '\x19' + dump_tuple(theme.COLOR_INFORMATION_TEXT) + '}' - if user.jid: - user_jid = '%s (\x19%s}%s\x19o%s)' % ( - inf, - dump_tuple(theme.COLOR_MUC_JID), - user.jid, - inf) - else: - user_jid = '' - info = ('\x19%s}%s\x19o%s%s: show: \x19%s}%s\x19o%s, affiliation:' - ' \x19%s}%s\x19o%s, role: \x19%s}%s\x19o%s') % ( - dump_tuple(user.color), - nick, - user_jid, - inf, - dump_tuple(theme.color_show(user.show)), - user.show or 'Available', - inf, - dump_tuple(theme.color_role(user.role)), - user.affiliation or 'None', - inf, - dump_tuple(theme.color_role(user.role)), - user.role or 'None', - '\n%s' % user.status if user.status else '') - self.add_message(info, typ=0) - self.core.refresh_window() + if not self.print_info(nick): + self.core.information("Unknown user: %s" % nick, "Error") @command_args_parser.quoted(0) def command_configure(self, ignored): |