Skip to content

Commit f1d8fd5

Browse files
committed
refactor(plugins): 重构插件并适配新版 API
- 更新 ipinfo、ping、whois、icp 等插件以使用新的 API 接口 - 优化插件功能,调整输出格式以适应新的数据结构 - 移除 ping 插件中的香港节点查询功能 - 更新 README 文件,添加项目进入长周期维护状态的说明
1 parent 25107be commit f1d8fd5

File tree

5 files changed

+43
-57
lines changed

5 files changed

+43
-57
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
---
88

9+
> [!CAUTION]
10+
> ⚠️ 本项目功能开发已完成,目前已进入长周期(LTS)状态。若有新问题请提交issue。
11+
12+
---
13+
914
## 📜 许可 | License
1015

1116
> 本项目采用 **AGPLv3** 协议授权。

plugins/ipinfo.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ async def ipinfo_handler(event):
2222
else:
2323
contents = "\n=====IP信息=====" + "\n" + \
2424
"IP: " + info["ip"] + "\n" + \
25-
"| 开始 IP: " + info["start_ip"] + "\n" + \
26-
"| 结束 IP: " + info["end_ip"] + "\n" + \
27-
"| 归属地: " + info["country"] + " " + info["region"] + "\n" + \
25+
"| 开始 IP: " + info["beginip"] + "\n" + \
26+
"| 结束 IP: " + info["endip"] + "\n" + \
27+
"| 归属地: " + info["region"] + "\n" + \
2828
"| 纬度: " + str(info["latitude"]) + "\n" + \
2929
"| 经度: " + str(info["longitude"]) + "\n" + \
30-
"| LLC: " + info["company"] + "\n" + \
31-
"| ASN: " + 'AS' + str(info["asn"]) + "\n" + \
30+
"| ISP: " + str(info["isp"]) + "\n" + \
31+
"| LLC: " + info["llc"] + "\n" + \
32+
"| ASN: " + str(info["asn"]) + "\n" + \
3233
"=============="
3334
await send_group_message(event.group_openid, msg_type=0, content=contents, msg_id=event.msg_id)
3435
return

plugins/ping.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ async def ping_handler(event):
88
"/ping [IP] [查询节点] - 查询IP地址延迟及归属地" + "\n" + \
99
"可选的查询节点有:" + "\n" + \
1010
"- cn | 中国湖北十堰/电信" + "\n" + \
11-
"- hk | 中国香港/腾讯云" + "\n" + \
1211
"==========================" + "\n" + \
1312
"使用示例: /ping 域名/IP cn" + "\n" + \
1413
"=========================="
@@ -18,23 +17,11 @@ async def ping_handler(event):
1817
if msg.startswith(("/ping ","ping ")) and msg.split(" ")[1] is not None:
1918
info = checkpoint = None
2019
try:
21-
node = msg.split(" ")[2]
22-
except IndexError:
23-
node = 'cn'
24-
if node == "cn":
25-
try:
26-
info = await get_ping_info(msg.split(" ")[1], "cn")
27-
checkpoint = "中国湖北十堰/电信"
28-
except TypeError as e:
29-
await send_group_message(event.group_openid, msg_type=0, content='未查询到该IP地址', msg_id=event.msg_id)
30-
return
31-
elif node == "hk":
32-
try:
33-
info = await get_ping_info(msg.split(" ")[1], "hk")
34-
checkpoint = "中国香港/腾讯云"
35-
except TypeError as e:
36-
await send_group_message(event.group_openid, msg_type=0, content='未查询到该IP地址', msg_id=event.msg_id)
37-
return
20+
info = await get_ping_info(msg.split(" ")[1])
21+
checkpoint = "中国湖北十堰/电信"
22+
except TypeError as e:
23+
await send_group_message(event.group_openid, msg_type=0, content='未查询到该IP地址', msg_id=event.msg_id)
24+
return
3825
if info:
3926
content = "\n=====Ping信息=====" + "\n" + \
4027
"主机名: " + info["host"].replace('.',',') + "\n" + \

