Spaces:
Running
Running
Update DragMusic/plugins/management/id.py
Browse files
DragMusic/plugins/management/id.py
CHANGED
@@ -2,25 +2,26 @@ from pyrogram import filters
|
|
2 |
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
|
3 |
from DragMusic import app
|
4 |
|
|
|
5 |
@app.on_message(filters.command("id") & filters.group)
|
6 |
async def id_handler(client, message: Message):
|
7 |
group_id = message.chat.id
|
8 |
user = None
|
9 |
show_group_id = False
|
10 |
|
11 |
-
# Case 1: If
|
12 |
if message.reply_to_message and message.reply_to_message.from_user:
|
13 |
user = message.reply_to_message.from_user
|
14 |
|
15 |
-
# Case 2: If mentioned
|
16 |
elif len(message.command) > 1:
|
17 |
username = message.command[1].replace("@", "")
|
18 |
try:
|
19 |
user = await client.get_users(username)
|
20 |
except Exception:
|
21 |
-
return await message.reply_text("
|
22 |
|
23 |
-
# Case 3:
|
24 |
else:
|
25 |
user = message.from_user
|
26 |
show_group_id = True
|
@@ -28,21 +29,25 @@ async def id_handler(client, message: Message):
|
|
28 |
user_id = user.id
|
29 |
name = user.first_name or "Unknown"
|
30 |
|
31 |
-
# Prepare text and buttons
|
32 |
if show_group_id:
|
33 |
text = (
|
34 |
-
f"User:
|
35 |
-
f"User ID:
|
36 |
f"Group ID: {group_id}"
|
37 |
)
|
38 |
buttons = [
|
39 |
[
|
40 |
-
InlineKeyboardButton("Copy User ID",
|
41 |
-
InlineKeyboardButton("Copy Group ID",
|
42 |
]
|
43 |
]
|
44 |
else:
|
45 |
-
text = f"User: {name}
|
46 |
-
buttons = [
|
|
|
|
|
47 |
|
48 |
-
await message.
|
|
|
|
|
|
|
|
2 |
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
|
3 |
from DragMusic import app
|
4 |
|
5 |
+
|
6 |
@app.on_message(filters.command("id") & filters.group)
|
7 |
async def id_handler(client, message: Message):
|
8 |
group_id = message.chat.id
|
9 |
user = None
|
10 |
show_group_id = False
|
11 |
|
12 |
+
# Case 1: If replying to a message with a user
|
13 |
if message.reply_to_message and message.reply_to_message.from_user:
|
14 |
user = message.reply_to_message.from_user
|
15 |
|
16 |
+
# Case 2: If user is mentioned with @username
|
17 |
elif len(message.command) > 1:
|
18 |
username = message.command[1].replace("@", "")
|
19 |
try:
|
20 |
user = await client.get_users(username)
|
21 |
except Exception:
|
22 |
+
return await message.reply_text("Invalid username or user not found.")
|
23 |
|
24 |
+
# Case 3: If no reply or mention, show command sender + group ID
|
25 |
else:
|
26 |
user = message.from_user
|
27 |
show_group_id = True
|
|
|
29 |
user_id = user.id
|
30 |
name = user.first_name or "Unknown"
|
31 |
|
|
|
32 |
if show_group_id:
|
33 |
text = (
|
34 |
+
f"User: {name}\n"
|
35 |
+
f"User ID: {user_id}\n"
|
36 |
f"Group ID: {group_id}"
|
37 |
)
|
38 |
buttons = [
|
39 |
[
|
40 |
+
InlineKeyboardButton("Copy User ID", copy_text=str(user_id)),
|
41 |
+
InlineKeyboardButton("Copy Group ID", copy_text=str(group_id)),
|
42 |
]
|
43 |
]
|
44 |
else:
|
45 |
+
text = f"User: {name}\nUser ID: {user_id}"
|
46 |
+
buttons = [
|
47 |
+
[InlineKeyboardButton("Copy User ID", copy_text=str(user_id))]
|
48 |
+
]
|
49 |
|
50 |
+
await message.reply(
|
51 |
+
text,
|
52 |
+
reply_markup=InlineKeyboardMarkup(buttons)
|
53 |
+
)
|