Files
Ultroid-fork/plugins/extra.py
Danish 68839e9dd0 Ultroid v0.0.7 2021/05/22
Co-authored-by: New-dev0 <New-dev0@notavailable.live>
Co-authored-by: Danish <danish@ultroid.tech>
Co-authored-by: Amit Sharma <48654350+buddhhu@users.noreply.github.com>
Co-authored-by: Programming Error <error@notavailable.live>
Co-authored-by: Aakash <BLUE-DEVIL1134@users.noreply.github.com>
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: divkix <divkix@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
2021-05-22 22:21:41 +05:30

119 lines
2.7 KiB
Python

# Ultroid - UserBot
# Copyright (C) 2020 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 telethon.events import NewMessage as NewMsg
from . import *
_new_msgs = {}
@ultroid_bot.on(
NewMsg(
outgoing=True,
),
)
async def newmsg(event):
if event.message.message == f"{HNDLR}reply":
return
_new_msgs[event.chat_id] = event.message
@ultroid_cmd(
pattern="del$",
)
async def delete_it(delme):
msg_src = await delme.get_reply_message()
if delme.reply_to_msg_id:
try:
await msg_src.delete()
await delme.delete()
except BaseException:
await eod(
delme,
f"Couldn't delete the message.\n\n**ERROR:**\n`{str(e)}`",
time=5,
)
@ultroid_cmd(
pattern="copy$",
)
async def copy(e):
reply = await e.get_reply_message()
if reply:
if reply.text and not reply.media:
await eor(e, reply.text)
else:
await reply.reply(reply)
if e.sender_id == ultroid_bot.uid:
await e.delete()
else:
await eod(e, "`Reply To any message`")
@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 ultroid_bot.iter_messages(chat, ultroid_bot.uid):
if i == 2:
await message.edit(string)
await edit.delete()
break
i = i + 1
@ultroid_cmd(
pattern="reply$",
)
async def _(e):
if e.reply_to_msg_id and e.chat_id in _new_msgs:
msg = _new_msgs[e.chat_id]
chat = await e.get_input_chat()
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.delete()
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})