From 3e83ba95da2f1484ca8a4e784e808ff93d5ea6cc Mon Sep 17 00:00:00 2001 From: b3yond Date: Sun, 9 Sep 2018 20:32:10 +0200 Subject: [PATCH] those error messages are a bit universal. --- active_bots/telegrambot.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/active_bots/telegrambot.py b/active_bots/telegrambot.py index 12a85a6..e916943 100644 --- a/active_bots/telegrambot.py +++ b/active_bots/telegrambot.py @@ -18,25 +18,23 @@ class TelegramBot(Bot): updates = tb.get_updates().wait() reports = [] for update in updates: - try: - user.save_seen_tg(update.update_id) - if update.message.text.lower() == "/start": - user.add_telegram_subscribers(update.message.sender.id) - tb.send_message(update.message.sender.id, "You are now subscribed to report notifications.") - # TODO: /start message should be set in frontend - elif update.message.text.lower() == "/stop": - user.remove_telegram_subscribers(update.message.sender.id) - tb.send_message(update.message.sender.id, "You are now unsubscribed from report notifications.") - # TODO: /stop message should be set in frontend - elif update.message.text.lower() == "/help": - tb.send_message(update.message.sender.id, "Send reports here to share them with other users. Use /start and /stop to get reports or not.") - # TODO: /help message should be set in frontend - else: - reports.append(Report(update.message.sender.username, self, - update.message.text, None, update.message.date)) - except AttributeError: - logger.error('Some Attribute Error. ', exc_info=True) + if update == 404: return reports + user.save_seen_tg(update.update_id) + if update.message.text.lower() == "/start": + user.add_telegram_subscribers(update.message.sender.id) + tb.send_message(update.message.sender.id, "You are now subscribed to report notifications.") + # TODO: /start message should be set in frontend + elif update.message.text.lower() == "/stop": + user.remove_telegram_subscribers(update.message.sender.id) + tb.send_message(update.message.sender.id, "You are now unsubscribed from report notifications.") + # TODO: /stop message should be set in frontend + elif update.message.text.lower() == "/help": + tb.send_message(update.message.sender.id, "Send reports here to share them with other users. Use /start and /stop to get reports or not.") + # TODO: /help message should be set in frontend + else: + reports.append(Report(update.message.sender.username, self, + update.message.text, None, update.message.date)) return reports def post(self, user, report):