mirror of
https://github.com/Nick80835/microbot
synced 2025-09-04 08:25:31 +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.pattern_match = pattern_match
|
||||||
event.args = pattern_match.groups()[-1]
|
event.args = pattern_match.groups()[-1]
|
||||||
|
event.other_args = pattern_match.groups()[1:-1]
|
||||||
event.extras = value["extras"]
|
event.extras = value["extras"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -110,6 +111,7 @@ class CommandHandler():
|
|||||||
builder = event.builder
|
builder = event.builder
|
||||||
event.pattern_match = pattern_match
|
event.pattern_match = pattern_match
|
||||||
event.args = pattern_match.groups()[-1]
|
event.args = pattern_match.groups()[-1]
|
||||||
|
event.other_args = pattern_match.groups()[1:-1]
|
||||||
|
|
||||||
photo_list = await value["function"](event)
|
photo_list = await value["function"](event)
|
||||||
|
|
||||||
@@ -141,6 +143,7 @@ class CommandHandler():
|
|||||||
builder = event.builder
|
builder = event.builder
|
||||||
event.pattern_match = pattern_match
|
event.pattern_match = pattern_match
|
||||||
event.args = pattern_match.groups()[-1]
|
event.args = pattern_match.groups()[-1]
|
||||||
|
event.other_args = pattern_match.groups()[1:-1]
|
||||||
|
|
||||||
result_list = await value["function"](event)
|
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>")
|
await event.reply(f"Syntax: {ldr.settings.get_config('cmd_prefix') or '.'}4c(f|) <board name>")
|
||||||
return
|
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:
|
async with ldr.aioclient.get(BOARD_URL.format(event.args)) as response:
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
|
@@ -79,24 +79,24 @@ async def bird(event):
|
|||||||
|
|
||||||
@ldr.add_list(["cat", "pussy"], pattern_extra="(gif|)(f|)")
|
@ldr.add_list(["cat", "pussy"], pattern_extra="(gif|)(f|)")
|
||||||
async def cat(event):
|
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):
|
if isinstance(neko, int):
|
||||||
await event.reply(f"There was an error finding the cats! :( -> **{neko}**")
|
await event.reply(f"There was an error finding the cats! :( -> **{neko}**")
|
||||||
return
|
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|)")
|
@ldr.add_list(["dog", "bitch"], pattern_extra="(gif|)(f|)")
|
||||||
async def dog(event):
|
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):
|
if isinstance(inu, int):
|
||||||
await event.reply(f"There was an error finding the dogs! :( -> **{inu}**")
|
await event.reply(f"There was an error finding the dogs! :( -> **{inu}**")
|
||||||
return
|
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")
|
@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)
|
@ldr.add("dan(s|x|q|)(f|)", nsfw=True, userlocking=True)
|
||||||
async def danbooru(event):
|
async def danbooru(event):
|
||||||
safety_arg = event.pattern_match.group(1)
|
safety_arg = event.other_args[0]
|
||||||
as_file = bool(event.pattern_match.group(2))
|
as_file = bool(event.other_args[1])
|
||||||
rating = ""
|
rating = ""
|
||||||
|
|
||||||
if safety_arg == "x":
|
if safety_arg == "x":
|
||||||
@@ -73,7 +73,7 @@ async def danbooru(event):
|
|||||||
|
|
||||||
@ldr.add_inline_photo("dan(s|x|q|)", default="dan")
|
@ldr.add_inline_photo("dan(s|x|q|)", default="dan")
|
||||||
async def danbooru_inline(event):
|
async def danbooru_inline(event):
|
||||||
safety_arg = event.pattern_match.group(1)
|
safety_arg = event.other_args[0]
|
||||||
rating = ""
|
rating = ""
|
||||||
|
|
||||||
if safety_arg == "x":
|
if safety_arg == "x":
|
||||||
|
@@ -36,7 +36,7 @@ from ubot.micro_bot import ldr
|
|||||||
|
|
||||||
@ldr.add("deepfry(f|)", userlocking=True)
|
@ldr.add("deepfry(f|)", userlocking=True)
|
||||||
async def deepfryer(event):
|
async def deepfryer(event):
|
||||||
as_file = bool(event.pattern_match.group(1))
|
as_file = bool(event.other_args[0])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
frycount = int(event.args)
|
frycount = int(event.args)
|
||||||
|
@@ -29,8 +29,8 @@ async def danbooru_ping(event):
|
|||||||
|
|
||||||
@ldr.add("gel(s|x|q|)(f|)", nsfw=True, userlocking=True)
|
@ldr.add("gel(s|x|q|)(f|)", nsfw=True, userlocking=True)
|
||||||
async def gelbooru(event):
|
async def gelbooru(event):
|
||||||
safety_arg = event.pattern_match.group(1)
|
safety_arg = event.other_args[0]
|
||||||
as_file = bool(event.pattern_match.group(2))
|
as_file = bool(event.other_args[1])
|
||||||
rating = ""
|
rating = ""
|
||||||
|
|
||||||
if safety_arg == "x":
|
if safety_arg == "x":
|
||||||
@@ -79,7 +79,7 @@ async def gelbooru(event):
|
|||||||
|
|
||||||
@ldr.add_inline_photo("gel(s|x|q|)", default="gel")
|
@ldr.add_inline_photo("gel(s|x|q|)", default="gel")
|
||||||
async def gelbooru_inline(event):
|
async def gelbooru_inline(event):
|
||||||
safety_arg = event.pattern_match.group(1)
|
safety_arg = event.other_args[0]
|
||||||
rating = ""
|
rating = ""
|
||||||
|
|
||||||
if safety_arg == "x":
|
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)
|
@ldr.add_list(NEKO_TYPES, nsfw=True, pattern_extra="(f|)", userlocking=True)
|
||||||
async def supernekoatsume(event):
|
async def supernekoatsume(event):
|
||||||
nekotype = event.extras
|
nekotype = event.extras
|
||||||
as_file = bool(event.pattern_match.group(1))
|
as_file = bool(event.other_args[0])
|
||||||
|
|
||||||
if nekotype in REPLY_TYPES:
|
if nekotype in REPLY_TYPES:
|
||||||
reply_to = await event.get_reply_message() or event
|
reply_to = await event.get_reply_message() or event
|
||||||
|
@@ -121,7 +121,7 @@ async def bodyfetcher(event, sub):
|
|||||||
@ldr.add("red(i|t|b)", userlocking=True)
|
@ldr.add("red(i|t|b)", userlocking=True)
|
||||||
async def redimg(event):
|
async def redimg(event):
|
||||||
sub = event.args.replace(" ", "_")
|
sub = event.args.replace(" ", "_")
|
||||||
fetch_type = event.pattern_match.group(1)
|
fetch_type = event.other_args[0]
|
||||||
|
|
||||||
if not sub:
|
if not sub:
|
||||||
await event.reply(f"Syntax: {ldr.settings.get_config('cmd_prefix') or '.'}red(i|t|b) <subreddit name>")
|
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)
|
@ldr.add("jon(x|)", userlocking=True)
|
||||||
async def imsorryjon(event):
|
async def imsorryjon(event):
|
||||||
if "x" in event.pattern_match.group(0):
|
if "x" in event.other_args[0]:
|
||||||
sub = "ImReallySorryJon"
|
sub = "ImReallySorryJon"
|
||||||
else:
|
else:
|
||||||
sub = "ImSorryJon"
|
sub = "ImSorryJon"
|
||||||
|
@@ -26,8 +26,8 @@ async def sankaku_ping(event):
|
|||||||
|
|
||||||
@ldr.add("san(s|x|q|)(f|)", nsfw=True, userlocking=True)
|
@ldr.add("san(s|x|q|)(f|)", nsfw=True, userlocking=True)
|
||||||
async def sankaku(event):
|
async def sankaku(event):
|
||||||
safety_arg = event.pattern_match.group(1)
|
safety_arg = event.other_args[0]
|
||||||
as_file = bool(event.pattern_match.group(2))
|
as_file = bool(event.other_args[1])
|
||||||
rating = ""
|
rating = ""
|
||||||
|
|
||||||
if safety_arg == "x":
|
if safety_arg == "x":
|
||||||
@@ -74,7 +74,7 @@ async def sankaku(event):
|
|||||||
|
|
||||||
@ldr.add_inline_photo("san(s|x|q|)", default="san")
|
@ldr.add_inline_photo("san(s|x|q|)", default="san")
|
||||||
async def sankaku_inline(event):
|
async def sankaku_inline(event):
|
||||||
safety_arg = event.pattern_match.group(1)
|
safety_arg = event.other_args[0]
|
||||||
rating = ""
|
rating = ""
|
||||||
|
|
||||||
if safety_arg == "x":
|
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:
|
async with ldr.aioclient.get("https://pokeapi.co/api/v2/pokemon/" + event.args) as response:
|
||||||
if response.status == 200:
|
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:
|
else:
|
||||||
await event.reply(f"An error occurred: **{response.status}**")
|
await event.reply(f"An error occurred: **{response.status}**")
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user