diff --git a/stdplugins/ninja.py b/stdplugins/ninja.py index 68db5a7..33d9c05 100644 --- a/stdplugins/ninja.py +++ b/stdplugins/ninja.py @@ -9,6 +9,7 @@ import telethon.utils from uniborg import util + async def get_target_message(event): if event.is_reply and (await event.reply_message).from_id == borg.uid: return event.reply_message @@ -29,12 +30,21 @@ async def await_read(chat, message): await fut -@borg.on(util.admin_cmd(r"^\.del(ete)?$")) +@borg.on(util.admin_cmd(r"^\.(del)(?:ete)?$")) +@borg.on(util.admin_cmd(r"^\.(edit)(.*)$")) async def delete(event): await event.delete() + command = event.pattern_match.group(1) + if command == 'edit': + text = event.pattern_match.group(2).strip() + if not text: + return target = await get_target_message(event) if target: chat = await event.input_chat await await_read(chat, target) await asyncio.sleep(.5) - await borg.delete_messages(chat, target) + if command == 'edit': + await borg.edit_message(chat, target, text) + else: + await borg.delete_messages(chat, target)