Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed supergroups not displaying right #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions telegramtui/src/chatBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
15 changes: 8 additions & 7 deletions telegramtui/src/messageBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -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
Expand Down