Reputation: 41
I have been using Telethon for quite some time with my own API credentials and phone number, however recently, I decided to log on my app with my brothers phone and notice something weird:
from telethon import TelegramClient, events, utils
api_id = "something"
api_hash = "something"
client = TelegramClient('test', api_id, api_hash)
async def main():
me = await client.get_me()
print(me.stringify());
async for dialog in client.iter_dialogs():
print(dialog, "\n-----")
with client:
client.loop.run_until_complete(main())
When I run the above code logged with my own phone number it will not show a deleter dialog. But if I ran with someone else's phone number, it will show the name of the deleted dialog.
Example: I create a dialog, ran the above example and log with my own phone, the dialog shows up. Then, I delete the dialog (using the official android app) and run the above script again, the dialog doens't shows up. However if I repeat the above steps with someone else's phone number, the deleted dialog will show up.
NOTE: although the dialog show's up, the messages in the dialog don't.
Is this normal behaviour? What I am missing? Any comment will be of great help
====EDIT====
So, I have made some extra digging I discovered that this behaviour only applies to dialogs with my own account, aka, the account that owns the Telegram credentials.
Basically, I asked my brother to delete a group chat and when I ran the client.iter_dialogs, it was not there. Then, I asked him to delete a dialog with another person, I ran client.iter_dialogs and the dialog was not there.
It seems that Telegram have some kind of exception just for the account that owns the credentials (maybe they understand that I will need to have it as way to communicate to my clients, maybe it's just a bug).
====EDIT 2====
So, I have run the script again... and now it's not happening. I have no idea what was happening nor why, but it has stopped showing up. Perhaps something at the Telegram API itself, but I can't be sure. Anyway, if, for any reason, it happens in your script post on this thread or open an issue back on Telethon.
Thanks.
Upvotes: 1
Views: 2646
Reputation: 71
add variable ignore_migrated = True to iter_dialogs()
async for dialog in client.iter_dialogs(ignore_migrated = True):
print(dialog, "\n-----")
ignore_migrated (bool
, optional):
Whether :tl:Chat
that have migrated_to
a :tl:Channel
should be included or not. By default all the chats in your
dialogs are returned, but setting this to True
will hide
them in the same way official applications do.
Upvotes: 0