diff --git a/plugins/MoobotFactoids.py b/plugins/MoobotFactoids.py index d3ad99c6f..2a5b0caa5 100644 --- a/plugins/MoobotFactoids.py +++ b/plugins/MoobotFactoids.py @@ -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) diff --git a/test/test_MoobotFactoids.py b/test/test_MoobotFactoids.py index 2dba0c289..3580915f9 100644 --- a/test/test_MoobotFactoids.py +++ b/test/test_MoobotFactoids.py @@ -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 foo')