plugins/whois.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ async def whois_handler(event):
2121
if info in [{"error": "网络请求失败,请稍后再试。"},{"error": "SSL 证书验证失败,请稍后再试或联系管理员。"}]:
2222
await send_group_message(event.group_openid, msg_type=0, content=f"请求失败,请稍后再试。\n详细信息:{info}", msg_id=event.msg_id)
2323
return
24-
domain_status_translated = translate_domain_status(info["domain_status"])
24+
info = info["whois"]
25+
domain = info["domain"]
26+
domain_status_translated = translate_domain_status(domain["status"])
2527
domain_status_str = "\n".join([status for status in domain_status_translated])
26-
dns_str = ", ".join([dns.replace(".", ",") for dns in info["dns"]])
28+
dns_str = ", ".join([dns.replace(".", ",") for dns in domain["name_servers"]])
2729
content = "\n=====Whois信息=====" + "\n" + \
28-
"| 注册地址: " + info["reg_url"].replace("http://", "").replace("https://", "").replace(".",
29-
",") + "\n" + \
30-
"| 注册邮箱: " + info["email"].replace(".", ",") + "\n" + \
31-
"| 注册电话: " + info["phone"] + "\n" + \
32-
"| 注册公司: " + info["LLC"].replace(".", ",") + "\n" + \
33-
"| 注册日期: " + info["reg_date"].replace("T", " ").replace("Z", "") + "\n" + \
34-
"| 更新日期: " + info["updated_date"].replace("T", " ").replace("Z", "") + "\n" + \
35-
"| 过期日期: " + info["exp_date"].replace("T", " ").replace("Z", "") + "\n" + \
30+
"| 注册邮箱: " + info["registrar"]["email"].replace(".", ",") + "\n" + \
31+
"| 注册电话: " + info["registrar"]["phone"] + "\n" + \
32+
"| 注册公司: " + info["registrar"]["name"].replace(".", ",") + "\n" + \
33+
"| 注册日期: " + domain["created_date_in_time"].replace("T", " ").replace("Z", "") + "\n" + \
34+
"| 更新日期: " + domain["updated_date_in_time"].replace("T", " ").replace("Z", "") + "\n" + \
35+
"| 过期日期: " + domain["expiration_date_in_time"].replace("T", " ").replace("Z", "") + "\n" + \
3636
"=====域名状态=====" + "\n" + \
3737
domain_status_str + "\n" + \
3838
"======DNS======" + "\n" + \

utils/get_uapis.py

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
uapi = "api.uapis.cn"
88
uapi_old = "uapis.cn"
9-
axtn = "api.axtn.net"
109

1110

1211
async def get_ip_info(ip):
13-
url = f"https://{uapi}/ipinfo?ip={ip}"
12+
url = f"https://{uapi}/api/v1/network/ipinfo?ip={ip}"
1413
async with aiohttp.ClientSession() as session:
1514
try:
1615
async with session.get(url) as response:
@@ -21,13 +20,8 @@ async def get_ip_info(ip):
2120
return None
2221

2322

24-
async def get_ping_info(ip, node):
25-
if node == "cn":
26-
url = f"https://{uapi}/ping?host={ip}"
27-
elif node == "hk":
28-
url = f"https://{axtn}/ping?host={ip}"
29-
else:
30-
return None
23+
async def get_ping_info(ip):
24+
url = f"https://{uapi}/api/v1/network/ping?host={ip}"
3125

3226
async with aiohttp.ClientSession() as session:
3327
try:
@@ -40,7 +34,7 @@ async def get_ping_info(ip, node):
4034

4135

4236
async def get_whois_info(domain):
43-
url = f"https://{uapi}/whois?domain={domain}"
37+
url = f"https://{uapi}/api/v1/network/whois?domain={domain}&format=json"
4438
async with aiohttp.ClientSession() as session:
4539
try:
4640
async with session.get(url) as response:
@@ -52,11 +46,11 @@ async def get_whois_info(domain):
5246
except ClientError as e:
5347
logger.error(f"请求错误:{e}")
5448
info = await response.json()['error'] if "error" in response.json() else "未返回正确值"
55-
return {"error": "info"}
49+
return {"error": info}
5650

