From 72302a52011e494da2eaa87661a0c241d1054b6c Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Sun, 21 Mar 2021 20:37:58 +0100 Subject: [PATCH] Add .sh command --- ubot.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ubot.py b/ubot.py index 406fd4f..1f694ce 100644 --- a/ubot.py +++ b/ubot.py @@ -87,11 +87,20 @@ async def edit(event): rpl = "Purge complete! Purged " + str(count) + " messages." await client.send_message('me', rpl) + if '.sh' in msg: + cmd = msg.split(' ', 1)[1] + host = os.uname()[1] + user = os.environ['LOGNAME'] + out = os.popen(cmd).read() + + rpl = '`' + user + '@' + host + ' $ ' + cmd + '`\n' + rpl += '`' + out + '`\n' + await event.edit(rpl) + if '.sauce' in msg: rpl = 'Sauce: [ghnou/ubot](https://git.ghnou.su/ghnou/ubot)' await event.edit(rpl) - if '.help' in msg: rpl = '**Available userbot commands:**\n' rpl += '.alive - Check whether the bot is running.\n' @@ -99,6 +108,7 @@ async def edit(event): rpl += '.stats - Get user account stats.\n' rpl += '.fire - IMA FIRING MAH LAZER\n' rpl += '.purgeme - Purge messages.\n' + rpl += '.sh - Execute a shell command.\n' rpl += '.sauce - Get the bot\'s source code.\n' rpl += '.help - Show this help message.\n' await event.edit(rpl)