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}")