From 0d5f7069a0233260c6e3e6974f022fe9a3a7ebf5 Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Wed, 21 Apr 2021 20:25:58 +0200 Subject: [PATCH] Add .re command --- ubot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ubot.py b/ubot.py index 78cd1f2..118396f 100755 --- a/ubot.py +++ b/ubot.py @@ -133,6 +133,16 @@ async def edit(event): msg = msg.split(' ', 2)[2] 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)' @@ -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)