mcmaniac: print confirmation when new entry is added
This commit is contained in:
parent
c1439ca4c5
commit
5fe240db8b
|
@ -49,8 +49,8 @@ class McManiac(DatabasePlugin):
|
||||||
if result:
|
if result:
|
||||||
return '[{rank}/{total}] {item}'.format(**result)
|
return '[{rank}/{total}] {item}'.format(**result)
|
||||||
|
|
||||||
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG \S+ :.*?\b(?P<item>Mc\S+iaC)\b.*')
|
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG (?P<channel>#\S+) :.*?\b(?P<item>Mc\S+iaC)\b.*')
|
||||||
def save(self, mask: str, item: str):
|
def save(self, mask: str, channel: str, item: str):
|
||||||
if IrcString(mask).nick != self.bot.nick:
|
if IrcString(mask).nick != self.bot.nick:
|
||||||
with self.con.cursor() as cur:
|
with self.con.cursor() as cur:
|
||||||
cur.execute('''
|
cur.execute('''
|
||||||
|
@ -59,5 +59,11 @@ class McManiac(DatabasePlugin):
|
||||||
VALUES
|
VALUES
|
||||||
(%s)
|
(%s)
|
||||||
ON CONFLICT DO NOTHING
|
ON CONFLICT DO NOTHING
|
||||||
|
RETURNING
|
||||||
|
(SELECT (count(*) + 1) AS total FROM mcmaniacs)
|
||||||
''', [item])
|
''', [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}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user