fix markovify

This commit is contained in:
bakatrouble 2019-11-27 23:13:59 +03:00
parent acb96c7556
commit 26b26c69c7

View File

@ -40,10 +40,6 @@ class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
'_mtg_data': JSONEditor(), '_mtg_data': JSONEditor(),
} }
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.mtg = markovify.Text.from_dict(self._mtg_data)
def message_handler(self, update: Update, ctx: CallbackContext): def message_handler(self, update: Update, ctx: CallbackContext):
if not update.effective_chat or not update.effective_user: if not update.effective_chat or not update.effective_user:
return return
@ -91,6 +87,7 @@ class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
def inline_query_handler(self, update: Update, ctx: CallbackContext): def inline_query_handler(self, update: Update, ctx: CallbackContext):
if not self.inline_reactions: if not self.inline_reactions:
return return
mtg = markovify.Text.from_dict(self._mtg_data)
seed(os.urandom(128)) seed(os.urandom(128))
results = [ results = [
InlineQueryResultArticle( InlineQueryResultArticle(
@ -101,7 +98,7 @@ class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
InlineQueryResultArticle( InlineQueryResultArticle(
id=uuid4(), id=uuid4(),
title='ФлаБеПроЛейка', title='ФлаБеПроЛейка',
input_message_content=InputTextMessageContent(choice(self.mtg.generate_text())) input_message_content=InputTextMessageContent(mtg.make_sentence())
), ),
] ]
update.inline_query.answer(results, cache_time=0) update.inline_query.answer(results, cache_time=0)