Files
Ultroid-fork/plugins/extra.py
Devesh Pal 4d30dd7dd7 [Update] Ultroid v0.6
Co-Authored-By: Amit Sharma <48654350+buddhhu@users.noreply.github.com>
Co-Authored-By: MMETMA <79155572+MMETMA@users.noreply.github.com>
Co-Authored-By: Aditya <me@xditya.me>
Co-Authored-By: marat2509 <93652988+marat2509@users.noreply.github.com>
Co-Authored-By: smartman_ru <14003491+smartmanru@users.noreply.github.com>
Co-Authored-By: Flasho <75789819+flashokillerify@users.noreply.github.com>
Co-Authored-By: ÁÑÑÍHÌLÅTØR SPÄRK <75305464+annihilatorrrr@users.noreply.github.com>
2022-06-06 23:18:16 +05:30

96 lines
2.3 KiB
Python

# Ultroid - UserBot
# Copyright (C) 2021-2022 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
• `{i}del <reply to message>`
Delete the replied message.
• `{i}edit <new message>`
Edit your last message or replied msg.
• `{i}copy <reply to message>`
Copy replied message / media.
• `{i}reply`
Reply the last sent msg to replied user.
"""
import asyncio
from . import get_string, ultroid_cmd
@ultroid_cmd(
pattern="del$",
manager=True,
)
async def delete_it(delme):
msg_src = await delme.get_reply_message()
if not msg_src:
return
await msg_src.try_delete()
await delme.try_delete()
@ultroid_cmd(
pattern="copy$",
)
async def copy(e):
reply = await e.get_reply_message()
if reply:
await reply.reply(reply)
return await e.try_delete()
await e.eor(get_string("ex_1"), time=5)
@ultroid_cmd(
pattern="edit",
)
async def editer(edit):
message = edit.text
chat = await edit.get_input_chat()
string = str(message[6:])
reply = await edit.get_reply_message()
if reply and reply.text:
try:
await reply.edit(string)
await edit.delete()
except BaseException:
pass
else:
i = 1
async for message in edit.client.iter_messages(chat, from_user="me", limit=2):
if i == 2:
await message.edit(string)
await edit.delete()
break
i += 1
@ultroid_cmd(
pattern="reply$",
)
async def _(e):
if e.reply_to_msg_id:
chat = e.chat_id
try:
msg = (await e.client.get_messages(e.chat_id, limit=1, max_id=e.id))[0]
except IndexError:
return await e.eor(
"`You have previously sent no message to reply again...`", time=5
)
except BaseException as er:
return await e.eor(f"**ERROR:** `{er}`")
await asyncio.wait(
[
e.client.delete_messages(chat, [e.id, msg.id]),
e.client.send_message(chat, msg, reply_to=e.reply_to_msg_id),
]
)
else:
await e.try_delete()