@zhin.js/plugin-repeater 1.1.14 → 1.1.16
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/README.md +6 -0
- package/commands/repeater-status/index.js +3 -3
- package/commands/repeater-status/index.ts +3 -3
- package/lib/config.js +3 -3
- package/lib/config.js.map +1 -1
- package/lib/engine.d.ts +2 -1
- package/lib/engine.d.ts.map +1 -1
- package/lib/engine.js +4 -9
- package/lib/engine.js.map +1 -1
- package/lib/i18n.d.ts +2 -0
- package/lib/i18n.d.ts.map +1 -0
- package/lib/i18n.js +8 -0
- package/lib/i18n.js.map +1 -0
- package/package.json +7 -7
- package/schema.json +15 -0
- package/src/config.ts +3 -3
- package/src/engine.ts +5 -9
- package/src/i18n.ts +8 -0
package/README.md
CHANGED
|
@@ -41,3 +41,9 @@ repeater:
|
|
|
41
41
|
## 许可
|
|
42
42
|
|
|
43
43
|
MIT
|
|
44
|
+
|
|
45
|
+
## Language / 语言
|
|
46
|
+
|
|
47
|
+
命令说明和执行反馈跟随当前操作语言(简体中文或英文);用户输入与第三方内容保持原样,不进行自动翻译。语言与时区、权限和实际执行行为独立。参见[官方插件语言说明](../../README.md#语言与内容)。
|
|
48
|
+
|
|
49
|
+
Command feedback follows the operation language. User input and third-party content remain unchanged. See the [localization guide](../../../docs/en/configuration/localization.md).
|
|
@@ -3,8 +3,8 @@ import { defineCommand } from 'zhin.js/command';
|
|
|
3
3
|
import {} from "../../lib/engine.js";
|
|
4
4
|
import { repeaterEngineToken } from "../../lib/runtime.js";
|
|
5
5
|
export default defineCommand({
|
|
6
|
-
description: '查看复读机的运行状态',
|
|
7
|
-
execute({ config, use }) {
|
|
8
|
-
return use(repeaterEngineToken).statusLines(config);
|
|
6
|
+
description: '查看复读机的运行状态', descriptionI18n: { en: "View repeater status" },
|
|
7
|
+
execute({ config, use, locale }) {
|
|
8
|
+
return use(repeaterEngineToken).statusLines(config, locale);
|
|
9
9
|
},
|
|
10
10
|
});
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
import { repeaterEngineToken } from '../../src/runtime.js';
|
|
6
6
|
|
|
7
7
|
export default defineCommand<RepeaterConfig>({
|
|
8
|
-
description: '查看复读机的运行状态',
|
|
9
|
-
execute({ config, use }) {
|
|
10
|
-
return use(repeaterEngineToken).statusLines(config);
|
|
8
|
+
description: '查看复读机的运行状态', descriptionI18n: { en: "View repeater status" },
|
|
9
|
+
execute({ config, use, locale }) {
|
|
10
|
+
return use(repeaterEngineToken).statusLines(config, locale);
|
|
11
11
|
},
|
|
12
12
|
});
|
package/lib/config.js
CHANGED
|
@@ -6,8 +6,8 @@ export const DEFAULT_REPEATER_CONFIG = Object.freeze({
|
|
|
6
6
|
});
|
|
7
7
|
/** Authoring declaration; scripts/sync-plugin-config-schemas.mjs generates the packaged schema.json for Runtime and Console. */
|
|
8
8
|
export const repeaterConfig = Schema.object({
|
|
9
|
-
threshold: Schema.number().min(2).max(10).step(1).default(DEFAULT_REPEATER_CONFIG.threshold).description('触发复读的最少人数').effect('reload'),
|
|
10
|
-
cooldown: Schema.number().min(5_000).max(300_000).default(DEFAULT_REPEATER_CONFIG.cooldown).description('同一群冷却时间 (ms)').effect('reload'),
|
|
11
|
-
maxLength: Schema.number().min(10).max(1_000).step(1).default(DEFAULT_REPEATER_CONFIG.maxLength).description('消息长度上限').effect('reload'),
|
|
9
|
+
threshold: Schema.number().min(2).max(10).step(1).default(DEFAULT_REPEATER_CONFIG.threshold).description('触发复读的最少人数').i18n({ "en": { "description": "Minimum distinct users needed to trigger repetition." } }).effect('reload'),
|
|
10
|
+
cooldown: Schema.number().min(5_000).max(300_000).default(DEFAULT_REPEATER_CONFIG.cooldown).description('同一群冷却时间 (ms)').i18n({ "en": { "description": "Cooldown for the same group, in milliseconds." } }).effect('reload'),
|
|
11
|
+
maxLength: Schema.number().min(10).max(1_000).step(1).default(DEFAULT_REPEATER_CONFIG.maxLength).description('消息长度上限').i18n({ "en": { "description": "Maximum message length." } }).effect('reload'),
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=config.js.map
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;IACnD,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,GAAG;CACf,CAAC,CAAC;AAEH,gIAAgI;AAChI,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;IACnD,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,GAAG;CACf,CAAC,CAAC;AAEH,gIAAgI;AAChI,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,EAAC,aAAa,EAAE,sDAAsD,EAAC,EAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC5N,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,EAAC,aAAa,EAAE,+CAA+C,EAAC,EAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;IACvN,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,EAAC,aAAa,EAAE,yBAAyB,EAAC,EAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;CACjM,CAAC,CAAC"}
|
package/lib/engine.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
1
2
|
import type { RepeaterConfig } from './config.js';
|
|
2
3
|
export { DEFAULT_REPEATER_CONFIG } from './config.js';
|
|
3
4
|
export type { RepeaterConfig } from './config.js';
|
|
@@ -31,7 +32,7 @@ export declare class RepeaterEngine {
|
|
|
31
32
|
get totalRepeats(): number;
|
|
32
33
|
get activeGroups(): number;
|
|
33
34
|
tick(message: RepeaterInboundFields, config: RepeaterConfig): RepeaterTickResult;
|
|
34
|
-
statusLines(config: RepeaterConfig): string;
|
|
35
|
+
statusLines(config: RepeaterConfig, locale?: Locale): string;
|
|
35
36
|
pruneStale(now?: number, expiry?: number, cooldown?: number): void;
|
|
36
37
|
dispose(): void;
|
|
37
38
|
}
|
package/lib/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,YAAY,EAAE;QACrB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;QAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,GAAG,IAAI,CAY5E;AASD,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,qBAAa,cAAc;;;IAezB,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,cAAc,GAAG,kBAAkB;IAuChF,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAK5D,UAAU,CAAC,GAAG,SAAa,EAAE,MAAM,SAAa,EAAE,QAAQ,SAAqB,GAAG,IAAI;IAStF,OAAO,IAAI,IAAI;CAMhB"}
|
package/lib/engine.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { messages as t } from './i18n.js';
|
|
1
2
|
import { DEFAULT_REPEATER_CONFIG } from './config.js';
|
|
2
3
|
export { DEFAULT_REPEATER_CONFIG } from './config.js';
|
|
3
4
|
/**
|
|
@@ -76,15 +77,9 @@ export class RepeaterEngine {
|
|
|
76
77
|
});
|
|
77
78
|
return { action: 'next' };
|
|
78
79
|
}
|
|
79
|
-
statusLines(config) {
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
`监控群数: ${this.activeGroups}`,
|
|
83
|
-
`触发阈值: ${config.threshold} 人`,
|
|
84
|
-
`冷却时间: ${config.cooldown / 1000}s`,
|
|
85
|
-
`消息长度上限: ${config.maxLength}`,
|
|
86
|
-
`累计复读: ${this.#totalRepeats} 次`,
|
|
87
|
-
].join('\n');
|
|
80
|
+
statusLines(config, locale) {
|
|
81
|
+
return t(locale, 'status', { groups: this.activeGroups, threshold: config.threshold,
|
|
82
|
+
cooldown: config.cooldown / 1000, length: config.maxLength, repeats: this.#totalRepeats });
|
|
88
83
|
}
|
|
89
84
|
pruneStale(now = Date.now(), expiry = 5 * 60_000, cooldown = this.#lastCooldown) {
|
|
90
85
|
for (const [key, state] of this.#groupStates) {
|
package/lib/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine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QAAQ,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED,UAAU,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC,aAAa;QAC7E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC7C,IAAI,GAAG,GAAG,KAAK,CAAC,QAAQ,GAAG,MAAM;gBAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnE,CAAC;QACD,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5C,IAAI,GAAG,GAAG,IAAI,GAAG,QAAQ,GAAG,CAAC;gBAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,aAAa;YAAE,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1D,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
package/lib/i18n.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,mHAKnB,CAAC"}
|
package/lib/i18n.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createMessages } from 'zhin.js/i18n';
|
|
2
|
+
export const messages = createMessages({
|
|
3
|
+
"status": {
|
|
4
|
+
"zh-CN": "复读机状态\n监控群数: {groups}\n触发阈值: {threshold} 人\n冷却时间: {cooldown}s\n消息长度上限: {length}\n累计复读: {repeats} 次",
|
|
5
|
+
"en": "Repeater status\nMonitored groups: {groups}\nTrigger threshold: {threshold} users\nCooldown: {cooldown}s\nMaximum message length: {length}\nTotal repetitions: {repeats}"
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=i18n.js.map
|
package/lib/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC;IACrC,QAAQ,EAAE;QACR,OAAO,EAAE,oGAAoG;QAC7G,IAAI,EAAE,0KAA0K;KACjL;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/plugin-repeater",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"description": "Repeater plugin for Zhin.js — auto-repeat when group members echo the same content (Plugin Runtime)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@zhin.js/core": "1.1.
|
|
44
|
-
"@zhin.js/skill": "1.1.
|
|
43
|
+
"@zhin.js/core": "1.1.51",
|
|
44
|
+
"@zhin.js/skill": "1.1.10"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"typescript": "^6.0.3",
|
|
48
48
|
"vitest": "^4.1.10",
|
|
49
|
-
"zhin.js": "1.1.
|
|
49
|
+
"zhin.js": "1.1.16"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"plugins": []
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@zhin.js/command": "^1.1.
|
|
87
|
-
"@zhin.js/middleware": "^1.1.
|
|
88
|
-
"zhin.js": "^1.1.
|
|
86
|
+
"@zhin.js/command": "^1.1.11",
|
|
87
|
+
"@zhin.js/middleware": "^1.1.10",
|
|
88
|
+
"zhin.js": "^1.1.16"
|
|
89
89
|
},
|
|
90
90
|
"peerDependenciesMeta": {
|
|
91
91
|
"@zhin.js/command": {
|
package/schema.json
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
"threshold": {
|
|
6
6
|
"type": "number",
|
|
7
7
|
"description": "触发复读的最少人数",
|
|
8
|
+
"x-i18n": {
|
|
9
|
+
"en": {
|
|
10
|
+
"description": "Minimum distinct users needed to trigger repetition."
|
|
11
|
+
}
|
|
12
|
+
},
|
|
8
13
|
"default": 3,
|
|
9
14
|
"minimum": 2,
|
|
10
15
|
"maximum": 10,
|
|
@@ -16,6 +21,11 @@
|
|
|
16
21
|
"cooldown": {
|
|
17
22
|
"type": "number",
|
|
18
23
|
"description": "同一群冷却时间 (ms)",
|
|
24
|
+
"x-i18n": {
|
|
25
|
+
"en": {
|
|
26
|
+
"description": "Cooldown for the same group, in milliseconds."
|
|
27
|
+
}
|
|
28
|
+
},
|
|
19
29
|
"default": 30000,
|
|
20
30
|
"minimum": 5000,
|
|
21
31
|
"maximum": 300000,
|
|
@@ -26,6 +36,11 @@
|
|
|
26
36
|
"maxLength": {
|
|
27
37
|
"type": "number",
|
|
28
38
|
"description": "消息长度上限",
|
|
39
|
+
"x-i18n": {
|
|
40
|
+
"en": {
|
|
41
|
+
"description": "Maximum message length."
|
|
42
|
+
}
|
|
43
|
+
},
|
|
29
44
|
"default": 200,
|
|
30
45
|
"minimum": 10,
|
|
31
46
|
"maximum": 1000,
|
package/src/config.ts
CHANGED
|
@@ -8,9 +8,9 @@ export const DEFAULT_REPEATER_CONFIG = Object.freeze({
|
|
|
8
8
|
|
|
9
9
|
/** Authoring declaration; scripts/sync-plugin-config-schemas.mjs generates the packaged schema.json for Runtime and Console. */
|
|
10
10
|
export const repeaterConfig = Schema.object({
|
|
11
|
-
threshold: Schema.number().min(2).max(10).step(1).default(DEFAULT_REPEATER_CONFIG.threshold).description('触发复读的最少人数').effect('reload'),
|
|
12
|
-
cooldown: Schema.number().min(5_000).max(300_000).default(DEFAULT_REPEATER_CONFIG.cooldown).description('同一群冷却时间 (ms)').effect('reload'),
|
|
13
|
-
maxLength: Schema.number().min(10).max(1_000).step(1).default(DEFAULT_REPEATER_CONFIG.maxLength).description('消息长度上限').effect('reload'),
|
|
11
|
+
threshold: Schema.number().min(2).max(10).step(1).default(DEFAULT_REPEATER_CONFIG.threshold).description('触发复读的最少人数').i18n({"en": {"description": "Minimum distinct users needed to trigger repetition."}}).effect('reload'),
|
|
12
|
+
cooldown: Schema.number().min(5_000).max(300_000).default(DEFAULT_REPEATER_CONFIG.cooldown).description('同一群冷却时间 (ms)').i18n({"en": {"description": "Cooldown for the same group, in milliseconds."}}).effect('reload'),
|
|
13
|
+
maxLength: Schema.number().min(10).max(1_000).step(1).default(DEFAULT_REPEATER_CONFIG.maxLength).description('消息长度上限').i18n({"en": {"description": "Maximum message length."}}).effect('reload'),
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export type RepeaterConfig = Schema.Output<typeof repeaterConfig>;
|
package/src/engine.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from './i18n.js';
|
|
1
3
|
import { DEFAULT_REPEATER_CONFIG } from './config.js';
|
|
2
4
|
import type { RepeaterConfig } from './config.js';
|
|
3
5
|
export { DEFAULT_REPEATER_CONFIG } from './config.js';
|
|
@@ -105,15 +107,9 @@ export class RepeaterEngine {
|
|
|
105
107
|
return { action: 'next' };
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
statusLines(config: RepeaterConfig): string {
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
`监控群数: ${this.activeGroups}`,
|
|
112
|
-
`触发阈值: ${config.threshold} 人`,
|
|
113
|
-
`冷却时间: ${config.cooldown / 1000}s`,
|
|
114
|
-
`消息长度上限: ${config.maxLength}`,
|
|
115
|
-
`累计复读: ${this.#totalRepeats} 次`,
|
|
116
|
-
].join('\n');
|
|
110
|
+
statusLines(config: RepeaterConfig, locale?: Locale): string {
|
|
111
|
+
return t(locale, 'status', { groups: this.activeGroups, threshold: config.threshold,
|
|
112
|
+
cooldown: config.cooldown / 1000, length: config.maxLength, repeats: this.#totalRepeats });
|
|
117
113
|
}
|
|
118
114
|
|
|
119
115
|
pruneStale(now = Date.now(), expiry = 5 * 60_000, cooldown = this.#lastCooldown): void {
|
package/src/i18n.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createMessages } from 'zhin.js/i18n';
|
|
2
|
+
|
|
3
|
+
export const messages = createMessages({
|
|
4
|
+
"status": {
|
|
5
|
+
"zh-CN": "复读机状态\n监控群数: {groups}\n触发阈值: {threshold} 人\n冷却时间: {cooldown}s\n消息长度上限: {length}\n累计复读: {repeats} 次",
|
|
6
|
+
"en": "Repeater status\nMonitored groups: {groups}\nTrigger threshold: {threshold} users\nCooldown: {cooldown}s\nMaximum message length: {length}\nTotal repetitions: {repeats}"
|
|
7
|
+
}
|
|
8
|
+
});
|