From de548d5dc028cc5cb44e8f6d5183ea21a6f2ee3e Mon Sep 17 00:00:00 2001 From: Marco Schlicht Date: Sat, 31 Oct 2020 12:40:14 +0100 Subject: [PATCH 1/2] fixed emoji/normal display character of super groups related to #21 --- telegramtui/src/chatBox.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/telegramtui/src/chatBox.py b/telegramtui/src/chatBox.py index 62eeef4..0ef4c07 100644 --- a/telegramtui/src/chatBox.py +++ b/telegramtui/src/chatBox.py @@ -23,19 +23,20 @@ def update_chat(self): data = [] for i in range(len(client.dialogs)): special = "" + dialog = client.dialogs[i] if self.emoji: - if hasattr(client.dialogs[i].dialog.peer, 'user_id'): - special = "👤 " if not client.dialogs[i].entity.bot else "🤖 " - elif hasattr(client.dialogs[i].dialog.peer, 'channel_id'): + if dialog.is_user: + special = "👤 " if not dialog.entity.bot else "🤖 " + elif dialog.is_channel and not dialog.is_group: special = "📢 " - elif hasattr(client.dialogs[i].dialog.peer, 'chat_id'): + elif dialog.is_group: special = "👥 " else: - if hasattr(client.dialogs[i].dialog.peer, 'user_id'): - special = "* " if not client.dialogs[i].entity.bot else "@ " - elif hasattr(client.dialogs[i].dialog.peer, 'channel_id'): + if dialog.is_user: + special = "* " if not dialog.entity.bot else "@ " + elif dialog.is_channel and not dialog.is_group: special = "# " - elif hasattr(client.dialogs[i].dialog.peer, 'chat_id'): + elif dialog.is_group: special = "$ " timestamp = int(time.time()) From 2b542b073bd9d2c8ae55a5049baec9da5f903c32 Mon Sep 17 00:00:00 2001 From: Marco Schlicht Date: Sat, 31 Oct 2020 12:51:11 +0100 Subject: [PATCH 2/2] fixed super groups displaying as channel fixes #21 --- telegramtui/src/messageBox.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/telegramtui/src/messageBox.py b/telegramtui/src/messageBox.py index a9096de..0150df5 100644 --- a/telegramtui/src/messageBox.py +++ b/telegramtui/src/messageBox.py @@ -136,25 +136,26 @@ def __init__(self, color, name): users = {} max_name_len = 0 + dialog = client.dialogs[current_user] # 1 - dialog with user - if hasattr(client.dialogs[current_user].dialog.peer, 'user_id'): + if dialog.is_user: dialog_type = 1 # set interlocutor - name = client.dialogs[current_user].name if hasattr(client.dialogs[current_user], 'name') else \ - client.dialogs[current_user].first_name - users[client.dialogs[current_user].dialog.peer.user_id] = user_info( + name = dialog.name if hasattr(dialog, 'name') else \ + dialog.first_name + users[dialog.dialog.peer.user_id] = user_info( self.parent.theme_manager.findPair(self, 'WARNING'), name) # set me name = client.me.first_name if hasattr(client.me, 'first_name') else client.me.last_name users[client.me.id] = user_info(self.parent.theme_manager.findPair(self, 'NO_EDIT'), name) - max_name_len = max(len(users[client.dialogs[current_user].dialog.peer.user_id].name), + max_name_len = max(len(users[dialog.dialog.peer.user_id].name), len(users[client.me.id].name)) # 2 - chat group - elif hasattr(client.dialogs[current_user].dialog.peer, 'chat_id'): + elif dialog.is_group: dialog_type = 2 for i in range(len(messages)): username = "" @@ -175,7 +176,7 @@ def __init__(self, color, name): users[client.me.id] = user_info(self.parent.theme_manager.findPair(self, 'NO_EDIT'), name) # 3 - channel - elif hasattr(client.dialogs[current_user].dialog.peer, 'channel_id'): + elif dialog.is_channel and not dialog.is_group: dialog_type = 3 # -1 not define