mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Karma: Delete record instead of resetting it to zero, and make @clear able to delete all records at once.
This commit is contained in:
parent
0d5f8ab05b
commit
1edd7fc379
@ -175,12 +175,15 @@ class SqliteKarmaDB(object):
|
|||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
return [(name, int(i)) for (name, i) in cursor.fetchall()]
|
return [(name, int(i)) for (name, i) in cursor.fetchall()]
|
||||||
|
|
||||||
def clear(self, channel, name):
|
def clear(self, channel, name=None):
|
||||||
db = self._getDb(channel)
|
db = self._getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
normalized = name.lower()
|
if name:
|
||||||
cursor.execute("""UPDATE karma SET subtracted=0, added=0
|
normalized = name.lower()
|
||||||
WHERE normalized=?""", (normalized,))
|
cursor.execute("""DELETE FROM karma
|
||||||
|
WHERE normalized=?""", (normalized,))
|
||||||
|
else:
|
||||||
|
cursor.execute("""DELETE FROM karma""")
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
def dump(self, channel, filename):
|
def dump(self, channel, filename):
|
||||||
@ -362,13 +365,14 @@ class Karma(callbacks.Plugin):
|
|||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def clear(self, irc, msg, args, channel, name):
|
def clear(self, irc, msg, args, channel, name):
|
||||||
"""[<channel>] <name>
|
"""[<channel>] [<name>]
|
||||||
|
|
||||||
Resets the karma of <name> to 0.
|
Resets the karma of <name> to 0. If <name> is not given, resets
|
||||||
|
everything.
|
||||||
"""
|
"""
|
||||||
self.db.clear(channel, name)
|
self.db.clear(channel, name or None)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
clear = wrap(clear, [('checkChannelCapability', 'op'), 'text'])
|
clear = wrap(clear, [('checkChannelCapability', 'op'), optional('text')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def dump(self, irc, msg, args, channel, filename):
|
def dump(self, irc, msg, args, channel, filename):
|
||||||
|
Loading…
Reference in New Issue
Block a user