From c56f3951e1085501ca5680015f3f7cbc5a9f104a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 14 Jul 2022 16:43:05 +0200 Subject: [PATCH] make roll command neater --- files/helpers/regex.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 6eeb33f87..90f38551c 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -1,6 +1,6 @@ import re from .const import * -from random import choice +from random import choice, choices if SITE_NAME == 'PCM': valid_username_chars = 'a-zA-Z0-9_\-А-я' @@ -144,4 +144,8 @@ commands = { command_regex = re.compile("(\s|\n|^)#(fortune|factcheck|8ball|roll)", flags=re.A|re.I) def command_regex_matcher(match, upper=False): - return match.group(1) + str(choice(commands[match.group(2).lower()])) \ No newline at end of file + result = str(choice(commands[match.group(2).lower()])) + if match.group(2) == 'roll': + color = tuple(choices(range(256), k=3)) + result = f'Your roll: {result}' + return match.group(1) + result \ No newline at end of file