Punctuation ("?!") is now stripped from keys before insertion into the db

This commit is contained in:
Daniel DiPaolo 2003-10-28 15:30:43 +00:00
parent d174226c5c
commit 2527f47cb6
2 changed files with 9 additions and 0 deletions

View File

@ -219,6 +219,8 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
irc.error(msg, conf.replyNotRegistered)
return
key, fact = match.groups()
# Strip the key of punctuation and spaces
key = key.strip('?!')
cursor = self.db.cursor()
# Check and make sure it's not in the DB already
cursor.execute("""SELECT * FROM factoids WHERE key LIKE %s""", key)

View File

@ -45,6 +45,13 @@ if sqlite is not None:
self.prefix = 'foo!bar@baz'
self.assertNotError('register tester moo')
def testAddFactoid(self):
self.assertNotError('moo is foo')
# Check stripping punctuation
self.assertError('moo!? is foo') # 'moo' already exists
self.assertNotError('foo!? is foo')
self.assertResponse('foo', 'foo is foo')
def testLiteral(self):
self.assertError('literal moo') # no factoids yet
self.assertNotError('moo is <reply>foo')