mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 14:14:37 +01:00
Made seen case-insensitive.
This commit is contained in:
parent
7973dc8921
commit
fc24f3ded1
@ -84,56 +84,60 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
|
|||||||
|
|
||||||
def makeDb(self, filename):
|
def makeDb(self, filename):
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
return sqlite.connect(filename)
|
db = sqlite.connect(filename)
|
||||||
db = sqlite.connect(filename)
|
else:
|
||||||
cursor = db.cursor()
|
db = sqlite.connect(filename)
|
||||||
cursor.execute("""CREATE TABLE user_stats (
|
cursor = db.cursor()
|
||||||
id INTEGER PRIMARY KEY,
|
cursor.execute("""CREATE TABLE user_stats (
|
||||||
name TEXT UNIQUE,
|
id INTEGER PRIMARY KEY,
|
||||||
last_seen TIMESTAMP,
|
name TEXT UNIQUE,
|
||||||
last_msg TEXT,
|
last_seen TIMESTAMP,
|
||||||
smileys INTEGER,
|
last_msg TEXT,
|
||||||
frowns INTEGER,
|
smileys INTEGER,
|
||||||
chars INTEGER,
|
frowns INTEGER,
|
||||||
words INTEGER,
|
chars INTEGER,
|
||||||
msgs INTEGER,
|
words INTEGER,
|
||||||
actions INTEGER,
|
msgs INTEGER,
|
||||||
joins INTEGER,
|
actions INTEGER,
|
||||||
parts INTEGER,
|
joins INTEGER,
|
||||||
kicks INTEGER,
|
parts INTEGER,
|
||||||
kicked INTEGER,
|
kicks INTEGER,
|
||||||
modes INTEGER,
|
kicked INTEGER,
|
||||||
topics INTEGER
|
modes INTEGER,
|
||||||
)""")
|
topics INTEGER
|
||||||
cursor.execute("""CREATE TABLE channel_stats (
|
)""")
|
||||||
smileys INTEGER,
|
cursor.execute("""CREATE TABLE channel_stats (
|
||||||
frowns INTEGER,
|
smileys INTEGER,
|
||||||
chars INTEGER,
|
frowns INTEGER,
|
||||||
words INTEGER,
|
chars INTEGER,
|
||||||
msgs INTEGER,
|
words INTEGER,
|
||||||
actions INTEGER,
|
msgs INTEGER,
|
||||||
joins INTEGER,
|
actions INTEGER,
|
||||||
parts INTEGER,
|
joins INTEGER,
|
||||||
kicks INTEGER,
|
parts INTEGER,
|
||||||
modes INTEGER,
|
kicks INTEGER,
|
||||||
topics INTEGER
|
modes INTEGER,
|
||||||
)""")
|
topics INTEGER
|
||||||
cursor.execute("""CREATE TABLE nick_seen (
|
)""")
|
||||||
name TEXT UNIQUE ON CONFLICT REPLACE,
|
cursor.execute("""CREATE TABLE nick_seen (
|
||||||
last_seen TIMESTAMP,
|
name TEXT UNIQUE ON CONFLICT REPLACE,
|
||||||
last_msg TEXT
|
last_seen TIMESTAMP,
|
||||||
)""")
|
last_msg TEXT
|
||||||
cursor.execute("""INSERT INTO channel_stats
|
)""")
|
||||||
VALUES (0, 0, 0, 0, 0,
|
cursor.execute("""INSERT INTO channel_stats
|
||||||
0, 0, 0, 0, 0, 0)""")
|
VALUES (0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0)""")
|
||||||
|
|
||||||
cursor.execute("""CREATE TABLE karma (
|
cursor.execute("""CREATE TABLE karma (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
name TEXT UNIQUE ON CONFLICT IGNORE,
|
name TEXT UNIQUE ON CONFLICT IGNORE,
|
||||||
added INTEGER,
|
added INTEGER,
|
||||||
subtracted INTEGER
|
subtracted INTEGER
|
||||||
)""")
|
)""")
|
||||||
db.commit()
|
db.commit()
|
||||||
|
def p(s1, s2):
|
||||||
|
return int(ircutils.nickEqual(s1, s2))
|
||||||
|
db.create_function('nickeq', 2, p)
|
||||||
return db
|
return db
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
@ -303,11 +307,11 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
table = 'nick_seen'
|
table = 'nick_seen'
|
||||||
sql = """SELECT last_seen, last_msg FROM %s WHERE name=%%s""" % table
|
sql = "SELECT last_seen, last_msg FROM %s WHERE nickeq(name,%%s)"%table
|
||||||
#debug.printf(sql)
|
#debug.printf(sql)
|
||||||
cursor.execute(sql, name)
|
cursor.execute(sql, name)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.reply(msg, 'I have not seen %s.' % name)
|
irc.error(msg, 'I have not seen %s.' % name)
|
||||||
else:
|
else:
|
||||||
(seen, m) = cursor.fetchone()
|
(seen, m) = cursor.fetchone()
|
||||||
seen = int(seen)
|
seen = int(seen)
|
||||||
|
@ -51,6 +51,11 @@ if sqlite is not None:
|
|||||||
def testNoKeyErrorStats(self):
|
def testNoKeyErrorStats(self):
|
||||||
self.assertNotRegexp('stats sweede', 'KeyError')
|
self.assertNotRegexp('stats sweede', 'KeyError')
|
||||||
|
|
||||||
|
def testSeen(self):
|
||||||
|
self.assertNotError('list')
|
||||||
|
self.assertNotError('seen %s' % self.nick)
|
||||||
|
self.assertNotError('seen %s' % self.nick.upper())
|
||||||
|
|
||||||
def testKarma(self):
|
def testKarma(self):
|
||||||
self.assertRegexp('karma foobar', 'no karma')
|
self.assertRegexp('karma foobar', 'no karma')
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user