Skip to content
Snippets Groups Projects
Commit f85d082b authored by Iori Ichinose's avatar Iori Ichinose :speech_balloon:
Browse files

add repeat command

parent 330db103
No related branches found
No related tags found
No related merge requests found
......@@ -58,10 +58,17 @@ class Command:
return ''
return random.choice(words)
@staticmethod
def repeat(m: re.Match) -> str:
key = m.group(1)
count = int(m.group(2))
return key * count
commands: dict[re.Pattern, Callable[[re.Match], str]] = {
re.compile(r'rand (\d+) (\d+)'): Command.rand,
re.compile(r'choice (.*)'): Command.choice
re.compile(r'choice (.*)'): Command.choice,
re.compile(r'repeat (.*?) (\d+)'): Command.repeat,
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment