mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 14:40:51 +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)
|
id = ircdb.users.getUserId(msg.prefix)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
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:
|
if channel not in self.channelWords:
|
||||||
self.channelWords[channel] = {}
|
self.channelWords[channel] = {}
|
||||||
for word in self.channelWords[channel]:
|
for word in self.channelWords[channel]:
|
||||||
word = word.lower()
|
lword = word.lower()
|
||||||
for msgword in msgwords:
|
count = msgwords.count(lword)
|
||||||
if msgword == word:
|
if count:
|
||||||
self.channelWords[channel][word] += 1
|
self.channelWords[channel][word] += count
|
||||||
if (channel, id) not in self:
|
if (channel, id) not in self:
|
||||||
self[channel, id] = {}
|
self[channel, id] = {}
|
||||||
if word not in self[channel, id]:
|
if word not in self[channel, id]:
|
||||||
self[channel, id][word] = 0
|
self[channel, id][word] = 0
|
||||||
self[channel, id][word] += 1
|
self[channel, id][word] += count
|
||||||
|
|
||||||
|
|
||||||
filename = conf.supybot.directories.data.dirize('WordStats.db')
|
filename = conf.supybot.directories.data.dirize('WordStats.db')
|
||||||
|
@ -191,5 +191,16 @@ class WordStatsTestCase(ChannelPluginTestCase):
|
|||||||
finally:
|
finally:
|
||||||
conf.supybot.plugins.WordStats.ignoreQueries.setValue(original)
|
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:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user