From d60a49c275e20fb7de9555bd5ceaca5c26df3c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 18 Apr 2019 16:11:57 +0200 Subject: [PATCH] maybe no self.markov --- delojza.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/delojza.py b/delojza.py index 9e0fb86..699e700 100755 --- a/delojza.py +++ b/delojza.py @@ -208,16 +208,18 @@ class DelojzaBot: self.handle([url], update.message, self.download_raw, filename=filename) 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): - 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): self.logger.error(error) if "Timed out" in str(error): 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) else: if update is not None: