Skip to content

Commit

Permalink
Plugins: debug: only accept eval for OWNER
Browse files Browse the repository at this point in the history
-> usage for ping and speedtest

Change-Id: Ifcefd2b8b215bbd78acaaf5e525b5abf3f14b2e6
  • Loading branch information
adekmaulana committed Jul 11, 2021
1 parent 0533204 commit d5b50dc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bot/plugins/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@

from bot import command, plugin, util

OWNER: int = int(os.environ.get("OWNER_ID", 0))


class Debug(plugin.Plugin):
name: ClassVar[str] = "Debug"

@command.desc("Pong")
async def cmd_ping(self, ctx: command.Context) -> str:
start = datetime.now()
await ctx.respond("Calculating response time...")
Expand All @@ -25,6 +28,8 @@ async def cmd_ping(self, ctx: command.Context) -> str:

return f"Latency: {latency} ms"


@command.desc("Test bot speed")
async def cmd_speedtest(self, ctx: command.Context) -> str:
before = util.time.usec()

Expand Down Expand Up @@ -53,6 +58,10 @@ async def cmd_speedtest(self, ctx: command.Context) -> str:

return status


@command.usage("[code]")
@command.desc("Run python code to debugging")
@command.filters(pyrogram.filters.user(OWNER)) # Only for owners, lazy hax use env
async def cmd_eval(self, ctx: command.Context) -> str:
code = ctx.input
if not code:
Expand Down

0 comments on commit d5b50dc

Please sign in to comment.