add runas command
This commit is contained in:
parent
69c166685f
commit
3f8ec459b5
1 changed files with 13 additions and 0 deletions
|
@ -197,3 +197,16 @@ class EvalModule(niobot.Module):
|
|||
thumb.save("file.webp", "webp")
|
||||
attachment = await niobot.ImageAttachment.from_file("file.webp", generate_blurhash=True)
|
||||
await ctx.respond("thumbnail.webp", file=attachment)
|
||||
|
||||
@niobot.command()
|
||||
@niobot.is_owner()
|
||||
async def runas(self, ctx: niobot.Context, user: str, command: str, *args: str):
|
||||
"""Run a command as another user."""
|
||||
event = ctx.event
|
||||
event.sender = user
|
||||
event.body = f"{command} {' '.join(args)}"
|
||||
try:
|
||||
result = await self.bot.process_event(event)
|
||||
await ctx.respond(f"Result of runas: `{result!r}`")
|
||||
except Exception as e:
|
||||
await ctx.respond(f"Error in runas process: `{e!r}`")
|
||||
|
|
Loading…
Reference in a new issue