maybe no self.markov

This commit is contained in:
Tomáš Mládek 2019-04-18 16:11:57 +02:00 committed by Tomáš Mládek
parent dd5224dd0d
commit d60a49c275

View file

@ -208,16 +208,18 @@ class DelojzaBot:
self.handle([url], update.message, self.download_raw, filename=filename) self.handle([url], update.message, self.download_raw, filename=filename)
def handle_text(self, _, update): def handle_text(self, _, update):
self.markov.add_to_corpus(update.message.text) if self.markov:
self.markov.add_to_corpus(update.message.text)
def tg_start(self, _, update): def tg_start(self, _, update):
update.message.reply_text(self.markov.make_sentence()) update.message.reply_text(self.markov.make_sentence() if self.markov else "HELLO")
def tg_error(self, bot, update, error): def tg_error(self, bot, update, error):
self.logger.error(error) self.logger.error(error)
if "Timed out" in str(error): if "Timed out" in str(error):
if update is not None: if update is not None:
update.message.reply_text(self.markov.make_sentence(tries=100) or "Mmmm, I like it...") default = "Mmmm, I like it..."
update.message.reply_text((self.markov.make_sentence(tries=100) if self.markov else default) or default)
self.handle_rest(bot, update) self.handle_rest(bot, update)
else: else:
if update is not None: if update is not None: