diff options
author | mathieui <mathieui@mathieui.net> | 2017-10-14 16:01:53 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2017-10-14 16:01:53 +0200 |
commit | 7a0fcf855e7b53d07347c82a24c7186808af5a2d (patch) | |
tree | 7fe641ae2fb66f7a2b3f5610b9014b3fe552adef | |
parent | 67b850096ecaa150a68e8270a706521af6a6c0b4 (diff) | |
download | poezio-7a0fcf855e7b53d07347c82a24c7186808af5a2d.tar.gz poezio-7a0fcf855e7b53d07347c82a24c7186808af5a2d.tar.bz2 poezio-7a0fcf855e7b53d07347c82a24c7186808af5a2d.tar.xz poezio-7a0fcf855e7b53d07347c82a24c7186808af5a2d.zip |
Split command_topic in muctab
-rw-r--r-- | poezio/tabs/muctab.py | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index 9d83ec67..584754e0 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -256,6 +256,33 @@ class MucTab(ChatTab): self.add_message(info, typ=0) return True + def change_topic(self, topic): + """Change the current topic""" + muc.change_subject(self.core.xmpp, self.name, topic) + + @refresh_wrapper.always + def show_topic(self): + """ + Print the current topic + """ + info_text = dump_tuple(get_theme().COLOR_INFORMATION_TEXT) + norm_text = dump_tuple(get_theme().COLOR_NORMAL_TEXT) + if self.topic_from: + user = self.get_user_by_name(self.topic_from) + if user: + user_text = dump_tuple(user.color) + user_string = '\x19%s}(set by \x19%s}%s\x19%s})' % ( + info_text, user_text, user.nick, info_text) + else: + user_string = self.topic_from + else: + user_string = '' + + self._text_buffer.add_message( + "\x19%s}The subject of the room is: \x19%s}%s %s" % + (info_text, norm_text, self.topic, user_string)) + + def on_input(self, key, raw): if not raw and key in self.key_func: self.key_func[key]() @@ -1312,26 +1339,9 @@ class MucTab(ChatTab): /topic [new topic] """ if not subject: - info_text = dump_tuple(get_theme().COLOR_INFORMATION_TEXT) - norm_text = dump_tuple(get_theme().COLOR_NORMAL_TEXT) - if self.topic_from: - user = self.get_user_by_name(self.topic_from) - if user: - user_text = dump_tuple(user.color) - user_string = '\x19%s}(set by \x19%s}%s\x19%s})' % ( - info_text, user_text, user.nick, info_text) - else: - user_string = self.topic_from - else: - user_string = '' - - self._text_buffer.add_message( - "\x19%s}The subject of the room is: \x19%s}%s %s" % - (info_text, norm_text, self.topic, user_string)) - self.refresh() - return - - muc.change_subject(self.core.xmpp, self.name, subject) + self.show_topic() + else: + self.change_topic(subject) @command_args_parser.quoted(0) def command_names(self, args): |