From 02bb64feab8ca5a128724b27b7e548fd4cc632d1 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Mon, 12 Mar 2018 11:58:46 +0100 Subject: [PATCH] Remove usage of old MatrixRoom.alias attribute in remaining places. * Use calculated display name in the bar item. * Don't mention the room name in topic messages for groups. --- matrix/bar_items.py | 4 +++- matrix/commands.py | 19 ++++++++++++------- matrix/rooms.py | 25 ++++++++++++++++--------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/matrix/bar_items.py b/matrix/bar_items.py index db67a3c..6a2af53 100644 --- a/matrix/bar_items.py +++ b/matrix/bar_items.py @@ -49,7 +49,9 @@ def matrix_bar_item_name(data, item, window, buffer, extra_info): room = server.rooms[room_id] - return "{color}{name}".format(color=W.color(color), name=room.alias) + return "{color}{name}".format( + color=W.color(color), + name=room.display_name()) elif buffer == server.server_buffer: color = ("status_name_ssl" diff --git a/matrix/commands.py b/matrix/commands.py index 5821aa6..dd7a440 100644 --- a/matrix/commands.py +++ b/matrix/commands.py @@ -918,13 +918,18 @@ def matrix_command_topic_cb(data, buffer, command): if not room.topic: return W.WEECHAT_RC_OK - message = ("{prefix}Topic for {color}{room}{ncolor} is " - "\"{topic}\"").format( - prefix=W.prefix("network"), - color=W.color("chat_buffer"), - ncolor=W.color("reset"), - room=room.alias, - topic=room.topic) + if room.is_named(): + message = ('{prefix}Topic for {color}{room}{ncolor} is ' + '"{topic}"').format( + prefix=W.prefix("network"), + color=W.color("chat_buffer"), + ncolor=W.color("reset"), + room=room.named_room_name(), + topic=room.topic) + else: + message = ('{prefix}Topic is "{topic}"').format( + prefix=W.prefix("network"), + topic=room.topic) date = int(time.time()) topic_date = room.topic_date.strftime("%a, %d %b %Y " diff --git a/matrix/rooms.py b/matrix/rooms.py index 6c9820a..b7fc4dc 100644 --- a/matrix/rooms.py +++ b/matrix/rooms.py @@ -706,15 +706,22 @@ class RoomTopicEvent(RoomEvent): nick_color=W.color(color_name), user=nick, ncolor=W.color("reset")) # TODO print old topic if configured so - message = ("{prefix}{nick} has changed " - "the topic for {chan_color}{room}{ncolor} " - "to \"{topic}\"").format( - prefix=W.prefix("network"), - nick=author, - chan_color=W.color("chat_channel"), - ncolor=W.color("reset"), - room=room.display_name(server.user_id), - topic=topic) + if room.is_named(): + message = ("{prefix}{nick} has changed " + "the topic for {chan_color}{room}{ncolor} " + "to \"{topic}\"").format( + prefix=W.prefix("network"), + nick=author, + chan_color=W.color("chat_channel"), + ncolor=W.color("reset"), + room=room.named_room_name(), + topic=topic) + else: + message = ('{prefix}{nick} has changed the topic to ' + '"{topic}"').format( + prefix=W.prefix("network"), + nick=author, + topic=topic) tags = ["matrix_topic", "log3", "matrix_id_{}".format(self.event_id)]