From ddc3e2d081719197ff6f91960704f9685c607752 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 7 Jun 2022 22:05:08 +0800 Subject: [PATCH] =?UTF-8?q?whois=20=E6=9F=A5=E8=AF=A2=E5=9F=9F=E5=90=8Dwho?= =?UTF-8?q?is=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 10 ++++++++++ whois/main.py | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 whois/main.py diff --git a/list.json b/list.json index 0277376..308a08c 100644 --- a/list.json +++ b/list.json @@ -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解析服务器等。" } ] } diff --git a/whois/main.py b/whois/main.py new file mode 100644 index 0000000..4aaadf4 --- /dev/null +++ b/whois/main.py @@ -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"{data}") + else: + await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")