Make sure BotChat row exists before trying to delete it

This commit is contained in:
Tulir Asokan
2018-04-13 19:45:54 +03:00
parent 92b86deeba
commit 423731751d
+4 -2
View File
@@ -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: