koishi-plugin-steam-info-check 1.0.9 → 1.0.10
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.d.ts +1 -0
- package/dist/index.js +66 -0
- package/dist/locales/zh-CN.d.ts +25 -0
- package/dist/locales/zh-CN.js +25 -0
- package/package.json +1 -1
- package/src/index.ts +57 -0
- package/src/locales/zh-CN.ts +25 -0
- package/src/locales/zh-CN.yml +2 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ exports.Config = koishi_1.Schema.object({
|
|
|
17
17
|
steamRequestInterval: koishi_1.Schema.number().default(300).description('轮询间隔(秒)'),
|
|
18
18
|
steamBroadcastType: koishi_1.Schema.union(['all', 'part', 'none']).default('part').description('播报类型:all(全部图片列表)、part(仅开始游戏时图片)、none(仅文字)'),
|
|
19
19
|
steamDisableBroadcastOnStartup: koishi_1.Schema.boolean().default(false).description('启动时禁用首次播报(仅预热缓存)'),
|
|
20
|
+
logForwardTarget: koishi_1.Schema.string().description('将所有日志转发到的目标用户 QQ(可选)'),
|
|
20
21
|
fonts: koishi_1.Schema.object({
|
|
21
22
|
regular: koishi_1.Schema.string().default('fonts/MiSans-Regular.ttf'),
|
|
22
23
|
light: koishi_1.Schema.string().default('fonts/MiSans-Light.ttf'),
|
|
@@ -41,6 +42,39 @@ function apply(ctx, config) {
|
|
|
41
42
|
// Services
|
|
42
43
|
ctx.plugin(service_1.SteamService, config);
|
|
43
44
|
ctx.plugin(drawer_1.DrawService, config);
|
|
45
|
+
// 日志转发(可选)
|
|
46
|
+
if (config.logForwardTarget) {
|
|
47
|
+
const target = config.logForwardTarget;
|
|
48
|
+
const sendToTarget = async (level, message) => {
|
|
49
|
+
try {
|
|
50
|
+
const bots = Object.values(ctx.bots);
|
|
51
|
+
const bot = bots[0];
|
|
52
|
+
if (!bot)
|
|
53
|
+
return;
|
|
54
|
+
const text = `[${exports.name}][${level}] ${typeof message === 'string' ? message : JSON.stringify(message)}`;
|
|
55
|
+
await bot.sendMessage(target, text);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// 忽略转发失败,避免影响主流程
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const ld = exports.logger;
|
|
62
|
+
const wrap = (orig, level) => (...args) => {
|
|
63
|
+
try {
|
|
64
|
+
orig(...args);
|
|
65
|
+
}
|
|
66
|
+
catch { }
|
|
67
|
+
try {
|
|
68
|
+
sendToTarget(level, args.map(a => (typeof a === 'string' ? a : JSON.stringify(a))).join(' '));
|
|
69
|
+
}
|
|
70
|
+
catch { }
|
|
71
|
+
};
|
|
72
|
+
ld.debug = wrap(ld.debug?.bind(ld) || (() => { }), 'DEBUG');
|
|
73
|
+
ld.info = wrap(ld.info?.bind(ld) || (() => { }), 'INFO');
|
|
74
|
+
ld.warn = wrap(ld.warn?.bind(ld) || (() => { }), 'WARN');
|
|
75
|
+
ld.error = wrap(ld.error?.bind(ld) || (() => { }), 'ERROR');
|
|
76
|
+
ld.fatal = wrap(ld.fatal?.bind(ld) || (() => { }), 'FATAL');
|
|
77
|
+
}
|
|
44
78
|
// Database
|
|
45
79
|
ctx.model.extend('steam_bind', {
|
|
46
80
|
id: 'unsigned',
|
|
@@ -264,6 +298,7 @@ async function ensureChannelMeta(ctx, session) {
|
|
|
264
298
|
{ group_id: Number(channelId) },
|
|
265
299
|
{ group_id: { group_id: Number(channelId) } },
|
|
266
300
|
];
|
|
301
|
+
// 先尝试对象参数变体
|
|
267
302
|
for (const args of argVariants) {
|
|
268
303
|
try {
|
|
269
304
|
exports.logger.error(`getGroupInfo 尝试 args=${JSON.stringify(args)}`);
|
|
@@ -296,6 +331,10 @@ async function ensureChannelMeta(ctx, session) {
|
|
|
296
331
|
// 记录详细错误以便分析 retcode/args
|
|
297
332
|
try {
|
|
298
333
|
exports.logger.error('getGroupInfo 调用失败,args=' + JSON.stringify(args) + ',错误:' + String(err) + ' EEE');
|
|
334
|
+
// 如果错误信息里包含 server-side 的 args 表示 RPC 层可能对参数进行了二次包装,记录原始错误便于排查
|
|
335
|
+
if (err && err.message) {
|
|
336
|
+
exports.logger.error('getGroupInfo 原始错误信息: ' + String(err.message));
|
|
337
|
+
}
|
|
299
338
|
}
|
|
300
339
|
catch (e) {
|
|
301
340
|
exports.logger.error('getGroupInfo 调用失败但记录 args 时出错:' + String(e) + ' EEE');
|
|
@@ -304,6 +343,33 @@ async function ensureChannelMeta(ctx, session) {
|
|
|
304
343
|
// 继续尝试下一个参数变体
|
|
305
344
|
}
|
|
306
345
|
}
|
|
346
|
+
// 再尝试直接传入原始值(避免内部框架二次封装)
|
|
347
|
+
const primitiveVariants = [channelId, Number(channelId)];
|
|
348
|
+
for (const arg of primitiveVariants) {
|
|
349
|
+
try {
|
|
350
|
+
exports.logger.error(`getGroupInfo 尝试 args=${JSON.stringify(arg)}`);
|
|
351
|
+
const info = await session.bot.internal.getGroupInfo(arg);
|
|
352
|
+
exports.logger.error(`getGroupInfo 返回: ${JSON.stringify(info)}`);
|
|
353
|
+
if (info) {
|
|
354
|
+
if (info.group_name) {
|
|
355
|
+
name = info.group_name;
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
if (info.data && info.data.group_name) {
|
|
359
|
+
name = info.data.group_name;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
catch (err) {
|
|
365
|
+
exports.logger.error('getGroupInfo 原始参数调用失败,arg=' + JSON.stringify(arg) + ',错误:' + String(err) + ' EEE');
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
// 所有尝试失败,记录最终失败并使用回退值
|
|
369
|
+
if (!name) {
|
|
370
|
+
exports.logger.error('getGroupInfo 所有尝试均失败,使用回退群名: ' + channelId + ' EEE');
|
|
371
|
+
name = channelId;
|
|
372
|
+
}
|
|
307
373
|
}
|
|
308
374
|
let avatar = current.avatar;
|
|
309
375
|
if (!avatar) {
|
package/dist/locales/zh-CN.d.ts
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
'steam-info': {
|
|
3
|
+
config: {
|
|
4
|
+
steamApiKey: string;
|
|
5
|
+
proxy: string;
|
|
6
|
+
steamRequestInterval: string;
|
|
7
|
+
steamBroadcastType: string;
|
|
8
|
+
steamDisableBroadcastOnStartup: string;
|
|
9
|
+
logForwardTarget: string;
|
|
10
|
+
fonts: {
|
|
11
|
+
regular: string;
|
|
12
|
+
light: string;
|
|
13
|
+
bold: string;
|
|
14
|
+
};
|
|
15
|
+
commandAuthority: {
|
|
16
|
+
bind: string;
|
|
17
|
+
unbind: string;
|
|
18
|
+
info: string;
|
|
19
|
+
check: string;
|
|
20
|
+
enable: string;
|
|
21
|
+
disable: string;
|
|
22
|
+
update: string;
|
|
23
|
+
nickname: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
2
27
|
commands: {
|
|
3
28
|
steam: {
|
|
4
29
|
bind: {
|
package/dist/locales/zh-CN.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = {
|
|
4
|
+
'steam-info': {
|
|
5
|
+
config: {
|
|
6
|
+
steamApiKey: 'Steam API Key(支持多个)',
|
|
7
|
+
proxy: '代理地址,例如 http://127.0.0.1:7890',
|
|
8
|
+
steamRequestInterval: '轮询间隔(秒)',
|
|
9
|
+
steamBroadcastType: '播报类型:all(全部图片列表)、part(仅开始游戏时图片)、none(仅文字)',
|
|
10
|
+
steamDisableBroadcastOnStartup: '启动时禁用首次播报(仅预热缓存)',
|
|
11
|
+
logForwardTarget: '日志转发目标 QQ(填写 QQ 号)',
|
|
12
|
+
fonts: {
|
|
13
|
+
regular: '常规字体路径',
|
|
14
|
+
light: '细体字体路径',
|
|
15
|
+
bold: '粗体字体路径',
|
|
16
|
+
},
|
|
17
|
+
commandAuthority: {
|
|
18
|
+
bind: '绑定命令权限',
|
|
19
|
+
unbind: '解绑命令权限',
|
|
20
|
+
info: '查看资料命令权限',
|
|
21
|
+
check: '查看状态命令权限',
|
|
22
|
+
enable: '启用播报命令权限',
|
|
23
|
+
disable: '禁用播报命令权限',
|
|
24
|
+
update: '更新群信息命令权限',
|
|
25
|
+
nickname: '设置昵称命令权限',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
4
29
|
commands: {
|
|
5
30
|
steam: {
|
|
6
31
|
bind: {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface Config {
|
|
|
13
13
|
steamRequestInterval: number
|
|
14
14
|
steamBroadcastType: 'all' | 'part' | 'none'
|
|
15
15
|
steamDisableBroadcastOnStartup: boolean
|
|
16
|
+
logForwardTarget?: string
|
|
16
17
|
fonts: {
|
|
17
18
|
regular: string
|
|
18
19
|
light: string
|
|
@@ -36,6 +37,7 @@ export const Config: Schema<Config> = Schema.object({
|
|
|
36
37
|
steamRequestInterval: Schema.number().default(300).description('轮询间隔(秒)'),
|
|
37
38
|
steamBroadcastType: Schema.union(['all', 'part', 'none']).default('part').description('播报类型:all(全部图片列表)、part(仅开始游戏时图片)、none(仅文字)'),
|
|
38
39
|
steamDisableBroadcastOnStartup: Schema.boolean().default(false).description('启动时禁用首次播报(仅预热缓存)'),
|
|
40
|
+
logForwardTarget: Schema.string().description('将所有日志转发到的目标用户 QQ(可选)'),
|
|
39
41
|
fonts: Schema.object({
|
|
40
42
|
regular: Schema.string().default('fonts/MiSans-Regular.ttf'),
|
|
41
43
|
light: Schema.string().default('fonts/MiSans-Light.ttf'),
|
|
@@ -71,6 +73,34 @@ export function apply(ctx: Context, config: Config) {
|
|
|
71
73
|
ctx.plugin(SteamService, config)
|
|
72
74
|
ctx.plugin(DrawService, config)
|
|
73
75
|
|
|
76
|
+
// 日志转发(可选)
|
|
77
|
+
if (config.logForwardTarget) {
|
|
78
|
+
const target = config.logForwardTarget
|
|
79
|
+
const sendToTarget = async (level: string, message: any) => {
|
|
80
|
+
try {
|
|
81
|
+
const bots = Object.values(ctx.bots)
|
|
82
|
+
const bot: any = bots[0]
|
|
83
|
+
if (!bot) return
|
|
84
|
+
const text = `[${name}][${level}] ${typeof message === 'string' ? message : JSON.stringify(message)}`
|
|
85
|
+
await bot.sendMessage(target, text)
|
|
86
|
+
} catch {
|
|
87
|
+
// 忽略转发失败,避免影响主流程
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const ld: any = logger as any
|
|
92
|
+
const wrap = (orig: Function, level: string) => (...args: any[]) => {
|
|
93
|
+
try { orig(...args) } catch {}
|
|
94
|
+
try { sendToTarget(level, args.map(a => (typeof a === 'string' ? a : JSON.stringify(a))).join(' ')) } catch {}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
ld.debug = wrap(ld.debug?.bind(ld) || (() => {}), 'DEBUG')
|
|
98
|
+
ld.info = wrap(ld.info?.bind(ld) || (() => {}), 'INFO')
|
|
99
|
+
ld.warn = wrap(ld.warn?.bind(ld) || (() => {}), 'WARN')
|
|
100
|
+
ld.error = wrap(ld.error?.bind(ld) || (() => {}), 'ERROR')
|
|
101
|
+
;(ld as any).fatal = wrap((ld as any).fatal?.bind(ld) || (() => {}), 'FATAL')
|
|
102
|
+
}
|
|
103
|
+
|
|
74
104
|
// Database
|
|
75
105
|
ctx.model.extend('steam_bind', {
|
|
76
106
|
id: 'unsigned',
|
|
@@ -299,6 +329,7 @@ async function ensureChannelMeta(ctx: Context, session: Session) {
|
|
|
299
329
|
{ group_id: { group_id: Number(channelId) } },
|
|
300
330
|
]
|
|
301
331
|
|
|
332
|
+
// 先尝试对象参数变体
|
|
302
333
|
for (const args of argVariants) {
|
|
303
334
|
try {
|
|
304
335
|
logger.error(`getGroupInfo 尝试 args=${JSON.stringify(args)}`)
|
|
@@ -333,6 +364,10 @@ async function ensureChannelMeta(ctx: Context, session: Session) {
|
|
|
333
364
|
// 记录详细错误以便分析 retcode/args
|
|
334
365
|
try {
|
|
335
366
|
logger.error('getGroupInfo 调用失败,args=' + JSON.stringify(args) + ',错误:' + String(err) + ' EEE')
|
|
367
|
+
// 如果错误信息里包含 server-side 的 args 表示 RPC 层可能对参数进行了二次包装,记录原始错误便于排查
|
|
368
|
+
if (err && (err as any).message) {
|
|
369
|
+
logger.error('getGroupInfo 原始错误信息: ' + String((err as any).message))
|
|
370
|
+
}
|
|
336
371
|
} catch (e) {
|
|
337
372
|
logger.error('getGroupInfo 调用失败但记录 args 时出错:' + String(e) + ' EEE')
|
|
338
373
|
}
|
|
@@ -340,6 +375,28 @@ async function ensureChannelMeta(ctx: Context, session: Session) {
|
|
|
340
375
|
// 继续尝试下一个参数变体
|
|
341
376
|
}
|
|
342
377
|
}
|
|
378
|
+
|
|
379
|
+
// 再尝试直接传入原始值(避免内部框架二次封装)
|
|
380
|
+
const primitiveVariants = [channelId, Number(channelId)]
|
|
381
|
+
for (const arg of primitiveVariants) {
|
|
382
|
+
try {
|
|
383
|
+
logger.error(`getGroupInfo 尝试 args=${JSON.stringify(arg)}`)
|
|
384
|
+
const info = await session.bot.internal.getGroupInfo(arg as any)
|
|
385
|
+
logger.error(`getGroupInfo 返回: ${JSON.stringify(info)}`)
|
|
386
|
+
if (info) {
|
|
387
|
+
if ((info as any).group_name) { name = (info as any).group_name; break }
|
|
388
|
+
if ((info as any).data && (info as any).data.group_name) { name = (info as any).data.group_name; break }
|
|
389
|
+
}
|
|
390
|
+
} catch (err) {
|
|
391
|
+
logger.error('getGroupInfo 原始参数调用失败,arg=' + JSON.stringify(arg) + ',错误:' + String(err) + ' EEE')
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// 所有尝试失败,记录最终失败并使用回退值
|
|
396
|
+
if (!name) {
|
|
397
|
+
logger.error('getGroupInfo 所有尝试均失败,使用回退群名: ' + channelId + ' EEE')
|
|
398
|
+
name = channelId
|
|
399
|
+
}
|
|
343
400
|
}
|
|
344
401
|
|
|
345
402
|
let avatar = current.avatar
|
package/src/locales/zh-CN.ts
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
export default {
|
|
2
|
+
'steam-info': {
|
|
3
|
+
config: {
|
|
4
|
+
steamApiKey: 'Steam API Key(支持多个)',
|
|
5
|
+
proxy: '代理地址,例如 http://127.0.0.1:7890',
|
|
6
|
+
steamRequestInterval: '轮询间隔(秒)',
|
|
7
|
+
steamBroadcastType: '播报类型:all(全部图片列表)、part(仅开始游戏时图片)、none(仅文字)',
|
|
8
|
+
steamDisableBroadcastOnStartup: '启动时禁用首次播报(仅预热缓存)',
|
|
9
|
+
logForwardTarget: '日志转发目标 QQ(填写 QQ 号)',
|
|
10
|
+
fonts: {
|
|
11
|
+
regular: '常规字体路径',
|
|
12
|
+
light: '细体字体路径',
|
|
13
|
+
bold: '粗体字体路径',
|
|
14
|
+
},
|
|
15
|
+
commandAuthority: {
|
|
16
|
+
bind: '绑定命令权限',
|
|
17
|
+
unbind: '解绑命令权限',
|
|
18
|
+
info: '查看资料命令权限',
|
|
19
|
+
check: '查看状态命令权限',
|
|
20
|
+
enable: '启用播报命令权限',
|
|
21
|
+
disable: '禁用播报命令权限',
|
|
22
|
+
update: '更新群信息命令权限',
|
|
23
|
+
nickname: '设置昵称命令权限',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
2
27
|
commands: {
|
|
3
28
|
steam: {
|
|
4
29
|
bind: {
|
package/src/locales/zh-CN.yml
CHANGED