forked from TeamUltroid/Ultroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextra.py
98 lines (85 loc) · 2.42 KB
/
extra.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 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
try:
await msg_src.delete()
await delme.delete()
except Exception as e:
await delme.eor(f"Couldn't delete the message.\n\n**ERROR:**\n`{e}`", time=5)
@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()