Made *everything* case-insensitive.

This commit is contained in:
Jeremy Fincher 2003-10-14 05:54:11 +00:00
parent 76c4b7ed4c
commit e4c64ec2ca
2 changed files with 26 additions and 12 deletions

View File

@ -168,7 +168,7 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
return return
cursor.execute("""SELECT COUNT(*) cursor.execute("""SELECT COUNT(*)
FROM user_stats FROM user_stats
WHERE name=%s""", name) WHERE nickeq(name,%s)""", name)
count = int(cursor.fetchone()[0]) count = int(cursor.fetchone()[0])
if count == 0: # User isn't in database. if count == 0: # User isn't in database.
cursor.execute("""INSERT INTO user_stats VALUES ( cursor.execute("""INSERT INTO user_stats VALUES (
@ -183,7 +183,7 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
words=words+%s, msgs=msgs+1, words=words+%s, msgs=msgs+1,
actions=actions+%s, smileys=smileys+%s, actions=actions+%s, smileys=smileys+%s,
frowns=frowns+%s frowns=frowns+%s
WHERE name=%s""", WHERE nickeq(name,%s)""",
int(time.time()), s, int(time.time()), s,
chars, words, int(isAction), chars, words, int(isAction),
smileys, frowns, name) smileys, frowns, name)
@ -201,7 +201,7 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
name = msg.prefix name = msg.prefix
cursor.execute("""UPDATE user_stats cursor.execute("""UPDATE user_stats
SET joins=joins+1 SET joins=joins+1
WHERE name=%s""", name) WHERE nickeq(name,%s)""", name)
except KeyError: except KeyError:
pass pass
db.commit() db.commit()
@ -216,8 +216,8 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
name = ircdb.users.getUser(msg.prefix).name name = ircdb.users.getUser(msg.prefix).name
else: else:
name = msg.prefix name = msg.prefix
cursor.execute("UPDATE user_stats SET parts=parts+1 WHERE name=%s", cursor.execute("""UPDATE user_stats SET parts=parts+1
name) WHERE nickeq(name,%s)""", name)
except KeyError: except KeyError:
pass pass
db.commit() db.commit()
@ -234,7 +234,7 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
name = msg.prefix name = msg.prefix
cursor.execute("""UPDATE user_stats cursor.execute("""UPDATE user_stats
SET topics=topics+1 SET topics=topics+1
WHERE name=%s""", name) WHERE nickeq(name,%s)""", name)
except KeyError: except KeyError:
pass pass
db.commit() db.commit()
@ -251,7 +251,7 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
name = msg.prefix name = msg.prefix
cursor.execute("""UPDATE user_stats cursor.execute("""UPDATE user_stats
SET modes=modes+1 SET modes=modes+1
WHERE name=%s""", name) WHERE nickeq(name,%s)""", name)
except KeyError: except KeyError:
pass pass
db.commit() db.commit()
@ -268,7 +268,7 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
name = msg.prefix name = msg.prefix
cursor.execute("""UPDATE user_stats cursor.execute("""UPDATE user_stats
SET kicks=kicks+1 SET kicks=kicks+1
WHERE name=%s""", name) WHERE nickeq(name,%s)""", name)
except KeyError: except KeyError:
pass pass
try: try:
@ -276,7 +276,7 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
name = ircdb.users.getUser(irc.state.nickToHostmask(kicked)).name name = ircdb.users.getUser(irc.state.nickToHostmask(kicked)).name
cursor.execute("""UPDATE user_stats cursor.execute("""UPDATE user_stats
SET kicked=kicked+1 SET kicked=kicked+1
WHERE name=%s""", name) WHERE nickeq(name,%s)""", name)
except KeyError: except KeyError:
pass pass
db.commit() db.commit()
@ -405,9 +405,9 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
cursor = db.cursor() cursor = db.cursor()
cursor.execute("""SELECT smileys, frowns, chars, words, msgs, actions, cursor.execute("""SELECT smileys, frowns, chars, words, msgs, actions,
joins, parts, kicks, kicked, modes, topics joins, parts, kicks, kicked, modes, topics
FROM user_stats WHERE name=%s""", name) FROM user_stats WHERE nickeq(name,%s)""", name)
if cursor.rowcount == 0: if cursor.rowcount == 0:
irc.reply(msg, 'I have no stats for that user.') irc.error(msg, 'I have no stats for that user.')
return return
values = cursor.fetchone() values = cursor.fetchone()
s = '%s has sent %s; a total of %s, %s, ' \ s = '%s has sent %s; a total of %s, %s, ' \

View File

@ -38,12 +38,26 @@ except ImportError:
if sqlite is not None: if sqlite is not None:
class ChannelDBTestCase(ChannelPluginTestCase, PluginDocumentation): class ChannelDBTestCase(ChannelPluginTestCase, PluginDocumentation):
plugins = ('ChannelDB', 'MiscCommands') plugins = ('ChannelDB', 'MiscCommands', 'UserCommands')
def setUp(self):
ChannelPluginTestCase.setUp(self)
self.prefix = 'foo!bar@baz'
self.nick = 'foo'
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick,
'register foo bar',
prefix=self.prefix))
_ = self.irc.takeMsg()
def test(self): def test(self):
self.assertNotError('channelstats') self.assertNotError('channelstats')
self.assertNotError('channelstats') self.assertNotError('channelstats')
self.assertNotError('channelstats') self.assertNotError('channelstats')
def testStats(self):
self.assertError('stats %s' % self.nick)
self.assertNotError('stats %s' % self.nick)
self.assertNotError('stats %s' % self.nick.upper())
def testNoKeyErrorEscapeFromSeen(self): def testNoKeyErrorEscapeFromSeen(self):
self.assertRegexp('seen asldfkjasdlfkj', 'I have not seen') self.assertRegexp('seen asldfkjasdlfkj', 'I have not seen')
self.assertNotRegexp('seen asldfkjasdlfkj', 'KeyError') self.assertNotRegexp('seen asldfkjasdlfkj', 'KeyError')