From e6485c73bb60539fd9fe0a6fb9a0f248014e4e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Fri, 6 Jul 2018 18:39:43 +0200 Subject: [PATCH] buffer: Add support for multiple users with the same base name. --- matrix/buffer.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/matrix/buffer.py b/matrix/buffer.py index c2ed1cd..96d192f 100644 --- a/matrix/buffer.py +++ b/matrix/buffer.py @@ -677,10 +677,16 @@ class RoomBuffer(object): def handle_membership_events(self, event, is_state): def join(event, date, is_state): user = self.room.users[event.sender] - buffer_user = RoomUser(user.name, event.sender, user.power_level) - # TODO we need to check that the displayed nick is unique if it - # isn't use the full user_id - self.displayed_nicks[event.sender] = user.name + + # TODO make this configurable + if user.name in self.displayed_nicks.values(): + # Use the full user id, but don't include the @ + nick = event.sender[1:] + else: + nick = user.name + + buffer_user = RoomUser(nick, event.sender, user.power_level) + self.displayed_nicks[event.sender] = nick if self.room.own_user_id == event.sender: buffer_user.color = "weechat.color.chat_nick_self"