mirror of https://github.com/Mikaela/Limnoria.git
Let's not error to the channel if we're randomly speaking
This commit is contained in:
parent
d103888968
commit
56907b8266
|
@ -231,7 +231,8 @@ class Markov(callbacks.Privmsg):
|
||||||
if now > self.lastSpoke + throttle:
|
if now > self.lastSpoke + throttle:
|
||||||
canSpeak = True
|
canSpeak = True
|
||||||
if canSpeak and random.random() < prob:
|
if canSpeak and random.random() < prob:
|
||||||
f = self._markov(channel, irc, private=True, to=channel)
|
f = self._markov(channel, irc, private=True, to=channel,
|
||||||
|
Random=True)
|
||||||
schedule.addEvent(lambda: self.q.enqueue(f), now + delay)
|
schedule.addEvent(lambda: self.q.enqueue(f), now + delay)
|
||||||
self.lastSpoke = now + delay
|
self.lastSpoke = now + delay
|
||||||
words = self.tokenize(msg)
|
words = self.tokenize(msg)
|
||||||
|
@ -301,8 +302,13 @@ class Markov(callbacks.Privmsg):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
irc.error('I was unable to generate a Markov chain at least %s '
|
if not Random:
|
||||||
'long.' % utils.nItems('word', minLength))
|
irc.error('I was unable to generate a Markov chain at least %s'
|
||||||
|
' long.' % utils.nItems('word', minLength))
|
||||||
|
else:
|
||||||
|
self.log.debug('Not randomSpeaking. Unable to generate a '
|
||||||
|
'Markov chain at least %s long.' %
|
||||||
|
utils.nItems('word', minLength))
|
||||||
return f
|
return f
|
||||||
|
|
||||||
def markov(self, irc, msg, args, channel, word1, word2):
|
def markov(self, irc, msg, args, channel, word1, word2):
|
||||||
|
@ -313,7 +319,7 @@ class Markov(callbacks.Privmsg):
|
||||||
channel itself). If word1 and word2 are specified, they will be used
|
channel itself). If word1 and word2 are specified, they will be used
|
||||||
to start the Markov chain.
|
to start the Markov chain.
|
||||||
"""
|
"""
|
||||||
f = self._markov(channel, irc, word1, word2)
|
f = self._markov(channel, irc, word1, word2, Random=False)
|
||||||
self.q.enqueue(f)
|
self.q.enqueue(f)
|
||||||
markov = wrap(markov, ['channeldb', optional('something'),
|
markov = wrap(markov, ['channeldb', optional('something'),
|
||||||
additional('something')])
|
additional('something')])
|
||||||
|
|
Loading…
Reference in New Issue