koishi-plugin-jscn-aaaquery 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/index.js +87 -20
  2. package/package.json +1 -1
  3. package/readme.md +27 -0
package/lib/index.js CHANGED
@@ -164,7 +164,11 @@ function apply(ctx, config) {
164
164
  }
165
165
  __name(formatAccount, "formatAccount");
166
166
  function isAccountResponseComplete(data) {
167
- return !!(data.accessUserName && data.onlineStatus && data.isPass && data.userIp && data.mac && data.maxUpSpeed !== void 0 && data.maxDownSpeed !== void 0 && data.accessDomain && data.startTime && data.startTimeSum !== void 0 && data.nickName);
167
+ const hasBasicFields = !!(data.accessUserName && data.onlineStatus && data.isPass);
168
+ if (data.onlineStatus === "离线" || data.isPass === "原因未知") {
169
+ return hasBasicFields;
170
+ }
171
+ return hasBasicFields && !!(data.userIp && data.mac && data.maxUpSpeed !== void 0 && data.maxDownSpeed !== void 0 && data.accessDomain && data.startTime && data.startTimeSum !== void 0 && data.nickName);
168
172
  }
169
173
  __name(isAccountResponseComplete, "isAccountResponseComplete");
170
174
  async function getToken() {
@@ -226,6 +230,29 @@ function apply(ctx, config) {
226
230
  });
227
231
  console.log("查询响应:", JSON.stringify(response, null, 2));
