Skip to content

Commit 19b6dc8

Browse files
committed
Add a command to run a command on lovelace
1 parent 368246d commit 19b6dc8

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from discord.ext.commands import Cog, Context, command
2+
3+
from arthur.apis.netcup.ssh import rce_as_a_service
4+
from arthur.bot import KingArthur
5+
6+
7+
class RemoteCommands(Cog):
8+
"""We love RCE."""
9+
10+
def __init__(self, bot: KingArthur) -> None:
11+
self.bot = bot
12+
13+
@command(name="rce")
14+
async def rce(self, ctx: Context, *, command: str) -> None:
15+
"""Ed is the standard text editor."""
16+
if not ctx.guild:
17+
return
18+
if not ctx.bot.is_owner(ctx.author):
19+
await ctx.message.add_reaction("❌")
20+
return
21+
22+
response = await rce_as_a_service(command)
23+
24+
if not response.stderr or not response.stdout:
25+
await ctx.send("Successfully ran with no output!")
26+
return
27+
28+
await ctx.send(f"```{response.stderr}```\n```{response.stdout}```")
29+
30+
31+
async def setup(bot: KingArthur) -> None:
32+
"""Add cog to bot."""
33+
await bot.add_cog(RemoteCommands(bot))

0 commit comments

Comments
 (0)