Add .sh command

This commit is contained in:
Michael De Roover 2021-03-21 20:37:58 +01:00
parent 5ffc2114dd
commit 72302a5201
Signed by: vim
GPG Key ID: 075496E232CE04CB

12
ubot.py
View File

@ -87,11 +87,20 @@ async def edit(event):
rpl = "Purge complete! Purged " + str(count) + " messages." rpl = "Purge complete! Purged " + str(count) + " messages."
await client.send_message('me', rpl) 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: if '.sauce' in msg:
rpl = 'Sauce: [ghnou/ubot](https://git.ghnou.su/ghnou/ubot)' rpl = 'Sauce: [ghnou/ubot](https://git.ghnou.su/ghnou/ubot)'
await event.edit(rpl) await event.edit(rpl)
if '.help' in msg: if '.help' in msg:
rpl = '**Available userbot commands:**\n' rpl = '**Available userbot commands:**\n'
rpl += '.alive - Check whether the bot is running.\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 += '.stats - Get user account stats.\n'
rpl += '.fire - IMA FIRING MAH LAZER\n' rpl += '.fire - IMA FIRING MAH LAZER\n'
rpl += '.purgeme - Purge messages.\n' rpl += '.purgeme - Purge messages.\n'
rpl += '.sh - Execute a shell command.\n'
rpl += '.sauce - Get the bot\'s source code.\n' rpl += '.sauce - Get the bot\'s source code.\n'
rpl += '.help - Show this help message.\n' rpl += '.help - Show this help message.\n'
await event.edit(rpl) await event.edit(rpl)