Skip to content

Commit

Permalink
Added is_me for get_last_messages for telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
onuratakan committed Apr 23, 2024
1 parent 65d995a commit 6b6f69f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tiger/tools/communication/telegram/as_user/get_last_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,24 @@ async def get_messages(num, limit):
"7d0ebd20538d88ab0629eb926acb08f7") as client:
messages = await client.get_messages(num, limit=limit)
the_messages_list = {}
our_entity_id = (await client.get_me()).id
for each_ms in messages:
number = ""
type_of_entity = ""
the_entity = await client.get_entity(each_ms.peer_id)
try:
number = (await client.get_entity(each_ms.peer_id)).phone
number = the_entity.phone
type_of_entity = "user"
except:
try:
number = (await client.get_entity(each_ms.peer_id)).username
number = the_entity.username
type_of_entity = "channel"
except:
number = (await client.get_entity(each_ms.peer_id)).id
number = the_entity.id
type_of_entity = "group"

is_me = False
if our_entity_id == the_entity.id:
is_me = True
the_messages_list[each_ms.id] = {
"id":
each_ms.id,
Expand All @@ -47,6 +51,8 @@ async def get_messages(num, limit):
number,
"type_of_entity":
type_of_entity,
"is_me":
is_me,
}
return the_messages_list

Expand Down

0 comments on commit 6b6f69f

Please sign in to comment.