228
232
  if (response.status === 200 && response.data) {
233
+ if (response.data.isPass === "上线失败") {
234
+ console.log("账号上线失败,将使用失败信息");
235
+ if (!response.data.startTimeSum) response.data.startTimeSum = 0;
236
+ if (!response.data.maxUpSpeed) response.data.maxUpSpeed = 0;
237
+ if (!response.data.maxDownSpeed) response.data.maxDownSpeed = 0;
238
+ if (!response.data.startTime) response.data.startTime = response.data.onlineFailTime || "未知";
239
+ if (!response.data.nickName) response.data.nickName = response.data.nickName || "未知";
240
+ setCache("account", { account: formattedAccount }, response.data);
241
+ return response.data;
242
+ }
243
+ if (response.data.onlineStatus === "离线" || response.data.isPass === "原因未知") {
244
+ console.log("账号离线或状态异常,将使用有限信息");
245
+ if (!response.data.startTimeSum) response.data.startTimeSum = 0;
246
+ if (!response.data.maxUpSpeed) response.data.maxUpSpeed = 0;
247
+ if (!response.data.maxDownSpeed) response.data.maxDownSpeed = 0;
248
+ if (!response.data.startTime) response.data.startTime = "未知";
249
+ if (!response.data.nickName) response.data.nickName = "未知";
250
+ if (!response.data.mac) response.data.mac = "未知";
251
+ if (!response.data.userIp) response.data.userIp = "未知";
252
+ if (!response.data.accessDomain) response.data.accessDomain = "未知";
253
+ setCache("account", { account: formattedAccount }, response.data);
254
+ return response.data;
255
+ }
229
256
  if (!isAccountResponseComplete(response.data)) {
230
257
  throw new Error("账号信息有误,请检查账号是否正确");
231
258
  }
@@ -865,16 +892,36 @@ function apply(ctx, config) {
865
892
  // `RADIUS用户密码: ${user.password}`,
866
893
  `RADIUS状态: ${translateUserStatus(user.user_status)} ${user.user_status === "active" ? "✅" : user.user_status === "suspend" ? "⚠️" : "❌"}`,
867
894
  "",
868
- `状态: ${accountInfo.onlineStatus} ${accountInfo.onlineStatus.includes("在线") ? "✅" : "❌"}`,
869
- `认证: ${accountInfo.isPass} ${accountInfo.isPass.includes("成功") ? "✅" : "❌"}`,
870
- `IP地址: ${accountInfo.userIp}`,
871
- `MAC地址: ${accountInfo.mac}`,
872
- `最大上行: ${accountInfo.maxUpSpeed}Mbps`,
873
- `最大下行: ${accountInfo.maxDownSpeed}Mbps`,
874
- `开始时间: ${accountInfo.startTime}`,
875
- `在线时长: ${durationText}`,
876
- ""
895
+ `状态: ${accountInfo.onlineStatus} ${accountInfo.onlineStatus === "在线" ? "✅" : "❌"}`,
896
+ `认证: ${accountInfo.isPass} ${accountInfo.isPass.includes("成功") ? "✅" : "❌"}`
877
897
  ];
898
+ if (accountInfo.isPass === "上线失败") {
899
+ message.push(
900
+ `MAC地址: ${accountInfo.mac || "未知"}`,
901
+ `失败时间: ${accountInfo.onlineFailTime || "未知"}`,
902
+ `失败原因: ${accountInfo.onlineFailReason || "未知"}`,
903
+ `回复消息: ${accountInfo.failReplyMessage || "未知"}`,
904
+ `原因分析: ${accountInfo.reasonAnaly || "未知"}`
905
+ );
906
+ } else if (accountInfo.onlineStatus === "离线" || accountInfo.isPass === "原因未知") {
907
+ message.push(
908
+ `MAC地址: ${accountInfo.mac || "未知"}`,
909
+ `最后IP: ${accountInfo.userIp || "未知"}`
910
+ );
911
+ if (accountInfo.startTime) {
912
+ message.push(`最后在线: ${accountInfo.startTime || "未知"}`);
913
+ }
914
+ } else {
915
+ message.push(
916
+ `IP地址: ${accountInfo.userIp}`,
917
+ `MAC地址: ${accountInfo.mac}`,
918
+ `最大上行: ${accountInfo.maxUpSpeed}Mbps`,
919
+ `最大下行: ${accountInfo.maxDownSpeed}Mbps`,
920
+ `开始时间: ${accountInfo.startTime}`,
921
+ `在线时长: ${durationText}`
922
+ );
923
+ }
924
+ message.push("");
878
925
  if (orders && orders.length > 0) {
879
926
  message.push("🛒 订购信息");
880
927
  message.push("--------------------------------");
@@ -936,16 +983,36 @@ function apply(ctx, config) {
936
983
  // `RADIUS用户密码: ${user.password}`,
937
984
  `RADIUS状态: ${translateUserStatus(user.user_status)} ${user.user_status === "active" ? "✅" : user.user_status === "suspend" ? "⚠️" : "❌"}`,
938
985
  "",
939
- `状态: ${accountInfo.onlineStatus} ${accountInfo.onlineStatus.includes("在线") ? "✅" : "❌"}`,
940
- `认证: ${accountInfo.isPass} ${accountInfo.isPass.includes("成功") ? "✅" : "❌"}`,
941
- `IP地址: ${accountInfo.userIp}`,
942
- `MAC地址: ${accountInfo.mac}`,
943
- `最大上行: ${accountInfo.maxUpSpeed}Mbps`,
944
- `最大下行: ${accountInfo.maxDownSpeed}Mbps`,
945
- `开始时间: ${accountInfo.startTime}`,
946
- `在线时长: ${durationText}`,
947
- ""
986
+ `状态: ${accountInfo.onlineStatus} ${accountInfo.onlineStatus === "在线" ? "✅" : "❌"}`,
987
+ `认证: ${accountInfo.isPass} ${accountInfo.isPass.includes("成功") ? "✅" : "❌"}`
948
988
  ];
989
+ if (accountInfo.isPass === "上线失败") {
990
+ message.push(
991
+ `MAC地址: ${accountInfo.mac || "未知"}`,
992
+ `失败时间: ${accountInfo.onlineFailTime || "未知"}`,
993
+ `失败原因: ${accountInfo.onlineFailReason || "未知"}`,
994
+ `回复消息: ${accountInfo.failReplyMessage || "未知"}`,
995
+ `原因分析: ${accountInfo.reasonAnaly || "未知"}`
996
+ );
997
+ } else if (accountInfo.onlineStatus === "离线" || accountInfo.isPass === "原因未知") {
998
+ message.push(
999
+ `MAC地址: ${accountInfo.mac || "未知"}`,
1000
+ `最后IP: ${accountInfo.userIp || "未知"}`
1001
+ );
1002
+ if (accountInfo.startTime) {
1003
+ message.push(`最后在线: ${accountInfo.startTime || "未知"}`);
1004
+ }
1005
+ } else {
1006
+ message.push(
1007
+ `IP地址: ${accountInfo.userIp}`,
1008
+ `MAC地址: ${accountInfo.mac}`,
1009
+ `最大上行: ${accountInfo.maxUpSpeed}Mbps`,
1010
+ `最大下行: ${accountInfo.maxDownSpeed}Mbps`,
1011
+ `开始时间: ${accountInfo.startTime}`,
1012
+ `在线时长: ${durationText}`
1013
+ );
1014
+ }
1015
+ message.push("");
949
1016
  if (orders && orders.length > 0) {
950
1017
  message.push("🛒 订购信息");
951
1018
  message.push("--------------------------------");
@@ -1174,7 +1241,7 @@ function apply(ctx, config) {
1174
1241
  "🔐 RADIUS用户信息",
1175
1242
  "--------------------------------",
1176
1243
  `账号: ${user.login_name}`,
1177
- `密码: ${user.password}`,
1244
+ // `密码: ${user.password}`,
1178
1245
  `状态: ${translateUserStatus(user.user_status)} ${user.user_status === "active" ? "✅" : user.user_status === "suspend" ? "⚠️" : "❌"}`,
1179
1246
  `漫游状态: ${user.roam_status === "0" ? "允许漫游" : "禁止漫游"}`,
1180
1247
  `分公司标识: ${user.org_code}`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-jscn-aaaquery",
3
3
  "description": "江苏有线无锡分公司宽带信息查询插件",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -18,6 +18,10 @@
18
18
  - RADIUS用户信息:状态、密码等
19
19
  - 账号基本信息:在线状态、认证状态、IP地址、MAC地址等
20
20
  - 订购信息:订购状态、服务名称、生效时间、失效时间等
21
+ - 账号状态处理:
22
+ - 在线状态:显示IP地址、MAC地址、带宽、时长等完整信息
23
+ - 离线状态:显示最后IP地址、MAC地址、最后在线时间等基本信息
24
+ - 上线失败:显示MAC地址、失败时间、失败原因、回复消息、原因分析等故障信息
21
25
  - 备注:账号会自动转换为大写,在线时长会以"天小时分钟"的形式显示。
22
26
 
23
27
  ### 2. 账号详情
@@ -130,10 +134,33 @@
130
134
  5. 如果查询失败,请检查输入格式是否正确。
131
135
  6. 确保运维系统和RADIUS系统API能够正常访问。
132
136
  7. 账号查询时会先检查RADIUS授权,如授权有误将不继续查询账号信息。
137
+ 8. 光功率刷新功能将无论设备是否在线都会尝试刷新,确保获取最新数据。
138
+ 9. 针对上线失败或离线状态的账号,系统也能提供有用的信息,不会简单报错。
139
+
140
+ ## 开发相关
141
+
142
+ 为了支持开发过程中的热重载功能,需要确保:
143
+ 1. 在`koishi.yml`中正确配置hmr插件
144
+ 2. 安装并启用loader服务
145
+ 3. 在开发环境下运行Koishi时设置`NODE_ENV=development`
146
+
147
+ ```yaml
148
+ # 开发相关配置示例
149
+ group:develop:
150
+ $if: env.NODE_ENV === 'development'
151
+ hmr:
152
+ root:
153
+ - .
154
+ loader:
155
+ watch: true
156
+ ```
133
157
 
134
158
  ## 更新日志
135
159
 
136
160
  ### 最新更新
161
+ - 增加了离线状态和上线失败状态的特殊处理,提供更多有用信息
162
+ - 修复了状态图标显示问题,确保"不在线"状态正确显示❌图标
163
+ - 优化了数据完整性检查,对不同状态采用不同的验证标准
137
164
  - 增加了光功率评估功能,直观显示接收光功率是否在正常范围内
138
165
  - 优化了在线时长显示,支持天/小时/分钟格式
139
166
  - 增强了MAC地址格式处理,支持中文符号分隔