mirror of https://github.com/Mikaela/Limnoria.git
Punctuation ("?!") is now stripped from keys before insertion into the db
This commit is contained in:
parent
d174226c5c
commit
2527f47cb6
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue