tell: fix sending unique constraint violating message multiple times
This commit is contained in:
parent
31631e3e4d
commit
452796556f
10
bot/tell.py
10
bot/tell.py
@ -39,10 +39,6 @@ class Tell(DatabasePlugin):
|
||||
nick = args['<nick>'].lower()
|
||||
tell = [nick, mask.nick, ' '.join(args['<message>']).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<mask>.*) PRIVMSG .* :.*')
|
||||
def on_message(self, mask: str):
|
||||
|
Loading…
Reference in New Issue
Block a user