From 5fe240db8bc0745c9d5346c3d05bd693fda7696e Mon Sep 17 00:00:00 2001 From: jkhsjdhjs Date: Mon, 6 Dec 2021 02:51:00 +0000 Subject: [PATCH] mcmaniac: print confirmation when new entry is added --- bot/mcmaniac.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bot/mcmaniac.py b/bot/mcmaniac.py index acc6966..f3752f5 100644 --- a/bot/mcmaniac.py +++ b/bot/mcmaniac.py @@ -49,8 +49,8 @@ class McManiac(DatabasePlugin): if result: return '[{rank}/{total}] {item}'.format(**result) - @irc3.event(r'^:(?P\S+) PRIVMSG \S+ :.*?\b(?PMc\S+iaC)\b.*') - def save(self, mask: str, item: str): + @irc3.event(r'^:(?P\S+) PRIVMSG (?P#\S+) :.*?\b(?PMc\S+iaC)\b.*') + def save(self, mask: str, channel: str, item: str): if IrcString(mask).nick != self.bot.nick: with self.con.cursor() as cur: cur.execute(''' @@ -59,5 +59,11 @@ class McManiac(DatabasePlugin): VALUES (%s) ON CONFLICT DO NOTHING + RETURNING + (SELECT (count(*) + 1) AS total FROM mcmaniacs) ''', [item]) - self.con.commit() + self.con.commit() + result = cur.fetchone() + if result is None: + return + self.bot.privmsg(channel, f"{result['total']}. mcmanic added: {item}")