mkdryden / telegram-stats-bot

A simple bot that lives in your Telegram group, logging messages to a Postgresql database and serving statistical tables and plots to users as Telegram messages.
GNU General Public License v3.0
53 stars 20 forks source link

Titles plot fails for some image dimensions #16

Open mkdryden opened 1 year ago

mkdryden commented 1 year ago

Apparently /stats titles fails for chats with a small number of titles, resulting in a weird shaped image:

telegram-stats-bot_1  | Traceback (most recent call last):
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/ext/utils/promise.py", line 96, in run
telegram-stats-bot_1  |     self._result = self.pooled_function(*self.args, **self.kwargs)
telegram-stats-bot_1  |   File "/usr/src/app/telegram_stats_bot/main.py", line 173, in print_stats
telegram-stats-bot_1  |     context.bot.send_photo(chat_id=update.effective_chat.id, photo=image)
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 134, in decorator
telegram-stats-bot_1  |     result = func(*args, **kwargs)
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 753, in send_photo
telegram-stats-bot_1  |     return self._message(  # type: ignore[return-value]
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/ext/extbot.py", line 203, in _message
telegram-stats-bot_1  |     result = super()._message(
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 344, in _message
telegram-stats-bot_1  |     result = self._post(endpoint, data, timeout=timeout, api_kwargs=api_kwargs)
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 299, in _post
telegram-stats-bot_1  |     return self.request.post(
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/utils/request.py", line 359, in post
telegram-stats-bot_1  |     result = self._request_wrapper('POST', url, fields=data, **urlopen_kwargs)
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/utils/request.py", line 279, in _request_wrapper
telegram-stats-bot_1  |     raise BadRequest(message)
telegram-stats-bot_1  | telegram.error.BadRequest: Photo_invalid_dimensions