Add .re command

This commit is contained in:
Michael De Roover 2021-04-21 20:25:58 +02:00
parent a4d803f305
commit 0d5f7069a0
Signed by: vim
GPG Key ID: 075496E232CE04CB

11
ubot.py
View File

@ -134,6 +134,16 @@ async def edit(event):
for i in range(0,cnt):
await event.respond(msg)
if msg.startswith('.re'):
import os
regex = str(msg.split(' ', 1)[1])
inmsg = await event.get_reply_message()
outmsg = os.popen('echo "' + str(inmsg.text) + '" | sed "' + regex + '"').read()
rpl = f'`{regex}`\n'
rpl += f'{outmsg}\n'
await event.edit(rpl)
if msg.startswith('.sauce'):
rpl = 'Sauce: [ghnou/ubot](https://git.nixmagic.com/ghnou/ubot)'
await event.edit(rpl)
@ -148,6 +158,7 @@ async def edit(event):
rpl += '.sh - Execute a shell command.\n'
rpl += '.sys - Show system information.\n'
rpl += '.spam - Spam messages.. yea.\n'
rpl += '.re - s/foo/bar/\n'
rpl += '.sauce - Get the bot\'s source code.\n'
rpl += '.help - Show this help message.\n'
await event.edit(rpl)