mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 10:34:19 +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):
|
def makeDb(self, filename):
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
return sqlite.connect(db=filename, mode=0755,
|
db = sqlite.connect(filename, converters={'bool': bool})
|
||||||
converters={'bool': bool})
|
else:
|
||||||
#else:
|
db = sqlite.connect(filename, coverters={'bool': bool})
|
||||||
db = sqlite.connect(db=filename, mode=0755, coverters={'bool': bool})
|
cursor = db.cursor()
|
||||||
cursor = db.cursor()
|
cursor.execute("""CREATE TABLE quotegrabs (
|
||||||
cursor.execute("""CREATE TABLE quotegrabs (
|
id INTEGER PRIMARY KEY,
|
||||||
id INTEGER PRIMARY KEY,
|
nick TEXT,
|
||||||
nick TEXT,
|
hostmask TEXT,
|
||||||
hostmask TEXT,
|
added_by TEXT,
|
||||||
added_by TEXT,
|
added_at TIMESTAMP,
|
||||||
added_at TIMESTAMP,
|
quote TEXT
|
||||||
quote TEXT
|
);""")
|
||||||
);""")
|
def p(s1, s2):
|
||||||
|
return int(ircutils.nickEqual(s1, s2))
|
||||||
|
db.create_function('nickeq', 2, p)
|
||||||
db.commit()
|
db.commit()
|
||||||
return db
|
return db
|
||||||
|
|
||||||
@ -148,7 +150,7 @@ class QuoteGrabs(plugins.ChannelDBHandler,
|
|||||||
irc.error(msg, 'You can\'t quote grab yourself.')
|
irc.error(msg, 'You can\'t quote grab yourself.')
|
||||||
return
|
return
|
||||||
for m in reviter(irc.state.history):
|
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)
|
self._grab(irc, m, msg.prefix)
|
||||||
irc.reply(msg, conf.replySuccess)
|
irc.reply(msg, conf.replySuccess)
|
||||||
return
|
return
|
||||||
@ -165,7 +167,7 @@ class QuoteGrabs(plugins.ChannelDBHandler,
|
|||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""SELECT quote FROM quotegrabs
|
cursor.execute("""SELECT quote FROM quotegrabs
|
||||||
WHERE nick=%s
|
WHERE nickeq(nick, %s)
|
||||||
ORDER BY id DESC LIMIT 1""", nick)
|
ORDER BY id DESC LIMIT 1""", nick)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.error(msg,'I couldn\'t find a matching quotegrab for %s'%nick)
|
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.assertNotError('grab foo') # note: NOT an error, still won't dupe
|
||||||
self.assertResponse('quotegrabs list foo', '#1: test')
|
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:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user