mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
fix a few bugs in markov
This commit is contained in:
parent
caa2fff26c
commit
a80e94bb83
3 changed files with 13 additions and 10 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "royalpack"
|
name = "royalpack"
|
||||||
version = "5.2.4"
|
version = "5.2.5"
|
||||||
description = "A Royalnet command pack for the Royal Games community"
|
description = "A Royalnet command pack for the Royal Games community"
|
||||||
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
||||||
license = "AGPL-3.0+"
|
license = "AGPL-3.0+"
|
||||||
|
|
|
@ -16,16 +16,19 @@ class MarkovCommand(Command):
|
||||||
|
|
||||||
def __init__(self, interface: CommandInterface):
|
def __init__(self, interface: CommandInterface):
|
||||||
super().__init__(interface)
|
super().__init__(interface)
|
||||||
files: List[str] = tuple(os.walk(self.config["Markov"]["models_directory"]))[0][2]
|
if interface.name == "telegram":
|
||||||
for file in files:
|
files: List[str] = tuple(os.walk(self.config["Markov"]["models_directory"]))[0][2]
|
||||||
match = re.match("(\S+)\.json", file)
|
for file in files:
|
||||||
if match is None:
|
match = re.match(r"(\S+)\.json$", file)
|
||||||
continue
|
if match is None:
|
||||||
model_name = match.group(1)
|
continue
|
||||||
with open(os.path.join(self.config["Markov"]["models_directory"], file)) as f:
|
model_name = match.group(1)
|
||||||
self._texts[model_name] = markovify.NewlineText.from_json(f.read())
|
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:
|
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"])
|
model_name = args.optional(0, self.config["Markov"]["default_model"])
|
||||||
try:
|
try:
|
||||||
sentence = self._texts[model_name].make_sentence()
|
sentence = self._texts[model_name].make_sentence()
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
semantic = "5.2.4"
|
semantic = "5.2.5"
|
||||||
|
|
Loading…
Reference in a new issue