Markov: try to fix unicode errors in irc bot
This commit is contained in:
parent
a9560b6fa2
commit
3856a1e95b
|
@ -139,15 +139,15 @@ class Markov(Module):
|
||||||
topics = [x for x in addressed_re.match(what).group(1).split(' ') if len(x) >= 3]
|
topics = [x for x in addressed_re.match(what).group(1).split(' ') if len(x) >= 3]
|
||||||
|
|
||||||
self.lines_seen.append(('.self.said.', datetime.now()))
|
self.lines_seen.append(('.self.said.', datetime.now()))
|
||||||
return self.irc.reply(event, '{0:s}: {1:s}'.format(nick,
|
return self.irc.reply(event, u"{0:s}: {1:s}".format(nick,
|
||||||
' '.join(_generate_sentence(context, topics=topics))))
|
u" ".join(_generate_sentence(context, topics=topics))))
|
||||||
else:
|
else:
|
||||||
# i wasn't addressed directly, so just respond
|
# i wasn't addressed directly, so just respond
|
||||||
topics = [x for x in what.split(' ') if len(x) >= 3]
|
topics = [x for x in what.split(' ') if len(x) >= 3]
|
||||||
self.lines_seen.append(('.self.said.', datetime.now()))
|
self.lines_seen.append(('.self.said.', datetime.now()))
|
||||||
|
|
||||||
return self.irc.reply(event, '{0:s}'.format(' '.join(_generate_sentence(context,
|
return self.irc.reply(event, u"{0:s}".format(u" ".join(_generate_sentence(context,
|
||||||
topics=topics))))
|
topics=topics))))
|
||||||
|
|
||||||
def markov_learn(self, event, nick, userhost, what, admin_unlocked):
|
def markov_learn(self, event, nick, userhost, what, admin_unlocked):
|
||||||
"""Learn one line, as provided to the command."""
|
"""Learn one line, as provided to the command."""
|
||||||
|
@ -190,10 +190,12 @@ class Markov(Module):
|
||||||
topics = [x for x in line.split(' ') if len(x) >= 3]
|
topics = [x for x in line.split(' ') if len(x) >= 3]
|
||||||
|
|
||||||
self.lines_seen.append(('.self.said.', datetime.now()))
|
self.lines_seen.append(('.self.said.', datetime.now()))
|
||||||
return ' '.join(_generate_sentence(context, topics=topics, min_words=min_size, max_words=max_size))
|
return u" ".join(_generate_sentence(context, topics=topics,
|
||||||
|
min_words=min_size, max_words=max_size))
|
||||||
else:
|
else:
|
||||||
self.lines_seen.append(('.self.said.', datetime.now()))
|
self.lines_seen.append(('.self.said.', datetime.now()))
|
||||||
return ' '.join(_generate_sentence(context, min_words=min_size, max_words=max_size))
|
return u" ".join(_generate_sentence(context, min_words=min_size,
|
||||||
|
max_words=max_size))
|
||||||
|
|
||||||
def thread_do(self):
|
def thread_do(self):
|
||||||
"""Do various things."""
|
"""Do various things."""
|
||||||
|
|
Loading…
Reference in New Issue