PagerMaid_Plugins_Pyro/whois/main.py

28 lines
1007 B
Python
Raw Normal View History

2022-06-07 14:05:08 +00:00
from pyrogram import Client
2024-09-28 14:35:08 +00:00
from pagermaid.dependence import client
from pagermaid.enums import Message
2022-06-07 14:05:08 +00:00
from pagermaid.listener import listener
2023-07-01 12:18:58 +00:00
@listener(command="whois", description="查看域名是否已被注册、注册日期、过期日期、域名状态、DNS解析服务器等。")
2022-06-07 14:05:08 +00:00
async def whois(_: Client, context: Message):
try:
message = context.arguments
except ValueError:
await context.edit("出错了呜呜呜 ~ 无效的参数。")
return
2023-07-01 12:18:58 +00:00
req = await client.get(f"https://namebeta.com/api/search/check?query={message}")
2022-06-07 14:05:08 +00:00
if req.status_code == 200:
try:
2023-07-01 12:18:58 +00:00
data = (
req.json()["whois"]["whois"].split("For more information")[0].rstrip()
)
2022-06-07 14:05:08 +00:00
except:
await context.edit("出错了呜呜呜 ~ 可能是域名不正确。")
return
await context.edit(f"<code>{data}</code>")
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")