From f07f4486eef40de88cf7de1d221e4eb60d94bfc4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 10 Jan 2020 19:04:52 +0100 Subject: [PATCH] Disable markov command --- royalpack/commands/markov.py | 49 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/royalpack/commands/markov.py b/royalpack/commands/markov.py index 47ca5ef2..f162f9bb 100644 --- a/royalpack/commands/markov.py +++ b/royalpack/commands/markov.py @@ -1,8 +1,8 @@ from typing import * from royalnet.commands import * -import markovify -import os -import re +# import markovify +# import os +# import re class MarkovCommand(Command): @@ -12,29 +12,30 @@ class MarkovCommand(Command): syntax: str = "[modello]" - _texts: Dict[str, markovify.NewlineText] = {} + # _texts: Dict[str, markovify.NewlineText] = {} def __init__(self, interface: CommandInterface): super().__init__(interface) - if interface.name == "telegram": - files: List[str] = tuple(os.walk(self.config["Markov"]["models_directory"]))[0][2] - for file in files: - match = re.match(r"(\S+)\.json$", file) - if match is None: - continue - model_name = match.group(1) - with open(os.path.join(self.config["Markov"]["models_directory"], file)) as f: - self._texts[model_name] = markovify.NewlineText.from_json(f.read()) + # if interface.name == "telegram": + # files: List[str] = tuple(os.walk(self.config["Markov"]["models_directory"]))[0][2] + # for file in files: + # match = re.match(r"(\S+)\.json$", file) + # if match is None: + # continue + # model_name = match.group(1) + # with open(os.path.join(self.config["Markov"]["models_directory"], file)) as f: + # self._texts[model_name] = markovify.NewlineText.from_json(f.read()) async def run(self, args: CommandArgs, data: CommandData) -> None: - if self.interface.name != "telegram": - raise UnsupportedError("[c]markov[/c] funziona solo su Telegram.") - model_name = args.optional(0, self.config["Markov"]["default_model"]) - try: - sentence = self._texts[model_name].make_sentence() - except KeyError: - raise InvalidInputError("Il modello richiesto non esiste.") - if sentence is None or sentence == "": - await data.reply(f"๐Ÿ’ญ Il bot ([c]{model_name}[/c])... non dice niente. Riprova!") - else: - await data.reply(f'๐Ÿ’ฌ Il bot ([c]{model_name}[/c]) dice:\n{sentence}') + raise CommandError(f"{self} รจ disattivato. Riprova tra un po' di giorni!") + # if self.interface.name != "telegram": + # raise UnsupportedError("[c]markov[/c] funziona solo su Telegram.") + # model_name = args.optional(0, self.config["Markov"]["default_model"]) + # try: + # sentence = self._texts[model_name].make_sentence() + # except KeyError: + # raise InvalidInputError("Il modello richiesto non esiste.") + # if sentence is None or sentence == "": + # await data.reply(f"๐Ÿ’ญ Il bot ([c]{model_name}[/c])... non dice niente. Riprova!") + # else: + # await data.reply(f'๐Ÿ’ฌ Il bot ([c]{model_name}[/c]) dice:\n{sentence}')