1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

fix a few bugs in markov

This commit is contained in:
Steffo 2020-01-09 13:41:31 +01:00
parent caa2fff26c
commit a80e94bb83
3 changed files with 13 additions and 10 deletions

View file

@ -2,7 +2,7 @@
[tool.poetry]
name = "royalpack"
version = "5.2.4"
version = "5.2.5"
description = "A Royalnet command pack for the Royal Games community"
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
license = "AGPL-3.0+"

View file

@ -16,9 +16,10 @@ class MarkovCommand(Command):
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("(\S+)\.json", file)
match = re.match(r"(\S+)\.json$", file)
if match is None:
continue
model_name = match.group(1)
@ -26,6 +27,8 @@ class MarkovCommand(Command):
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()

View file

@ -1 +1 @@
semantic = "5.2.4"
semantic = "5.2.5"