sycgram/plugins/info.py

32 lines
1.2 KiB
Python
Raw Permalink Normal View History

2022-04-06 14:39:27 +00:00
from core import command
from pyrogram import Client
from pyrogram.types import Message
from tools.helpers import get_fullname
@Client.on_message(command("id"))
async def get_id(_: Client, msg: Message):
"""直接使用或者回复目标消息从而获取各种IDs"""
text = f"Message ID: `{msg.message_id}`\n\n" \
2022-04-09 08:53:29 +00:00
f"Chat Title: `{msg.chat.title or msg.chat.first_name}`\n" \
2022-04-06 14:39:27 +00:00
f"Chat Type: `{msg.chat.type}`\n" \
2022-04-09 08:53:29 +00:00
f"Chat ID: `{msg.chat.id}`"
2022-04-06 14:39:27 +00:00
2022-04-08 01:39:46 +00:00
replied_msg = msg.reply_to_message
if replied_msg and replied_msg.from_user:
user = replied_msg.from_user
text = f"Repiled Message ID: `{replied_msg.message_id}`\n\n" \
2022-04-06 14:39:27 +00:00
f"User Nick: `{get_fullname(user)}`\n"\
f"User Name: `@{user.username}`\n" \
f"User ID: `{user.id}`\n\n" \
f"{text}"
2022-04-08 01:39:46 +00:00
elif replied_msg and replied_msg.sender_chat:
sender_chat = replied_msg.sender_chat
text = f"Repiled Message ID: `{replied_msg.message_id}`\n\n" \
f"Chat Title: `{sender_chat.title}`\n" \
f"Chat Type: `{sender_chat.type}`\n" \
f"Chat ID: `{sender_chat.id}`\n\n" \
f"{text}"
2022-04-06 14:39:27 +00:00
await msg.edit_text(text)