Skip to content

Commit

Permalink
Merge pull request #165 from hoeckxer/feature/telegram_error_handling
Browse files Browse the repository at this point in the history
Added error handling for telegram messages not being able to send
  • Loading branch information
enarjord authored Jun 25, 2021
2 parents f6d5078 + 8900084 commit 3ec9f68
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,19 @@ def send_msg(self, msg: str):
parse_mode=ParseMode.HTML,
reply_markup=self._keyboards[self._keyboard_idx],
disable_notification=False
).message_id
)
except Exception as e:
print(f'Failed to send telegram message: {e}')
print(f'Error sending telegram message: {e}')
try:
self._updater.bot.send_message(
self._chat_id,
text=f'Error sending message: {e}',
parse_mode=ParseMode.HTML,
reply_markup=self._keyboards[self._keyboard_idx],
disable_notification=False
)
except Exception as fe:
print(f'Failed to send error message: {fe}')

def exit(self):
try:
Expand Down

0 comments on commit 3ec9f68

Please sign in to comment.