LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
10.01k stars 1.41k forks source link

telethon.errors.rpcerrorlist.BotMethodInvalidError #1065

Closed dhpour closed 5 years ago

dhpour commented 5 years ago

I simply tried this like before

client.get_messages("channel_username")

but this new error is thrown:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    res = client.get_messages("cinemadaily")
  File "e:\Programs\Python36\lib\site-packages\telethon\sync.py", line 54, in syncified
    return loop.run_until_complete(coro)
  File "e:\Programs\Python36\lib\asyncio\base_events.py", line 466, in run_until_complete
    return future.result()
  File "e:\Programs\Python36\lib\site-packages\telethon\client\messages.py", line 367, in get_messages
    async for x in self.iter_messages(*args, **kwargs):
  File "e:\Programs\Python36\lib\site-packages\async_generator\_impl.py", line 366, in step
    return await ANextIter(self._it, start_fn, *args)
  File "e:\Programs\Python36\lib\site-packages\async_generator\_impl.py", line 205, in throw
    return self._invoke(self._it.throw, type, value, traceback)
  File "e:\Programs\Python36\lib\site-packages\async_generator\_impl.py", line 209, in _invoke
    result = fn(*args)
  File "e:\Programs\Python36\lib\site-packages\telethon\client\messages.py", line 272, in iter_messages
    r = await self(request)
  File "e:\Programs\Python36\lib\site-packages\telethon\client\users.py", line 60, in __call__
    result = await future
telethon.errors.rpcerrorlist.BotMethodInvalidError: The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot (caused by GetHistoryRequest)
Lonami commented 5 years ago

Bots cannot get message history.

dhpour commented 5 years ago

I made a raw telegram client not a bot. get_message_history works well, get_message of the newer telethon versions also worked for a while but now it raises this error. I cannot understand the logic behind it.

Lonami commented 5 years ago

get_message_history doesn't exist. get_messages works fine for users. Bots can't use it. The session file in use is running a bot account. There is no issue or bug.