mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
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)
|
irc.error(msg, conf.replyNotRegistered)
|
||||||
return
|
return
|
||||||
key, fact = match.groups()
|
key, fact = match.groups()
|
||||||
|
# Strip the key of punctuation and spaces
|
||||||
|
key = key.strip('?!')
|
||||||
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 LIKE %s""", key)
|
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.prefix = 'foo!bar@baz'
|
||||||
self.assertNotError('register tester moo')
|
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):
|
def testLiteral(self):
|
||||||
self.assertError('literal moo') # no factoids yet
|
self.assertError('literal moo') # no factoids yet
|
||||||
self.assertNotError('moo is <reply>foo')
|
self.assertNotError('moo is <reply>foo')
|
||||||
|
Loading…
Reference in New Issue
Block a user