From ce212fa2cdb65779d5a85a024e59edff4f5a08c0 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 5 Nov 2003 06:29:07 +0000 Subject: [PATCH] Fixed bug #835786 -- case insensitive now. --- plugins/QuoteGrabs.py | 32 +++++++++++++++++--------------- test/test_QuoteGrabs.py | 9 +++++++++ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/plugins/QuoteGrabs.py b/plugins/QuoteGrabs.py index 778c6874b..5f9b6cd88 100644 --- a/plugins/QuoteGrabs.py +++ b/plugins/QuoteGrabs.py @@ -77,19 +77,21 @@ class QuoteGrabs(plugins.ChannelDBHandler, def makeDb(self, filename): if os.path.exists(filename): - return sqlite.connect(db=filename, mode=0755, - converters={'bool': bool}) - #else: - db = sqlite.connect(db=filename, mode=0755, coverters={'bool': bool}) - cursor = db.cursor() - cursor.execute("""CREATE TABLE quotegrabs ( - id INTEGER PRIMARY KEY, - nick TEXT, - hostmask TEXT, - added_by TEXT, - added_at TIMESTAMP, - quote TEXT - );""") + db = sqlite.connect(filename, converters={'bool': bool}) + else: + db = sqlite.connect(filename, coverters={'bool': bool}) + cursor = db.cursor() + cursor.execute("""CREATE TABLE quotegrabs ( + id INTEGER PRIMARY KEY, + nick TEXT, + hostmask TEXT, + added_by TEXT, + added_at TIMESTAMP, + quote TEXT + );""") + def p(s1, s2): + return int(ircutils.nickEqual(s1, s2)) + db.create_function('nickeq', 2, p) db.commit() return db @@ -148,7 +150,7 @@ class QuoteGrabs(plugins.ChannelDBHandler, irc.error(msg, 'You can\'t quote grab yourself.') return for m in reviter(irc.state.history): - if m.command == 'PRIVMSG' and m.nick == nick: + if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick): self._grab(irc, m, msg.prefix) irc.reply(msg, conf.replySuccess) return @@ -165,7 +167,7 @@ class QuoteGrabs(plugins.ChannelDBHandler, db = self.getDb(channel) cursor = db.cursor() cursor.execute("""SELECT quote FROM quotegrabs - WHERE nick=%s + WHERE nickeq(nick, %s) ORDER BY id DESC LIMIT 1""", nick) if cursor.rowcount == 0: irc.error(msg,'I couldn\'t find a matching quotegrab for %s'%nick) diff --git a/test/test_QuoteGrabs.py b/test/test_QuoteGrabs.py index 8d7a81ae1..e1d2bd77c 100644 --- a/test/test_QuoteGrabs.py +++ b/test/test_QuoteGrabs.py @@ -75,5 +75,14 @@ class QuoteGrabsTestCase(ChannelPluginTestCase, PluginDocumentation): self.assertNotError('grab foo') # note: NOT an error, still won't dupe self.assertResponse('quotegrabs list foo', '#1: test') + def testCaseInsensitivity(self): + testPrefix = 'foo!bar@baz' + self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test', + prefix=testPrefix)) + self.assertNotError('grab FOO') + self.assertNotError('quote foo') + self.assertNotError('quote FoO') + self.assertNotError('quote Foo') + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: