Skip to content

Commit

Permalink
Add better error handling in the UrlTask (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bb4L authored Jul 17, 2020
1 parent c18b12e commit d5f0231
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='telegram-task-bot',
version='0.1.0',
version='0.1.1',
license='LGPLv3',
description='Library for writing task based telegram bots',
long_description=open('README.md').read(),
Expand Down
9 changes: 7 additions & 2 deletions telegramtaskbot/Tasks/UrlTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ def callback(self, context: telegram.ext.CallbackContext):
response_message = self.get_data()
self.logger.info(f'Notifying {len(users)} users for {self.job_name}')
for user in users:
context.bot.send_message(chat_id=user, text=response_message,
disable_notification=self.disable_notifications)
try:
self.logger.info(f'Notifying {user}')
context.bot.send_message(chat_id=user, text=response_message,
disable_notification=self.disable_notifications)
except telegram.TelegramError as e:
self.logger.info(f'Error occurred while notifying {user}')
self.logger.error(e.message)

def get_actual_value(self, joblist: [], update: telegram.Update, context: telegram.ext.CallbackContext):
self.handle_get_actual_value(context, update.callback_query.message.chat_id)
Expand Down

0 comments on commit d5f0231

Please sign in to comment.