Telethon: AttributeError: 'NoneType' object has no attribute 'messages'

Got the following error a few times

Traceback (most recent call last):
  File "site/my_app.py", line 109, in <module>
    watch_telegram()
  File "site/my_app.py", line 94, in watch_telegram
    client.get_content(channels, telegram_on_message_callback)
  File "/path/to/my_app/chats/telegram/telegram.py", line 58, in get_content
    entity, limit=self.message_count, min_id=entity.min_id)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/telethon/telegram_client.py", line 340, in get_message_history
    total_messages = getattr(result, 'count', len(result.messages))

AttributeError: ‘NoneType’ object has no attribute ‘messages’

I initialise my example exactly the same as it happens in the InteractiveTelegramClient. The get_content method is an equivalent run. (Basically the same code)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 27 (13 by maintainers)

Commits related to this issue

Most upvoted comments

but there was no any kind of additional information. I run my app with --telethon-log=DEBUG

That’s strange, --telethon-log=DEBUG should have shown a more detailed log. Unless you haven’t used upstream.

You can wrap your code in try: ... except: ... block.

I could actually workaround this… Thanks for the idea @pazis. I mean it’s not optimal but it’s a solution…