From b821e960840c76d98c29c0e248937b7b8285c97f Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Wed, 27 Nov 2019 22:41:31 +0300 Subject: [PATCH] fix mtg --- bots/modules/_mtg.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bots/modules/_mtg.py b/bots/modules/_mtg.py index 2dcb5ec..b605b0a 100644 --- a/bots/modules/_mtg.py +++ b/bots/modules/_mtg.py @@ -49,11 +49,12 @@ class MTG(object): if second_word is not None: return first_word, second_word elif first_word is not None: - if ('.' + '+' + first_word in self.MC) and len(self.MC['.' + '+' + first_word]) != 0: - second_word = random.choice(self.MC['.' + '+' + first_word]) - elif ('.' + '+' + first_word.capitalize() in self.MC) and \ - len(self.MC['.' + '+' + first_word.capitalize()]) != 0: - second_word = random.choice(self.MC['.' + '+' + first_word.capitalize()]) + word = '.' + '+' + first_word + word_cap = '.' + '+' + first_word.capitalize() + if word in self.MC and len(self.MC[word]): + second_word = random.choice(self.MC[word]) + elif word_cap in self.MC and len(self.MC[word_cap]): + second_word = random.choice(self.MC[word_cap]) else: return self.choose_start_words() return first_word, second_word @@ -67,7 +68,7 @@ class MTG(object): while not (len(gen_words) > size and w2 == '.'): gen_words.append(w2.capitalize() if (w1 == '.') else w2) w1, w2 = w2, random.choice(self.MC[w1 + '+' + w2]) - gen_words.append(w2) + gen_words.append(w2) text = ' '.join(gen_words) text = text.replace(' ,', ',').replace(' .', '.') return text