添加whois插件 (#5)

This commit is contained in:
KorenKrita 2020-08-12 14:57:28 +08:00 committed by GitHub
parent 5c0e3e5438
commit a7f2790ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -159,6 +159,16 @@
"supported": false,
"des-short": "回复你要临时禁言的人的消息来实现XX秒的禁言。",
"des": "这个人很懒,什么都没有留下。"
},
{
"name": "whois",
"version": "1.0",
"section": "daily",
"maintainer": "KorenKrita",
"size": "1.1 kb",
"supported": true,
"des-short": "查询域名whois信息",
"des": "查看域名是否已被注册、注册日期、过期日期、域名状态、DNS解析服务器等。"
}
]
}

23
whois.py Normal file
View File

@ -0,0 +1,23 @@
import json
import os,sys,codecs
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
from requests import get
from pagermaid.listener import listener
from pagermaid.utils import obtain_message
@listener(outgoing=True, command="whois",
description="查看域名是否已被注册、注册日期、过期日期、域名状态、DNS解析服务器等。")
async def whois(context):
await context.edit("获取中 . . .")
try:
message = await obtain_message(context)
except ValueError:
await context.edit("出错了呜呜呜 ~ 无效的参数。")
return
req = get("https://tenapi.cn/whois/?url=" + message)
if req.status_code == 200:
data = json.loads(req.text)
res = 'url ' + data['data']['url'] + '\n注册商: ' + str(data['data']['注册商']) + '\n联系人: ' + str(data['data']['联系人']) + '\n联系邮箱: ' + str(data['data']['联系邮箱']) + '\n注册时间: ' + str(data['data']['注册时间']) + '\n过期时间: ' + str(data['data']['过期时间']) + '\nDNS ' + str(data['data']['DNS'])
await context.edit(res)
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")