Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

BotMethodInvalidError occurs however i use a personal telegram account

I run this:

async def main():
    async for dialog in client.iter_dialogs():
        print(dialog.name, 'has ID', dialog.id)

if __name__ == '__main__':
    with client:
        client.loop.run_until_complete(main())

And it causes BotMethodInvalidError: The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot (caused by GetDialogsRequest).
But i didn’t use a bot, i used a personal telegram account.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Edit:

if you’re certain you used a personal account and no bot_token, this means there is garbage .session file from previous bot login.. change the name and login once again with phone number, the danya2.session will be the user session to use, danya seems to be a bot.

TelegramClient('danya2', api_id=api_id_user, api_hash=api_hash_user)

You can check the current account logged-in in client using client.get_me()


Only users can get the open dialogs in the account, logins with bot token aren’t allowed to do that through the Telegram api.

a bot has to only handle realtime resources in events and cache them for future usage.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading