mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 22:24:20 +01:00
Made seen case-insensitive.
This commit is contained in:
parent
7973dc8921
commit
fc24f3ded1
@ -84,7 +84,8 @@ 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)
|
||||||
|
else:
|
||||||
db = sqlite.connect(filename)
|
db = sqlite.connect(filename)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""CREATE TABLE user_stats (
|
cursor.execute("""CREATE TABLE user_stats (
|
||||||
@ -134,6 +135,9 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
|
|||||||
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