From 68aa8b85b85088be19b92593c43959be85730731 Mon Sep 17 00:00:00 2001 From: Stan James Date: Thu, 28 Jun 2018 11:54:17 -0600 Subject: [PATCH] Move notification chat to end of function ...So if notification channel is not set up right, it doesn't stop blocking from happening. --- bot.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bot.py b/bot.py index 99014e5..6932eb3 100644 --- a/bot.py +++ b/bot.py @@ -79,8 +79,6 @@ class TelegramMonitorBot: if self.debug: update.message.reply_text(log_message) print(log_message) - # Notify channel - bot.sendMessage(chat_id=self.notify_chat, text="🤖:" + log_message) # Ban the user self.ban_user(update) # Log in database @@ -91,6 +89,8 @@ class TelegramMonitorBot: s.add(userBan) s.commit() s.close() + # Notify channel + bot.sendMessage(chat_id=self.notify_chat, text=log_message) if self.name_ban_re and self.name_ban_re.search(update.message.from_user.username or ''): # Logging @@ -98,8 +98,6 @@ class TelegramMonitorBot: if self.debug: update.message.reply_text(log_message) print(log_message) - # Notify channel - bot.sendMessage(chat_id=self.notify_chat, text=log_message) # Ban the user self.ban_user(update) # Log in database @@ -110,6 +108,8 @@ class TelegramMonitorBot: s.add(userBan) s.commit() s.close() + # Notify channel + bot.sendMessage(chat_id=self.notify_chat, text=log_message) def security_check_message(self, bot, update): @@ -126,8 +126,6 @@ class TelegramMonitorBot: if self.debug: update.message.reply_text(log_message) print(log_message) - # Notify channel - bot.sendMessage(chat_id=self.notify_chat, text=log_message) # Any message that causes a ban gets deleted update.message.delete() # Ban the user @@ -140,6 +138,8 @@ class TelegramMonitorBot: s.add(userBan) s.commit() s.close() + # Notify channel + bot.sendMessage(chat_id=self.notify_chat, text=log_message) elif self.message_hide_re and self.message_hide_re.search(message): # Logging @@ -147,8 +147,6 @@ class TelegramMonitorBot: if self.debug: update.message.reply_text(log_message) print(log_message) - # Notify channel - bot.sendMessage(chat_id=self.notify_chat, text=log_message) # Delete the message update.message.delete() # Log in database @@ -159,6 +157,8 @@ class TelegramMonitorBot: s.add(messageHide) s.commit() s.close() + # Notify channel + bot.sendMessage(chat_id=self.notify_chat, text=log_message) def logger(self, bot, update):