nmlorg / metabot

Modularized, multi-account bot.
https://metabot.readthedocs.io/
5 stars 0 forks source link

Don't try to send an empty update message #71

Closed nmlorg closed 5 years ago

nmlorg commented 5 years ago

Overnight, the bot logged a number of exceptions of the form:

2019-08-07 07:00:05,794 ERROR loop.py:72] Ignoring uncaught error while dispatching:
Traceback (most recent call last):
  File "lib/python3.6/site-packages/ntelebot/loop.py", line 70, in run
    callback()
  File "lib/python3.6/site-packages/metabot/modules/events.py", line 39, in _hourly
    _daily_messages(multibot, records)
  File "lib/python3.6/site-packages/metabot/modules/events.py", line 119, in _daily_messages
    disable_notification=True)
  File "lib/python3.6/site-packages/ntelebot/bot.py", line 68, in __call__
    raise ntelebot.errors.Error(data)
ntelebot.errors.Error: {'ok': False, 'error_code': 400, 'description': 'Bad Request: message text is empty'}

  They spontaneously stopped at 8 a.m., suggesting a group with an 8 a.m. announcement scheduled had a change to its events that triggered the events != lastevents check but that wasn't considered an add, remove, or update. Presumably, this was an update to something like updated (which isn't included in update announcements). The bot should either generate a dummy value for text just to avoid triggering that Telegram error (and raising an exception, blocking the rest of _daily_messages), or get rid of the events != lastevents check and actually compute text every time, only triggering an update if it changes.