whois 查询域名whois信息

This commit is contained in:
xtaodada 2022-06-07 22:05:08 +08:00
parent 1f48ef9918
commit ddc3e2d081
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 33 additions and 0 deletions

View File

@ -119,6 +119,16 @@
"supported": true,
"des-short": "每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地",
"des": "每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地。\n指令-news"
},
{
"name": "whois",
"version": "1.141",
"section": "daily",
"maintainer": "xtaodada",
"size": "1.0 kb",
"supported": true,
"des-short": "查询域名whois信息",
"des": "查看域名是否已被注册、注册日期、过期日期、域名状态、DNS解析服务器等。"
}
]
}

23
whois/main.py Normal file
View File

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