@@ -30,7 +30,8 @@ def custom_mention(user, custom_text):
30
30
31
31
32
32
@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
34
35
if message .reply_to_message :
35
36
user = message .reply_to_message .from_user
36
37
custom_text = (
@@ -39,13 +40,33 @@ async def example_edit(_: Client, message: Message):
39
40
if custom_text :
40
41
await message .edit (custom_mention (user , custom_text ))
41
42
else :
42
- await message .edit (user .mention )
43
+ await message .delete ()
44
+ await client .send_message (chat_id , user .mention )
43
45
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 ()
46
65
47
66
48
67
modules_help ["mention" ] = {
68
+ "mention" : "Mention the user you replied to." ,
49
69
"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." ,
51
72
}
0 commit comments