diff --git a/modules/whois/__init__.py b/modules/whois/__init__.py index 500103e3..53164906 100644 --- a/modules/whois/__init__.py +++ b/modules/whois/__init__.py @@ -1,12 +1,11 @@ import ipaddress -from core.utils import get_url -import ujson as json -import socket from core.builtins.message import MessageSession from core.component import on_command from .ip import check_ip, format_ip +# from .domain import check_domain, format_domain -w = on_command('whois') +w = on_command('whois', desc='查询 IP Whois 信息', + developers=['Dianliang233']) @w.handle('') @@ -16,6 +15,9 @@ async def _(msg: MessageSession): if query_type == 'ip': res = await check_ip(query) await msg.finish(await format_ip(res)) + # elif query_type == 'domain': + # res = await check_domain(query) + # await msg.finish(await format_domain(res)) def ip_or_domain(string: str): diff --git a/modules/whois/domain.py b/modules/whois/domain.py new file mode 100644 index 00000000..de1e934e --- /dev/null +++ b/modules/whois/domain.py @@ -0,0 +1,21 @@ +from typing import Any, Union +import json +import socket +import ipaddress +from core.utils import get_url +import os +import whois + +iso = json.load(open(os.path.dirname(os.path.abspath( + __file__)) + './iso.json', 'r', encoding='utf-8')) + + +async def check_domain(domain: str): + return whois.whois(domain) + + +async def format_domain(info: whois.WhoisEntry): + res = '' + for key, value in info.items(): + res += f'\n{key}:{value}' + return res diff --git a/modules/whois/ip.py b/modules/whois/ip.py index beff8b12..7d0b3f3f 100644 --- a/modules/whois/ip.py +++ b/modules/whois/ip.py @@ -1,10 +1,9 @@ -from typing import Any, Union +from typing import Any import json import socket import ipaddress from core.utils import get_url import os -import decimal iso = json.load(open(os.path.dirname(os.path.abspath( __file__)) + './iso.json', 'r', encoding='utf-8'))