mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Karma works now.
This commit is contained in:
parent
2dd5a522d3
commit
6d40bb475e
@ -38,6 +38,7 @@ statistics about smileys, actions, characters, and words.
|
|||||||
from baseplugin import *
|
from baseplugin import *
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import sets
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import sqlite
|
import sqlite
|
||||||
@ -57,9 +58,10 @@ smileyre = re.compile('|'.join(map(re.escape, smileys)))
|
|||||||
frownre = re.compile('|'.join(map(re.escape, frowns)))
|
frownre = re.compile('|'.join(map(re.escape, frowns)))
|
||||||
|
|
||||||
class ChannelDB(callbacks.PrivmsgCommandAndRegexp, ChannelDBHandler):
|
class ChannelDB(callbacks.PrivmsgCommandAndRegexp, ChannelDBHandler):
|
||||||
|
regexps = sets.Set(['increaseKarma', 'decreaseKarma'])
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
ChannelDBHandler.__init__(self)
|
ChannelDBHandler.__init__(self)
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||||
|
|
||||||
def makeDb(self, filename):
|
def makeDb(self, filename):
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
@ -111,7 +113,7 @@ class ChannelDB(callbacks.PrivmsgCommandAndRegexp, ChannelDBHandler):
|
|||||||
return db
|
return db
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
callbacks.Privmsg.doPrivmsg(self, irc, msg)
|
callbacks.PrivmsgCommandAndRegexp.doPrivmsg(self, irc, msg)
|
||||||
if ircutils.isChannel(msg.args[0]):
|
if ircutils.isChannel(msg.args[0]):
|
||||||
(channel, s) = msg.args
|
(channel, s) = msg.args
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
@ -301,18 +303,20 @@ class ChannelDB(callbacks.PrivmsgCommandAndRegexp, ChannelDBHandler):
|
|||||||
|
|
||||||
def increaseKarma(self, irc, msg, match):
|
def increaseKarma(self, irc, msg, match):
|
||||||
r"^(.*?)\+\+"
|
r"^(.*?)\+\+"
|
||||||
|
debug.printf('increaseKarma')
|
||||||
name = match.group(1)
|
name = match.group(1)
|
||||||
db = self.getDb(msg.args[0])
|
db = self.getDb(msg.args[0])
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""INSERT INTO karma VALUES (0, %s, 1, 0)""", name)
|
cursor.execute("""INSERT INTO karma VALUES (NULL, %s, 1, 0)""", name)
|
||||||
cursor.execute("""UPDATE karma SET added=added+1 WHERE name=%s""",name)
|
cursor.execute("""UPDATE karma SET added=added+1 WHERE name=%s""",name)
|
||||||
|
|
||||||
def decreaseKarma(self, irc, msg, match):
|
def decreaseKarma(self, irc, msg, match):
|
||||||
r"^(.*?)--"
|
r"^(.*?)--"
|
||||||
|
debug.printf('decreaseKarma')
|
||||||
name = match.group(1)
|
name = match.group(1)
|
||||||
db = self.getDb(msg.args[0])
|
db = self.getDb(msg.args[0])
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""INSERT INTO karma VALUES (0, %s, 0, 1)""", name)
|
cursor.execute("""INSERT INTO karma VALUES (NULL, %s, 0, 1)""", name)
|
||||||
cursor.execute("""UPDATE karma
|
cursor.execute("""UPDATE karma
|
||||||
SET subtracted=subtracted+1
|
SET subtracted=subtracted+1
|
||||||
WHERE name=%s""", name)
|
WHERE name=%s""", name)
|
||||||
|
Loading…
Reference in New Issue
Block a user