From cf9f9eacc052c9016c51c73f3bf4de061f0f5aad Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Thu, 22 Feb 2024 14:45:50 -0600 Subject: [PATCH] Mods --- main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 11f1f1b..7a68a0b 100644 --- a/main.py +++ b/main.py @@ -35,7 +35,7 @@ def get_path(name): return str(Path(HERE, name)) def extract_range(string): - pattern = re.compile(r"(\d+)(?:-(\d+))?") + pattern = re.compile(r"\s*(\d+)\s*(?:-\s*(\d+))?\s*") match = pattern.search(string) if not match: @@ -49,6 +49,9 @@ def extract_range(string): else: return [int(start), int(end)] +def clean_list(lst): + return list(filter(lambda x: x != "", lst)) + headers = { "User-Agent": "gluebot", "Origin": "https://deek.chat", @@ -142,8 +145,8 @@ async def on_message(ws, message): await gif_wins(args[0], room_id) elif cmd == "numbers" or cmd == "number" or cmd == "nums" or cmd == "num": - if len(args) >= 1: - arg = args[0] + if len(args) > 0: + arg = " ".join(clean_list(args)) else: arg = None @@ -210,7 +213,7 @@ async def gif_numbers(arg, room_id): if numbers[0] < numbers[1]: num = random_int(numbers[0], numbers[1]) - if num <= 0: + if num < 0: num = random_int(0, 999) input_path = get_path("numbers.png")