From 452796556f3ada0a1ad7b4a71ee27cd2c3d67165 Mon Sep 17 00:00:00 2001 From: jkhsjdhjs Date: Tue, 9 Mar 2021 15:16:39 +0000 Subject: [PATCH] tell: fix sending unique constraint violating message multiple times --- bot/tell.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bot/tell.py b/bot/tell.py index bdfb104..8331f08 100644 --- a/bot/tell.py +++ b/bot/tell.py @@ -39,10 +39,6 @@ class Tell(DatabasePlugin): nick = args[''].lower() tell = [nick, mask.nick, ' '.join(args['']).strip(), datetime.utcnow()] - if nick not in self.tell_queue: - self.tell_queue[nick] = [] - self.tell_queue[nick].append(tell[1:]) - try: with self.con.cursor() as cur: cur.execute(''' @@ -52,13 +48,15 @@ class Tell(DatabasePlugin): (%s, %s, %s, %s) ''', tell) self.con.commit() - + if nick not in self.tell_queue: + self.tell_queue[nick] = [] + self.tell_queue[nick].append(tell[1:]) self.bot.notice(mask.nick, "I will tell that to {} when I see them.".format(nick)) except Error as ex: self.log.error(ex) self.con.rollback() - self.bot.notice(mask.nick, "database error") + self.bot.notice(mask.nick, "database error (is the user already awaiting such a message?)") @irc3.event(r'(?i)^:(?P.*) PRIVMSG .* :.*') def on_message(self, mask: str):