mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Should fix a reported bug. I guess db isn't always iterable.
This commit is contained in:
parent
6c9d74e728
commit
570b3024c2
@ -107,7 +107,7 @@ class DbmMarkovDB(object):
|
|||||||
isFirst=False, isLast=False):
|
isFirst=False, isLast=False):
|
||||||
db = self._getDb(channel)
|
db = self._getDb(channel)
|
||||||
combined = self._combine(first, second)
|
combined = self._combine(first, second)
|
||||||
if combined in db: # EW!
|
if db.has_key(combined): # EW!
|
||||||
db[combined] = ' '.join([db[combined], follower])
|
db[combined] = ' '.join([db[combined], follower])
|
||||||
else:
|
else:
|
||||||
db[combined] = follower
|
db[combined] = follower
|
||||||
@ -201,6 +201,8 @@ class Markov(callbacks.Privmsg):
|
|||||||
def tokenize(self, m):
|
def tokenize(self, m):
|
||||||
if ircmsgs.isAction(m):
|
if ircmsgs.isAction(m):
|
||||||
return ircmsgs.unAction(m).split()
|
return ircmsgs.unAction(m).split()
|
||||||
|
elif ircmsgs.isCtcp(m):
|
||||||
|
return []
|
||||||
else:
|
else:
|
||||||
return m.args[1].split()
|
return m.args[1].split()
|
||||||
|
|
||||||
@ -211,6 +213,9 @@ class Markov(callbacks.Privmsg):
|
|||||||
words.insert(0, '\n')
|
words.insert(0, '\n')
|
||||||
words.insert(0, '\n')
|
words.insert(0, '\n')
|
||||||
words.append('\n')
|
words.append('\n')
|
||||||
|
# This shouldn't happen often (CTCP messages being the possible exception)
|
||||||
|
if not words or len(words) == 3:
|
||||||
|
return
|
||||||
def doPrivmsg(db):
|
def doPrivmsg(db):
|
||||||
for (first, second, follower) in window(words, 3):
|
for (first, second, follower) in window(words, 3):
|
||||||
db.addPair(channel, first, second, follower)
|
db.addPair(channel, first, second, follower)
|
||||||
@ -308,3 +313,5 @@ class Markov(callbacks.Privmsg):
|
|||||||
|
|
||||||
|
|
||||||
Class = Markov
|
Class = Markov
|
||||||
|
|
||||||
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user