From 423731751d4d676f8ee977818fb565884efcd843 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 13 Apr 2018 19:45:54 +0300 Subject: [PATCH] Make sure BotChat row exists before trying to delete it --- mautrix_telegram/bot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mautrix_telegram/bot.py b/mautrix_telegram/bot.py index 02ef656a..e56eb814 100644 --- a/mautrix_telegram/bot.py +++ b/mautrix_telegram/bot.py @@ -103,8 +103,10 @@ class Bot(AbstractUser): del self.chats[id] except KeyError: pass - self.db.delete(BotChat.query.get(id)) - self.db.commit() + existing_chat = BotChat.query.get(id) + if existing_chat: + self.db.delete(existing_chat) + self.db.commit() async def _can_use_commands(self, chat, tgid): if tgid in self.tg_whitelist: