diff --git a/ubot/command_handler.py b/ubot/command_handler.py index 327c7df..5071f2e 100644 --- a/ubot/command_handler.py +++ b/ubot/command_handler.py @@ -50,6 +50,7 @@ class CommandHandler(): event.pattern_match = pattern_match event.args = pattern_match.groups()[-1] + event.other_args = pattern_match.groups()[1:-1] event.extras = value["extras"] try: @@ -110,6 +111,7 @@ class CommandHandler(): builder = event.builder event.pattern_match = pattern_match event.args = pattern_match.groups()[-1] + event.other_args = pattern_match.groups()[1:-1] photo_list = await value["function"](event) @@ -141,6 +143,7 @@ class CommandHandler(): builder = event.builder event.pattern_match = pattern_match event.args = pattern_match.groups()[-1] + event.other_args = pattern_match.groups()[1:-1] result_list = await value["function"](event) diff --git a/ubot/modules/4chan.py b/ubot/modules/4chan.py index 584d05c..34bb4c7 100644 --- a/ubot/modules/4chan.py +++ b/ubot/modules/4chan.py @@ -16,7 +16,7 @@ async def fourchan(event): await event.reply(f"Syntax: {ldr.settings.get_config('cmd_prefix') or '.'}4c(f|) ") return - as_file = bool(event.pattern_match.group(1)) + as_file = bool(event.other_args[0]) async with ldr.aioclient.get(BOARD_URL.format(event.args)) as response: if response.status == 200: diff --git a/ubot/modules/catdog.py b/ubot/modules/catdog.py index f1006df..520c6fe 100644 --- a/ubot/modules/catdog.py +++ b/ubot/modules/catdog.py @@ -79,24 +79,24 @@ async def bird(event): @ldr.add_list(["cat", "pussy"], pattern_extra="(gif|)(f|)") async def cat(event): - neko = await neko_atsume(GIFPARAM if event.pattern_match.group(1) else IMGPARAM) + neko = await neko_atsume(GIFPARAM if event.other_args[0] else IMGPARAM) if isinstance(neko, int): await event.reply(f"There was an error finding the cats! :( -> **{neko}**") return - await event.reply(file=neko[0]["url"], force_document=bool(event.pattern_match.group(2))) + await event.reply(file=neko[0]["url"], force_document=bool(event.other_args[1])) @ldr.add_list(["dog", "bitch"], pattern_extra="(gif|)(f|)") async def dog(event): - inu = await inu_atsume(GIFPARAM if event.pattern_match.group(1) else IMGPARAM) + inu = await inu_atsume(GIFPARAM if event.event.other_args[0] else IMGPARAM) if isinstance(inu, int): await event.reply(f"There was an error finding the dogs! :( -> **{inu}**") return - await event.reply(file=inu[0]["url"], force_document=bool(event.pattern_match.group(2))) + await event.reply(file=inu[0]["url"], force_document=bool(event.other_args[1])) @ldr.add_inline_photo("cat", default="cat") diff --git a/ubot/modules/danbooru.py b/ubot/modules/danbooru.py index 2863f03..e40c963 100644 --- a/ubot/modules/danbooru.py +++ b/ubot/modules/danbooru.py @@ -25,8 +25,8 @@ async def danbooru_ping(event): @ldr.add("dan(s|x|q|)(f|)", nsfw=True, userlocking=True) async def danbooru(event): - safety_arg = event.pattern_match.group(1) - as_file = bool(event.pattern_match.group(2)) + safety_arg = event.other_args[0] + as_file = bool(event.other_args[1]) rating = "" if safety_arg == "x": @@ -73,7 +73,7 @@ async def danbooru(event): @ldr.add_inline_photo("dan(s|x|q|)", default="dan") async def danbooru_inline(event): - safety_arg = event.pattern_match.group(1) + safety_arg = event.other_args[0] rating = "" if safety_arg == "x": diff --git a/ubot/modules/deepfry.py b/ubot/modules/deepfry.py index e58fffc..b6a274c 100644 --- a/ubot/modules/deepfry.py +++ b/ubot/modules/deepfry.py @@ -36,7 +36,7 @@ from ubot.micro_bot import ldr @ldr.add("deepfry(f|)", userlocking=True) async def deepfryer(event): - as_file = bool(event.pattern_match.group(1)) + as_file = bool(event.other_args[0]) try: frycount = int(event.args) diff --git a/ubot/modules/gelbooru.py b/ubot/modules/gelbooru.py index a1193ac..c269a17 100644 --- a/ubot/modules/gelbooru.py +++ b/ubot/modules/gelbooru.py @@ -29,8 +29,8 @@ async def danbooru_ping(event): @ldr.add("gel(s|x|q|)(f|)", nsfw=True, userlocking=True) async def gelbooru(event): - safety_arg = event.pattern_match.group(1) - as_file = bool(event.pattern_match.group(2)) + safety_arg = event.other_args[0] + as_file = bool(event.other_args[1]) rating = "" if safety_arg == "x": @@ -79,7 +79,7 @@ async def gelbooru(event): @ldr.add_inline_photo("gel(s|x|q|)", default="gel") async def gelbooru_inline(event): - safety_arg = event.pattern_match.group(1) + safety_arg = event.other_args[0] rating = "" if safety_arg == "x": diff --git a/ubot/modules/nekos.py b/ubot/modules/nekos.py index 731e4f7..2266995 100644 --- a/ubot/modules/nekos.py +++ b/ubot/modules/nekos.py @@ -14,7 +14,7 @@ REPLY_TYPES = ['cuddle', 'hug', 'slap', 'spank', 'pat', 'baka'] @ldr.add_list(NEKO_TYPES, nsfw=True, pattern_extra="(f|)", userlocking=True) async def supernekoatsume(event): nekotype = event.extras - as_file = bool(event.pattern_match.group(1)) + as_file = bool(event.other_args[0]) if nekotype in REPLY_TYPES: reply_to = await event.get_reply_message() or event diff --git a/ubot/modules/reddit.py b/ubot/modules/reddit.py index c58bd02..e28275f 100644 --- a/ubot/modules/reddit.py +++ b/ubot/modules/reddit.py @@ -114,14 +114,14 @@ async def bodyfetcher(event, sub): await event.reply(f"**{title}**\n\n{body}") return - + await event.reply(f"Failed to find any valid content on **r/{sub}**!") @ldr.add("red(i|t|b)", userlocking=True) async def redimg(event): sub = event.args.replace(" ", "_") - fetch_type = event.pattern_match.group(1) + fetch_type = event.other_args[0] if not sub: await event.reply(f"Syntax: {ldr.settings.get_config('cmd_prefix') or '.'}red(i|t|b) ") @@ -157,7 +157,7 @@ async def todayifuckedup(event): @ldr.add("jon(x|)", userlocking=True) async def imsorryjon(event): - if "x" in event.pattern_match.group(0): + if "x" in event.other_args[0]: sub = "ImReallySorryJon" else: sub = "ImSorryJon" diff --git a/ubot/modules/sankaku.py b/ubot/modules/sankaku.py index 85e1af5..9846d8e 100644 --- a/ubot/modules/sankaku.py +++ b/ubot/modules/sankaku.py @@ -26,8 +26,8 @@ async def sankaku_ping(event): @ldr.add("san(s|x|q|)(f|)", nsfw=True, userlocking=True) async def sankaku(event): - safety_arg = event.pattern_match.group(1) - as_file = bool(event.pattern_match.group(2)) + safety_arg = event.other_args[0] + as_file = bool(event.other_args[1]) rating = "" if safety_arg == "x": @@ -74,7 +74,7 @@ async def sankaku(event): @ldr.add_inline_photo("san(s|x|q|)", default="san") async def sankaku_inline(event): - safety_arg = event.pattern_match.group(1) + safety_arg = event.other_args[0] rating = "" if safety_arg == "x": diff --git a/ubot/modules/scrapers.py b/ubot/modules/scrapers.py index 357b5d1..7b1843a 100644 --- a/ubot/modules/scrapers.py +++ b/ubot/modules/scrapers.py @@ -46,7 +46,7 @@ async def pokemon_image(event): async with ldr.aioclient.get("https://pokeapi.co/api/v2/pokemon/" + event.args) as response: if response.status == 200: - sprite_url = (await response.json())["sprites"]["front_shiny" if event.pattern_match.group(1) else "front_default"] + sprite_url = (await response.json())["sprites"]["front_shiny" if event.other_args[0] else "front_default"] else: await event.reply(f"An error occurred: **{response.status}**") return