mirror of
https://github.com/Nick80835/microbot
synced 2025-08-31 14:38:04 +00:00
add an easier flags variable
this also fixes a bug
This commit is contained in:
@@ -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)
|
||||
|
||||
|
@@ -16,7 +16,7 @@ async def fourchan(event):
|
||||
await event.reply(f"Syntax: {ldr.settings.get_config('cmd_prefix') or '.'}4c(f|) <board name>")
|
||||
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:
|
||||
|
@@ -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")
|
||||
|
@@ -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":
|
||||
|
@@ -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)
|
||||
|
@@ -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":
|
||||
|
@@ -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
|
||||
|
@@ -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) <subreddit name>")
|
||||
@@ -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"
|
||||
|
@@ -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":
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user