Add Whois
This commit is contained in:
parent
4a521799cc
commit
ee2ff34a77
3 changed files with 28 additions and 6 deletions
|
@ -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('<ip_or_domain>')
|
||||
|
@ -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):
|
||||
|
|
21
modules/whois/domain.py
Normal file
21
modules/whois/domain.py
Normal file
|
@ -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
|
|
@ -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'))
|
||||
|
|
Reference in a new issue