sycgram/plugins/info.py
2022-04-08 09:39:46 +08:00

32 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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" \
f"Chat Title: `{msg.chat.title}`\n" \
f"Chat Type: `{msg.chat.type}`\n" \
f"Chat ID: `{msg.chat.id}`" \
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" \
f"User Nick: `{get_fullname(user)}`\n"\
f"User Name: `@{user.username}`\n" \
f"User ID: `{user.id}`\n\n" \
f"{text}"
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}"
await msg.edit_text(text)