Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to sendMessage if a daily announcement's caption is too long #76

Closed
nmlorg opened this issue Sep 7, 2019 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@nmlorg
Copy link
Owner

nmlorg commented Sep 7, 2019

This past Wednesday's 8 a.m. Pacific announcement failed:

2019-09-04 08:00:14,958 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 42, in _hourly
    _daily_messages(multibot, records)
  File "lib/python3.6/site-packages/metabot/modules/events.py", line 76, 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: MEDIA_CAPTION_TOO_LONG'}

From #74:

For images, the announcement could be changed from a sendMessage to a sendPhoto, though the text of the message will become a "caption" instead—and will be limited to 1024 characters.

  1. We could do something like pass the caption text through metabot.util.html.sanitize, and revert to sendMessage if its length is greater than 1024.
  2. Alternatively we could capture that error and retry using sendMessage.

While working on this, we should also just improve error handling in the daily announcement loop so one announcement's failure won't cause all announcements for that time slot to be skipped (see 26c7734).

@nmlorg nmlorg added the bug Something isn't working label Sep 7, 2019
@nmlorg nmlorg self-assigned this Sep 7, 2019
@nmlorg
Copy link
Owner Author

nmlorg commented Jan 20, 2020

While working on this, we should also just improve error handling in the daily announcement loop so one announcement's failure won't cause all announcements for that time slot to be skipped (see 26c7734).

This was done in 358ce89.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant