mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Made MoobotFactoids case insensitive, and added tests to make sure that
case-insensitivity works.
This commit is contained in:
parent
f0574da59a
commit
1b25a207bf
@ -205,7 +205,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
return
|
return
|
||||||
# Check the factoid db for an appropriate reply
|
# Check the factoid db for an appropriate reply
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT fact FROM factoids WHERE key = %s""", key)
|
cursor.execute("""SELECT fact FROM factoids WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
text = self._getDunno(msg.nick)
|
text = self._getDunno(msg.nick)
|
||||||
irc.reply(msg, text, prefixName=False)
|
irc.reply(msg, text, prefixName=False)
|
||||||
@ -249,7 +249,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
key, fact = match.groups()
|
key, fact = match.groups()
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
# Check and make sure it's not in the DB already
|
# Check and make sure it's not in the DB already
|
||||||
cursor.execute("""SELECT * FROM factoids WHERE key = %s""", key)
|
cursor.execute("""SELECT * FROM factoids WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount != 0:
|
if cursor.rowcount != 0:
|
||||||
irc.error(msg, "Factoid '%s' already exists." % key)
|
irc.error(msg, "Factoid '%s' already exists." % key)
|
||||||
return
|
return
|
||||||
@ -273,7 +273,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
# Check and make sure it's in the DB
|
# Check and make sure it's in the DB
|
||||||
cursor.execute("""SELECT locked_at, fact FROM factoids
|
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||||
WHERE key = %s""", key)
|
WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error(msg, "Factoid '%s' not found." % key)
|
irc.error(msg, "Factoid '%s' not found." % key)
|
||||||
return
|
return
|
||||||
@ -308,7 +308,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
# Check and make sure it's in the DB
|
# Check and make sure it's in the DB
|
||||||
cursor.execute("""SELECT locked_at, fact FROM factoids
|
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||||
WHERE key = %s""", key)
|
WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error(msg, "Factoid '%s' not found." % key)
|
irc.error(msg, "Factoid '%s' not found." % key)
|
||||||
return
|
return
|
||||||
@ -338,7 +338,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
# Check and make sure it's in the DB
|
# Check and make sure it's in the DB
|
||||||
cursor.execute("""SELECT locked_at, fact FROM factoids
|
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||||
WHERE key = %s""", key)
|
WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error(msg, "Factoid '%s' not found." % key)
|
irc.error(msg, "Factoid '%s' not found." % key)
|
||||||
return
|
return
|
||||||
@ -367,7 +367,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
"""
|
"""
|
||||||
key = privmsgs.getArgs(args, needed=1)
|
key = privmsgs.getArgs(args, needed=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT fact FROM factoids WHERE key = %s""", key)
|
cursor.execute("""SELECT fact FROM factoids WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error(msg, "No such factoid: %s" % key)
|
irc.error(msg, "No such factoid: %s" % key)
|
||||||
return
|
return
|
||||||
@ -388,7 +388,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
cursor.execute("""SELECT created_by, created_at, modified_by,
|
cursor.execute("""SELECT created_by, created_at, modified_by,
|
||||||
modified_at, last_requested_by, last_requested_at,
|
modified_at, last_requested_by, last_requested_at,
|
||||||
requested_count, locked_at FROM
|
requested_count, locked_at FROM
|
||||||
factoids WHERE key = %s""", key)
|
factoids WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error(msg, "No such factoid: %s" % key)
|
irc.error(msg, "No such factoid: %s" % key)
|
||||||
return
|
return
|
||||||
@ -432,7 +432,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
key = privmsgs.getArgs(args, needed=1)
|
key = privmsgs.getArgs(args, needed=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT created_by, locked_at FROM factoids
|
cursor.execute("""SELECT created_by, locked_at FROM factoids
|
||||||
WHERE key = %s""", key)
|
WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error(msg, "No such factoid: %s" % key)
|
irc.error(msg, "No such factoid: %s" % key)
|
||||||
return
|
return
|
||||||
@ -559,7 +559,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
key = privmsgs.getArgs(args, needed=1)
|
key = privmsgs.getArgs(args, needed=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT key, locked_at FROM factoids
|
cursor.execute("""SELECT key, locked_at FROM factoids
|
||||||
WHERE key = %s""", key)
|
WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error(msg, "No such factoid: %s" % key)
|
irc.error(msg, "No such factoid: %s" % key)
|
||||||
return
|
return
|
||||||
|
@ -66,6 +66,10 @@ if sqlite is not None:
|
|||||||
# Test and make sure it's parsing
|
# Test and make sure it's parsing
|
||||||
self.assertNotError('moo4 is <reply>(1|2|3)')
|
self.assertNotError('moo4 is <reply>(1|2|3)')
|
||||||
self.assertRegexp('moo4', '^(1|2|3)$')
|
self.assertRegexp('moo4', '^(1|2|3)$')
|
||||||
|
# Check case-insensitivity
|
||||||
|
self.assertResponse('MOO', 'foo')
|
||||||
|
self.assertResponse('mOo', 'foo')
|
||||||
|
self.assertResponse('MoO', 'foo')
|
||||||
|
|
||||||
def testFactinfo(self):
|
def testFactinfo(self):
|
||||||
self.assertNotError('moo is <reply>foo')
|
self.assertNotError('moo is <reply>foo')
|
||||||
@ -206,7 +210,7 @@ if sqlite is not None:
|
|||||||
|
|
||||||
def testDunnoAdd(self):
|
def testDunnoAdd(self):
|
||||||
self.assertNotError('dunnoadd moo')
|
self.assertNotError('dunnoadd moo')
|
||||||
self.assertResponse('asdfagagfosdfk', 'moo (#1)')
|
self.assertResponse('asdfagagfosdfk', 'moo')
|
||||||
|
|
||||||
def testDunnoRemove(self):
|
def testDunnoRemove(self):
|
||||||
self.assertNotError('dunnoadd moo')
|
self.assertNotError('dunnoadd moo')
|
||||||
|
Loading…
Reference in New Issue
Block a user