From 509c6f7c432d2ec2659768d3d19bd1d9285583f2 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Wed, 8 Jun 2022 18:59:57 +0100 Subject: [PATCH] Notify the owner of subscriptions --- smsbot/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/smsbot/__init__.py b/smsbot/__init__.py index 3d9f1c3..ad35091 100644 --- a/smsbot/__init__.py +++ b/smsbot/__init__.py @@ -47,6 +47,7 @@ class TelegramSmsBot(object): if not update.message.chat['id'] in self.subscriber_ids: self.logger.info('{0} subscribed'.format(update.message.chat['username'])) self.subscriber_ids.append(update.message.chat['id']) + self.send_owner('{0} has subscribed'.format(update.message.chat['username']))) update.message.reply_markdown('You have been subscribed to SMS notifications') else: update.message.reply_markdown('You are already subscribed to SMS notifications') @@ -56,6 +57,7 @@ class TelegramSmsBot(object): if update.message.chat['id'] in self.subscriber_ids: self.logger.info('{0} unsubscribed'.format(update.message.chat['username'])) self.subscriber_ids.remove(update.message.chat['id']) + self.send_owner('{0} has unsubscribed'.format(update.message.chat['username']))) update.message.reply_markdown('You have been unsubscribed to SMS notifications') else: update.message.reply_markdown('You are not subscribed to SMS notifications') @@ -63,6 +65,7 @@ class TelegramSmsBot(object): def error_handler(self, update, context): """Log Errors caused by Updates.""" self.logger.warning('Update "%s" caused error "%s"', update, context.error) + self.send_owner('Update "%{0}" caused error "{1}"'.format(update, context.error)) def send_message(self, message, chat_id): self.bot.sendMessage(text=message, chat_id=chat_id)