ssh connection feature added

This commit is contained in:
esef committed 2026-07-01 00:03:27 +03:00
1 parent f91c7fed04
commit 21fa63b032
3 files changed
+40 -3

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import os
import subprocess
import discord
from discord.ext import commands
class Rio(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def connectrio(self, ctx):
target = os.getenv("RIO_CONNECTION")
try:
result = subprocess.run(
["ssh", "-o", "BatchMode=yes", target, "echo ok"],
capture_output=True,
text=True,
timeout=10
)
if result.returncode == 0 and "ok" in result.stdout:
await ctx.reply("ok")
else:
await ctx.reply("failed")
except Exception as e:
await ctx.reply(f"failed: {e}")
async def setup(bot):
await bot.add_cog(Rio(bot))