From 2527f47cb6056ae835469412944e329417506854 Mon Sep 17 00:00:00 2001 From: Daniel DiPaolo Date: Tue, 28 Oct 2003 15:30:43 +0000 Subject: [PATCH] Punctuation ("?!") is now stripped from keys before insertion into the db --- plugins/MoobotFactoids.py | 2 ++ test/test_MoobotFactoids.py | 7 +++++++ 2 files changed, 9 insertions(+) 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')