mcmaniac: print confirmation when new entry is added

This commit is contained in:
jkhsjdhjs 2021-12-06 02:51:00 +00:00
parent c1439ca4c5
commit 5fe240db8b

View File

@ -49,8 +49,8 @@ class McManiac(DatabasePlugin):
if result:
return '[{rank}/{total}] {item}'.format(**result)
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG \S+ :.*?\b(?P<item>Mc\S+iaC)\b.*')
def save(self, mask: str, item: str):
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG (?P<channel>#\S+) :.*?\b(?P<item>Mc\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()
result = cur.fetchone()
if result is None:
return
self.bot.privmsg(channel, f"{result['total']}. mcmanic added: {item}")