2
0
mirror of https://github.com/Nick80835/microbot synced 2025-09-01 06:55:51 +00:00

allow simplifying command registry to just a string arg for the pattern

This commit is contained in:
Nick80835
2020-05-02 17:04:27 -04:00
parent 917aedebe9
commit de2fd1f841
13 changed files with 49 additions and 47 deletions

View File

@@ -10,7 +10,7 @@ from ubot.micro_bot import micro_bot
ldr = micro_bot.loader
@ldr.add(pattern="reload", sudo=True)
@ldr.add("reload", sudo=True)
async def reload_modules(event):
reload_msg = await event.reply("`Reloading modules…`")
@@ -25,14 +25,14 @@ async def reload_modules(event):
pass
@ldr.add(pattern="del")
@ldr.add("del")
async def delete_message(event):
message_to_delete = await event.get_reply_message()
if message_to_delete.from_id == (await event.client.get_me()).id:
await message_to_delete.delete()
@ldr.add(pattern="alive", sudo=True)
@ldr.add("alive", sudo=True)
async def alive(event):
alive_format = "`μBot is running under {0}.\n\n" \
"Version: {1}\n" \
@@ -42,13 +42,13 @@ async def alive(event):
await event.reply(alive_format.format(uname().node, ldr.botversion, version.__version__, python_version()))
@ldr.add(pattern="shutdown", sudo=True)
@ldr.add("shutdown", sudo=True)
async def shutdown(event):
await event.reply("`Goodbye…`")
await micro_bot.stop_client()
@ldr.add(pattern="ping")
@ldr.add("ping")
async def ping(event):
start = time_ns()
ping_msg = await event.reply("`Ping…`")
@@ -56,6 +56,6 @@ async def ping(event):
await ping_msg.edit(f"`Ping… Pong! -> `**{time_taken_ms}**`ms`")
@ldr.add(pattern="repo")
@ldr.add("repo")
async def bot_repo(event):
await event.reply("https://github.com/Nick80835/microbot")