mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 02:24:12 +01:00
Fixed bug #835786 -- case insensitive now.
This commit is contained in:
parent
71791ab60b
commit
ce212fa2cd
@ -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)
|
||||
|
@ -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:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user