koishi-plugin-lolbaninfo 1.1.2 → 1.1.4
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.
- package/lib/index.js +28 -12
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -84,7 +84,7 @@ var Config = import_koishi.Schema.intersect([
|
|
|
84
84
|
api: import_koishi.Schema.object({
|
|
85
85
|
// API相关配置分组
|
|
86
86
|
apiUrl: import_koishi.Schema.string().description("目标网站的API接口地址").default("https://yun.4png.com/api/query.html"),
|
|
87
|
-
apiToken: import_koishi.Schema.string().description("网站API的访问Token(注册即可获得)").required()
|
|
87
|
+
apiToken: import_koishi.Schema.string().description("网站API的访问Token(注册即可获得)").role("secret").required()
|
|
88
88
|
// 需要用户输入的
|
|
89
89
|
}).description("API 设置"),
|
|
90
90
|
// API 相关配置的分组描述
|
|
@@ -129,7 +129,7 @@ async function requestWithRetry(ctx, config, qq) {
|
|
|
129
129
|
attempt++;
|
|
130
130
|
const status = error.response?.status || "未知状态";
|
|
131
131
|
const errorLog = `API请求失败(第 ${attempt} 次,状态:${status},错误:${error.message || error.code})`;
|
|
132
|
-
logger.
|
|
132
|
+
logger.error(errorLog);
|
|
133
133
|
const isRetryable = status >= 500 || !status || ["ECONNRESET", "ETIMEDOUT"].includes(error.code);
|
|
134
134
|
if (!isRetryable || attempt > retryTimes) {
|
|
135
135
|
const finalErrorLog = `达到最大重试次数或不可重试错误,停止请求`;
|
|
@@ -164,7 +164,11 @@ function apply(ctx, config) {
|
|
|
164
164
|
if (!isValidQQ(qq)) {
|
|
165
165
|
const errorLog = `QQ号格式错误:${qq}`;
|
|
166
166
|
logger.warn(errorLog);
|
|
167
|
-
return formatReplyMessage(
|
|
167
|
+
return formatReplyMessage(
|
|
168
|
+
session,
|
|
169
|
+
`❌ QQ号格式错误:${qq}(需5-13位数字)`,
|
|
170
|
+
config
|
|
171
|
+
);
|
|
168
172
|
}
|
|
169
173
|
try {
|
|
170
174
|
const result = await requestWithRetry(ctx, config, qq);
|
|
@@ -177,7 +181,8 @@ function apply(ctx, config) {
|
|
|
177
181
|
return formatReplyMessage(
|
|
178
182
|
session,
|
|
179
183
|
`✅ 查询成功:${msg}
|
|
180
|
-
|
|
184
|
+
|
|
185
|
+
📝 详细信息:${banInfo}`,
|
|
181
186
|
config
|
|
182
187
|
);
|
|
183
188
|
case 400:
|
|
@@ -200,7 +205,8 @@ function apply(ctx, config) {
|
|
|
200
205
|
return formatReplyMessage(
|
|
201
206
|
session,
|
|
202
207
|
`🛑 请求被拒绝 [403]:可能因查询过于频繁或IP受限
|
|
203
|
-
|
|
208
|
+
|
|
209
|
+
⏳ 建议稍后再试,或联系 API 提供方`,
|
|
204
210
|
config
|
|
205
211
|
);
|
|
206
212
|
case 404:
|
|
@@ -208,7 +214,15 @@ function apply(ctx, config) {
|
|
|
208
214
|
return formatReplyMessage(
|
|
209
215
|
session,
|
|
210
216
|
`❓ 未找到相关信息 [404]
|
|
211
|
-
|
|
217
|
+
|
|
218
|
+
📢 QQ ${qq} 可能未绑定《英雄联盟》账号,或当前无封禁记录`,
|
|
219
|
+
config
|
|
220
|
+
);
|
|
221
|
+
case 429:
|
|
222
|
+
logger.info(`API账号会员已经过期,请付费使用`);
|
|
223
|
+
return formatReplyMessage(
|
|
224
|
+
session,
|
|
225
|
+
`📢 API免费额度使用完毕或账号会员已经过期,请充值后使用`,
|
|
212
226
|
config
|
|
213
227
|
);
|
|
214
228
|
case 500:
|
|
@@ -216,7 +230,8 @@ function apply(ctx, config) {
|
|
|
216
230
|
return formatReplyMessage(
|
|
217
231
|
session,
|
|
218
232
|
`🛠️ 服务器内部错误 [500]:${msg}
|
|
219
|
-
|
|
233
|
+
|
|
234
|
+
📡 问题出在 API 服务端,请稍后再试`,
|
|
220
235
|
config
|
|
221
236
|
);
|
|
222
237
|
case 502:
|
|
@@ -226,16 +241,16 @@ function apply(ctx, config) {
|
|
|
226
241
|
return formatReplyMessage(
|
|
227
242
|
session,
|
|
228
243
|
`☁️ 服务暂时不可用 [${result.code}]:${msg}
|
|
229
|
-
|
|
244
|
+
|
|
245
|
+
🔌 可能是 API 服务维护或超载,请稍后重试`,
|
|
230
246
|
config
|
|
231
247
|
);
|
|
232
248
|
default:
|
|
233
249
|
const unknownLog = `查询失败 [错误码${result.code}]:${msg}`;
|
|
234
|
-
logger.
|
|
250
|
+
logger.error(unknownLog);
|
|
235
251
|
return formatReplyMessage(
|
|
236
252
|
session,
|
|
237
|
-
`❗ 收到未知响应码 [${result.code}]:${msg}
|
|
238
|
-
🔍 请检查 API 文档或联系插件作者`,
|
|
253
|
+
`❗ 收到未知响应码 [${result.code}]:${msg}`,
|
|
239
254
|
config
|
|
240
255
|
);
|
|
241
256
|
}
|
|
@@ -246,7 +261,8 @@ function apply(ctx, config) {
|
|
|
246
261
|
return formatReplyMessage(
|
|
247
262
|
session,
|
|
248
263
|
`⚠️ 查询过程中发生错误
|
|
249
|
-
|
|
264
|
+
|
|
265
|
+
📡 请检查网络、API 地址及 Token 配置`,
|
|
250
266
|
config
|
|
251
267
|
);
|
|
252
268
|
}
|