koishi-plugin-steam-info-check 1.0.8 → 1.0.9
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/dist/index.js +51 -30
- package/dist/service.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +54 -26
- package/src/locales/zh-CN.yml +21 -1
- package/src/service.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -83,7 +83,7 @@ function apply(ctx, config) {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
catch (e) {
|
|
86
|
-
exports.logger.
|
|
86
|
+
exports.logger.error('检查已绑定状态失败:' + String(e) + ' EEE');
|
|
87
87
|
}
|
|
88
88
|
await ctx.database.upsert('steam_bind', [
|
|
89
89
|
{
|
|
@@ -257,32 +257,53 @@ async function ensureChannelMeta(ctx, session) {
|
|
|
257
257
|
}
|
|
258
258
|
// OneBot 群名补充
|
|
259
259
|
if (!name && session.platform?.includes('onebot') && session.bot?.internal?.getGroupInfo) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
// 柔性尝试多种参数传递方式,记录每次调用结果以便定位 napcat/onebot 的参数格式差异
|
|
261
|
+
const argVariants = [
|
|
262
|
+
{ group_id: channelId },
|
|
263
|
+
{ group_id: { group_id: channelId } },
|
|
264
|
+
{ group_id: Number(channelId) },
|
|
265
|
+
{ group_id: { group_id: Number(channelId) } },
|
|
266
|
+
];
|
|
267
|
+
for (const args of argVariants) {
|
|
268
|
+
try {
|
|
269
|
+
exports.logger.error(`getGroupInfo 尝试 args=${JSON.stringify(args)}`);
|
|
270
|
+
const info = await session.bot.internal.getGroupInfo(args);
|
|
271
|
+
exports.logger.error(`getGroupInfo 返回: ${JSON.stringify(info)}`);
|
|
272
|
+
if (!info)
|
|
273
|
+
continue;
|
|
274
|
+
// 支持多种返回结构:直接 group_name、data.group_name(napcat)、或嵌套情况
|
|
275
|
+
if (info.group_name) {
|
|
276
|
+
name = info.group_name;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
if (info.data && info.data.group_name) {
|
|
280
|
+
name = info.data.group_name;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
if (info.data && info.data.group && info.data.group.group_name) {
|
|
284
|
+
name = info.data.group.group_name;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
// 某些实现会把返回包在 ret.data 或直接在 ret
|
|
288
|
+
if (info.ret && info.ret.data && info.ret.data.group_name) {
|
|
289
|
+
name = info.ret.data.group_name;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
// 如果未识别结构,记录并继续尝试下一个参数形态
|
|
293
|
+
exports.logger.error('getGroupInfo 返回了未识别结构(尝试 参数:' + JSON.stringify(args) + '): ' + JSON.stringify(info) + ' EEE');
|
|
294
|
+
}
|
|
295
|
+
catch (err) {
|
|
296
|
+
// 记录详细错误以便分析 retcode/args
|
|
264
297
|
try {
|
|
265
|
-
|
|
266
|
-
name = info.group_name;
|
|
267
|
-
}
|
|
268
|
-
else if (info.data && info.data.group_name) {
|
|
269
|
-
name = info.data.group_name;
|
|
270
|
-
}
|
|
271
|
-
else if (info.data && info.data.group && info.data.group.group_name) {
|
|
272
|
-
name = info.data.group.group_name;
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
exports.logger.warn('getGroupInfo 返回了未识别结构:' + JSON.stringify(info));
|
|
276
|
-
}
|
|
298
|
+
exports.logger.error('getGroupInfo 调用失败,args=' + JSON.stringify(args) + ',错误:' + String(err) + ' EEE');
|
|
277
299
|
}
|
|
278
300
|
catch (e) {
|
|
279
|
-
exports.logger.
|
|
301
|
+
exports.logger.error('getGroupInfo 调用失败但记录 args 时出错:' + String(e) + ' EEE');
|
|
280
302
|
}
|
|
303
|
+
// 如果错误中包含 retcode,记录方便排查
|
|
304
|
+
// 继续尝试下一个参数变体
|
|
281
305
|
}
|
|
282
306
|
}
|
|
283
|
-
catch (err) {
|
|
284
|
-
exports.logger.warn('getGroupInfo 调用失败:' + String(err));
|
|
285
|
-
}
|
|
286
307
|
}
|
|
287
308
|
let avatar = current.avatar;
|
|
288
309
|
if (!avatar) {
|
|
@@ -306,12 +327,12 @@ async function ensureChannelMeta(ctx, session) {
|
|
|
306
327
|
}
|
|
307
328
|
async function seedStatusCache(ctx) {
|
|
308
329
|
const binds = await ctx.database.get('steam_bind', {});
|
|
309
|
-
exports.logger.
|
|
330
|
+
exports.logger.error(`seedStatusCache: load binds count=${binds.length}`);
|
|
310
331
|
if (!binds.length)
|
|
311
332
|
return;
|
|
312
333
|
const steamIds = [...new Set(binds.map(b => b.steamId))];
|
|
313
334
|
const summaries = await ctx.steam.getPlayerSummaries(steamIds);
|
|
314
|
-
exports.logger.
|
|
335
|
+
exports.logger.error(`seedStatusCache: fetched summaries=${summaries.length}`);
|
|
315
336
|
for (const player of summaries) {
|
|
316
337
|
statusCache.set(player.steamid, player);
|
|
317
338
|
}
|
|
@@ -319,21 +340,21 @@ async function seedStatusCache(ctx) {
|
|
|
319
340
|
async function broadcast(ctx, config) {
|
|
320
341
|
try {
|
|
321
342
|
const channels = await ctx.database.get('steam_channel', { enable: true });
|
|
322
|
-
exports.logger.
|
|
343
|
+
exports.logger.error(`broadcast: enabled channels=${channels.length}`);
|
|
323
344
|
if (channels.length === 0)
|
|
324
345
|
return;
|
|
325
346
|
const channelIds = channels.map(c => c.id);
|
|
326
347
|
const binds = await ctx.database.get('steam_bind', { channelId: channelIds });
|
|
327
|
-
exports.logger.
|
|
348
|
+
exports.logger.error(`broadcast: binds total=${binds.length}`);
|
|
328
349
|
if (binds.length === 0)
|
|
329
350
|
return;
|
|
330
351
|
const steamIds = [...new Set(binds.map(b => b.steamId))];
|
|
331
|
-
exports.logger.
|
|
352
|
+
exports.logger.error(`broadcast: unique steamIds=${steamIds.length}`);
|
|
332
353
|
const currentSummaries = await ctx.steam.getPlayerSummaries(steamIds);
|
|
333
|
-
exports.logger.
|
|
354
|
+
exports.logger.error(`broadcast: fetched summaries=${currentSummaries.length}`);
|
|
334
355
|
const currentMap = new Map(currentSummaries.map(p => [p.steamid, p]));
|
|
335
356
|
for (const channel of channels) {
|
|
336
|
-
exports.logger.
|
|
357
|
+
exports.logger.error(`broadcast: channel=${channel.id} processing`);
|
|
337
358
|
const channelBinds = binds.filter(b => b.channelId === channel.id);
|
|
338
359
|
const msgs = [];
|
|
339
360
|
const startGamingPlayers = [];
|
|
@@ -359,7 +380,7 @@ async function broadcast(ctx, config) {
|
|
|
359
380
|
}
|
|
360
381
|
}
|
|
361
382
|
if (msgs.length > 0) {
|
|
362
|
-
exports.logger.
|
|
383
|
+
exports.logger.error(`broadcast: channel=${channel.id} msgs=${msgs.length}`);
|
|
363
384
|
const botKey = channel.platform && channel.assignee ? `${channel.platform}:${channel.assignee}` : undefined;
|
|
364
385
|
const bot = botKey ? ctx.bots[botKey] : Object.values(ctx.bots)[0];
|
|
365
386
|
if (!bot)
|
|
@@ -392,6 +413,6 @@ async function broadcast(ctx, config) {
|
|
|
392
413
|
}
|
|
393
414
|
}
|
|
394
415
|
catch (err) {
|
|
395
|
-
exports.logger.
|
|
416
|
+
exports.logger.error('broadcast 发生异常:' + String(err) + ' EEE');
|
|
396
417
|
}
|
|
397
418
|
}
|
package/dist/service.js
CHANGED
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -114,7 +114,7 @@ export function apply(ctx: Context, config: Config) {
|
|
|
114
114
|
return session.text('.already_bound')
|
|
115
115
|
}
|
|
116
116
|
} catch (e) {
|
|
117
|
-
logger.
|
|
117
|
+
logger.error('检查已绑定状态失败:' + String(e) + ' EEE')
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
await ctx.database.upsert('steam_bind', [
|
|
@@ -291,26 +291,54 @@ async function ensureChannelMeta(ctx: Context, session: Session) {
|
|
|
291
291
|
}
|
|
292
292
|
// OneBot 群名补充
|
|
293
293
|
if (!name && session.platform?.includes('onebot') && session.bot?.internal?.getGroupInfo) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
// 柔性尝试多种参数传递方式,记录每次调用结果以便定位 napcat/onebot 的参数格式差异
|
|
295
|
+
const argVariants = [
|
|
296
|
+
{ group_id: channelId },
|
|
297
|
+
{ group_id: { group_id: channelId } },
|
|
298
|
+
{ group_id: Number(channelId) },
|
|
299
|
+
{ group_id: { group_id: Number(channelId) } },
|
|
300
|
+
]
|
|
301
|
+
|
|
302
|
+
for (const args of argVariants) {
|
|
303
|
+
try {
|
|
304
|
+
logger.error(`getGroupInfo 尝试 args=${JSON.stringify(args)}`)
|
|
305
|
+
const info = await session.bot.internal.getGroupInfo(args)
|
|
306
|
+
logger.error(`getGroupInfo 返回: ${JSON.stringify(info)}`)
|
|
307
|
+
|
|
308
|
+
if (!info) continue
|
|
309
|
+
|
|
310
|
+
// 支持多种返回结构:直接 group_name、data.group_name(napcat)、或嵌套情况
|
|
311
|
+
if (info.group_name) {
|
|
312
|
+
name = info.group_name
|
|
313
|
+
break
|
|
314
|
+
}
|
|
315
|
+
if (info.data && info.data.group_name) {
|
|
316
|
+
name = info.data.group_name
|
|
317
|
+
break
|
|
318
|
+
}
|
|
319
|
+
if (info.data && info.data.group && info.data.group.group_name) {
|
|
320
|
+
name = info.data.group.group_name
|
|
321
|
+
break
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// 某些实现会把返回包在 ret.data 或直接在 ret
|
|
325
|
+
if (info.ret && info.ret.data && info.ret.data.group_name) {
|
|
326
|
+
name = info.ret.data.group_name
|
|
327
|
+
break
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// 如果未识别结构,记录并继续尝试下一个参数形态
|
|
331
|
+
logger.error('getGroupInfo 返回了未识别结构(尝试 参数:' + JSON.stringify(args) + '): ' + JSON.stringify(info) + ' EEE')
|
|
332
|
+
} catch (err) {
|
|
333
|
+
// 记录详细错误以便分析 retcode/args
|
|
298
334
|
try {
|
|
299
|
-
|
|
300
|
-
name = info.group_name
|
|
301
|
-
} else if (info.data && info.data.group_name) {
|
|
302
|
-
name = info.data.group_name
|
|
303
|
-
} else if (info.data && info.data.group && info.data.group.group_name) {
|
|
304
|
-
name = info.data.group.group_name
|
|
305
|
-
} else {
|
|
306
|
-
logger.warn('getGroupInfo 返回了未识别结构:' + JSON.stringify(info))
|
|
307
|
-
}
|
|
335
|
+
logger.error('getGroupInfo 调用失败,args=' + JSON.stringify(args) + ',错误:' + String(err) + ' EEE')
|
|
308
336
|
} catch (e) {
|
|
309
|
-
logger.
|
|
337
|
+
logger.error('getGroupInfo 调用失败但记录 args 时出错:' + String(e) + ' EEE')
|
|
310
338
|
}
|
|
339
|
+
// 如果错误中包含 retcode,记录方便排查
|
|
340
|
+
// 继续尝试下一个参数变体
|
|
311
341
|
}
|
|
312
|
-
} catch (err) {
|
|
313
|
-
logger.warn('getGroupInfo 调用失败:' + String(err))
|
|
314
342
|
}
|
|
315
343
|
}
|
|
316
344
|
|
|
@@ -336,11 +364,11 @@ async function ensureChannelMeta(ctx: Context, session: Session) {
|
|
|
336
364
|
|
|
337
365
|
async function seedStatusCache(ctx: Context) {
|
|
338
366
|
const binds = await ctx.database.get('steam_bind', {})
|
|
339
|
-
logger.
|
|
367
|
+
logger.error(`seedStatusCache: load binds count=${binds.length}`)
|
|
340
368
|
if (!binds.length) return
|
|
341
369
|
const steamIds = [...new Set(binds.map(b => b.steamId))]
|
|
342
370
|
const summaries = await ctx.steam.getPlayerSummaries(steamIds)
|
|
343
|
-
logger.
|
|
371
|
+
logger.error(`seedStatusCache: fetched summaries=${summaries.length}`)
|
|
344
372
|
for (const player of summaries) {
|
|
345
373
|
statusCache.set(player.steamid, player)
|
|
346
374
|
}
|
|
@@ -349,23 +377,23 @@ async function seedStatusCache(ctx: Context) {
|
|
|
349
377
|
async function broadcast(ctx: Context, config: Config) {
|
|
350
378
|
try {
|
|
351
379
|
const channels = await ctx.database.get('steam_channel', { enable: true })
|
|
352
|
-
logger.
|
|
380
|
+
logger.error(`broadcast: enabled channels=${channels.length}`)
|
|
353
381
|
if (channels.length === 0) return
|
|
354
382
|
|
|
355
383
|
const channelIds = channels.map(c => c.id)
|
|
356
384
|
const binds = await ctx.database.get('steam_bind', { channelId: channelIds })
|
|
357
|
-
logger.
|
|
385
|
+
logger.error(`broadcast: binds total=${binds.length}`)
|
|
358
386
|
if (binds.length === 0) return
|
|
359
387
|
|
|
360
388
|
const steamIds = [...new Set(binds.map(b => b.steamId))]
|
|
361
|
-
logger.
|
|
389
|
+
logger.error(`broadcast: unique steamIds=${steamIds.length}`)
|
|
362
390
|
|
|
363
391
|
const currentSummaries = await ctx.steam.getPlayerSummaries(steamIds)
|
|
364
|
-
logger.
|
|
392
|
+
logger.error(`broadcast: fetched summaries=${currentSummaries.length}`)
|
|
365
393
|
const currentMap = new Map(currentSummaries.map(p => [p.steamid, p]))
|
|
366
394
|
|
|
367
395
|
for (const channel of channels) {
|
|
368
|
-
logger.
|
|
396
|
+
logger.error(`broadcast: channel=${channel.id} processing`)
|
|
369
397
|
const channelBinds = binds.filter(b => b.channelId === channel.id)
|
|
370
398
|
const msgs: string[] = []
|
|
371
399
|
const startGamingPlayers: any[] = []
|
|
@@ -393,7 +421,7 @@ async function broadcast(ctx: Context, config: Config) {
|
|
|
393
421
|
}
|
|
394
422
|
|
|
395
423
|
if (msgs.length > 0) {
|
|
396
|
-
logger.
|
|
424
|
+
logger.error(`broadcast: channel=${channel.id} msgs=${msgs.length}`)
|
|
397
425
|
const botKey = channel.platform && channel.assignee ? `${channel.platform}:${channel.assignee}` : undefined
|
|
398
426
|
const bot = botKey ? ctx.bots[botKey] : Object.values(ctx.bots)[0]
|
|
399
427
|
if (!bot) continue
|
|
@@ -423,6 +451,6 @@ async function broadcast(ctx: Context, config: Config) {
|
|
|
423
451
|
statusCache.set(p.steamid, p)
|
|
424
452
|
}
|
|
425
453
|
} catch (err) {
|
|
426
|
-
logger.
|
|
454
|
+
logger.error('broadcast 发生异常:' + String(err) + ' EEE')
|
|
427
455
|
}
|
|
428
456
|
}
|
package/src/locales/zh-CN.yml
CHANGED
|
@@ -11,4 +11,24 @@ enable_success: "已开启本群播报。"
|
|
|
11
11
|
disable_success: "已关闭本群播报。"
|
|
12
12
|
args_missing: "参数缺失。"
|
|
13
13
|
update_success: "更新群信息成功。"
|
|
14
|
-
nickname_set: "昵称已设置为 {0}。"
|
|
14
|
+
nickname_set: "昵称已设置为 {0}。"
|
|
15
|
+
|
|
16
|
+
# 配置面板本地化
|
|
17
|
+
fonts:
|
|
18
|
+
regular: "常规字体路径"
|
|
19
|
+
light: "细体字体路径"
|
|
20
|
+
bold: "粗体字体路径"
|
|
21
|
+
|
|
22
|
+
steamDisableBroadcastOnStartup: "启动时禁用首次播报(仅预热缓存)"
|
|
23
|
+
steamRequestInterval: "轮询间隔(秒)"
|
|
24
|
+
steamBroadcastType: "播报类型(all/part/none)"
|
|
25
|
+
|
|
26
|
+
commandAuthority:
|
|
27
|
+
bind: "绑定命令权限"
|
|
28
|
+
unbind: "解绑命令权限"
|
|
29
|
+
info: "查看资料命令权限"
|
|
30
|
+
check: "查看状态命令权限"
|
|
31
|
+
enable: "启用播报命令权限"
|
|
32
|
+
disable: "禁用播报命令权限"
|
|
33
|
+
update: "更新群信息命令权限"
|
|
34
|
+
nickname: "设置昵称命令权限"
|
package/src/service.ts
CHANGED