mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Fix bug #1087369, WordStats is case sensitive
This commit is contained in:
parent
dc408473db
commit
cd4f073ad5
@ -158,19 +158,19 @@ class WordStatsDB(plugins.ChannelUserDB):
|
||||
id = ircdb.users.getUserId(msg.prefix)
|
||||
except KeyError:
|
||||
return
|
||||
msgwords = [s.strip(nonAlphaNumeric) for s in text.split()]
|
||||
msgwords = [s.strip(nonAlphaNumeric).lower() for s in text.split()]
|
||||
if channel not in self.channelWords:
|
||||
self.channelWords[channel] = {}
|
||||
for word in self.channelWords[channel]:
|
||||
word = word.lower()
|
||||
for msgword in msgwords:
|
||||
if msgword == word:
|
||||
self.channelWords[channel][word] += 1
|
||||
lword = word.lower()
|
||||
count = msgwords.count(lword)
|
||||
if count:
|
||||
self.channelWords[channel][word] += count
|
||||
if (channel, id) not in self:
|
||||
self[channel, id] = {}
|
||||
if word not in self[channel, id]:
|
||||
self[channel, id][word] = 0
|
||||
self[channel, id][word] += 1
|
||||
self[channel, id][word] += count
|
||||
|
||||
|
||||
filename = conf.supybot.directories.data.dirize('WordStats.db')
|
||||
|
@ -191,5 +191,16 @@ class WordStatsTestCase(ChannelPluginTestCase):
|
||||
finally:
|
||||
conf.supybot.plugins.WordStats.ignoreQueries.setValue(original)
|
||||
|
||||
def testWordStatsCaseInsensitive(self):
|
||||
self.assertNotError('add lol')
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'lOL',
|
||||
prefix=self.prefix))
|
||||
self.assertRegexp('wordstats foo', r'[\'"]lol[\'"]: 2')
|
||||
self.assertNotError('add MOO')
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'mOo',
|
||||
prefix=self.prefix))
|
||||
self.assertRegexp('wordstats foo',
|
||||
r'(lol|MOO)[\'"]: 2 and [\'"](lol|MOO)[\'"]: 2')
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user