Skip to content

Commit 1eee940

Browse files
Update mention.py
1 parent edccaf1 commit 1eee940

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

fun/mention.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def custom_mention(user, custom_text):
3030

3131

3232
@Client.on_message(filters.command("mention", prefix) & filters.me)
33-
async def example_edit(_: Client, message: Message):
33+
async def example_edit(client: Client, message: Message):
34+
chat_id = message.chat.id
3435
if message.reply_to_message:
3536
user = message.reply_to_message.from_user
3637
custom_text = (
@@ -39,13 +40,33 @@ async def example_edit(_: Client, message: Message):
3940
if custom_text:
4041
await message.edit(custom_mention(user, custom_text))
4142
else:
42-
await message.edit(user.mention)
43+
await message.delete()
44+
await client.send_message(chat_id, user.mention)
4345
else:
44-
await message.edit("Please reply to a message to mention the user.")
45-
await message.delete()
46+
if len(message.text.split()) > 1:
47+
user_id = message.text.split()[1]
48+
if user_id.isdigit():
49+
text = (
50+
message.text.split(maxsplit=2)[2]
51+
if len(message.text.split()) > 2
52+
else None
53+
)
54+
if text:
55+
men = Link(f"tg://user?id={user_id}", text, client.parse_mode)
56+
else:
57+
men = (await client.get_users(user_id)).mention
58+
await message.edit(men)
59+
else:
60+
await message.edit("Invalid user_id")
61+
await message.delete()
62+
else:
63+
await message.edit("Reply to a message or provide a user_id")
64+
await message.delete()
4665

4766

4867
modules_help["mention"] = {
68+
"mention": "Mention the user you replied to.",
4969
"mention [custom_text]": "Mention the user you replied to with custom text.",
50-
"mention": "Mention the user you replied to with their username.",
70+
"mention [user_id] [custom_text]": "Mention a user by their user_id with custom text.",
71+
"mention [user_id]": "Mention a user by their user_id.",
5172
}

0 commit comments

Comments
 (0)