Skip to content

Commit

Permalink
Fix for get_last_messages
Browse files Browse the repository at this point in the history
  • Loading branch information
onuratakan committed Apr 14, 2024
1 parent f5a04cd commit ef988e7
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tiger/tools/communication/telegram/as_user/get_last_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,30 @@ async def get_messages(num, limit):
messages = await client.get_messages(num, limit=limit)
the_messages_list = {}
for each_ms in messages:
number = ""
type_of_entity = ""
try:
number = (await client.get_entity(each_ms.peer_id.user_id)).phone
type_of_entity = "user"
except:
try:
number = (await client.get_entity(each_ms.peer_id.user_id)).username
type_of_entity = "channel"
except:
number = (await client.get_entity(each_ms.peer_id.user_id)).id
type_of_entity = "group"

the_messages_list[each_ms.id] = {
"id":
each_ms.id,
"message":
each_ms.text,
"date":
each_ms.date,
"sender":
(await
client.get_entity(each_ms.peer_id.user_id)).username,
"number":
number,
"type_of_entity":
type_of_entity,
}
return the_messages_list

Expand Down

0 comments on commit ef988e7

Please sign in to comment.