5751

5852
async def get_icp_info(domain):
59-
url = f"https://{uapi_old}/api/icp?domain={domain}"
53+
url = f"https://{uapi}/api/v1/network/icp?domain={domain}"
6054
async with aiohttp.ClientSession() as session:
6155
try:
6256
async with session.get(url) as response:
@@ -68,7 +62,7 @@ async def get_icp_info(domain):
6862

6963

7064
async def get_hot_list(hot_type):
71-
url = f"https://{uapi_old}/api/hotlist?type={hot_type}"
65+
url = f"https://{uapi}/api/v1/misc/hotboard?type={hot_type}"
7266
async with aiohttp.ClientSession() as session:
7367
try:
7468
async with session.get(url) as response:
@@ -92,35 +86,34 @@ async def get_answer_book():
9286

9387

9488
async def get_touch_url(qqid):
95-
url = f"https://{uapi_old}/api/mt?qq={str(qqid)}"
89+
url = f"https://{uapi}/api/v1/image/motou?qq={str(qqid)}"
9690
return url
9791

9892

9993
async def get_steamid_info(steamid):
10094
split_str = steamid.split(" ")
10195
steamid = split_str[1] # 获取分割后的第二个子字符串
102-
url = f"https://{uapi_old}/api/steamuserinfo?input={steamid}"
96+
url = f"https://{uapi}/api/v1/game/steam/summary?steamid={steamid}"
10397
async with aiohttp.ClientSession() as session:
10498
try:
10599
async with session.get(url) as response:
106100
if response.status == 200:
107101
data = await response.json()
108102
if data.get("code") == 200:
109-
communitystate = data.get("communitystate") if data.get("communitystate") != 'N/A' else "未知"
110-
steamID64 = data.get("steamID64") if data.get("steamID64") != 'N/A' else "未知"
111-
steamUsername = data.get("username") if data.get("username") != 'N/A' else "未知"
103+
communitystate = data.get("communityvisibilitystate") if data.get("communityvisibilitystate") != 'N/A' else "未知"
104+
steamID64 = data.get("steamid") if data.get("steamid") != 'N/A' else "未知"
105+
steamUsername = data.get("personaname") if data.get("personaname") != 'N/A' else "未知"
112106
realname = data.get("realname") if data.get("realname") != 'N/A' else "未知"
113-
accountcreationdate = data.get("accountcreationdate") if data.get("accountcreationdate") != 'N/A' else "未知"
114-
lastlogoff = data.get("lastlogoff") if data.get("lastlogoff") != '1970-01-01 08:00:00' and data.get("lastlogoff") != 'N/A' else "未知"
115-
location = data.get("location") if data.get("location") != 'N/A' else "未知"
107+
accountcreationdate = data.get("timecreated_str") if data.get("timecreated_str") != 'N/A' else "未知"
108+
# lastlogoff = data.get("lastlogoff") if data.get("lastlogoff") != '1970-01-01 08:00:00' and data.get("lastlogoff") != 'N/A' else "未知"
109+
location = data.get("loccountrycode") if data.get("loccountrycode") != 'N/A' else "未知"
116110
return f"""
117111
====Steam账户信息====
118112
| 社区资料状态:{communitystate}
119113
| 用户名:{steamUsername}
120114
| 真实姓名:{realname}
121115
| Steam ID:{steamID64}
122116
| 账户创建日期:{accountcreationdate}
123-
| 最后下线日期:{lastlogoff}
124117
| 地理位置:{location}
125118
=====================
126119
"""
@@ -161,12 +154,12 @@ def translate_domain_status(status_list):
161154

162155

163156
def format_hot_search(data):
164-
items = data.get("data", [])[:10]
157+
items = data.get("list", [])[:10]
165158
formatted = []
166159
for item in items:
167160
index = item.get("index", "")
168161
title = item.get("title", "")
169-
hot = item.get("hot", None)
162+
hot = item.get("hot_value", None)
170163
if hot:
171164
formatted.append(f"{index} - {title} | {hot}")
172165
else:

0 commit comments

Comments
 (0)