@zhin.js/plugin-group-suite 3.0.1 → 3.0.3
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 +42 -58
- package/agent/tools/group_announce.ts +12 -0
- package/commands/checkin.ts +12 -0
- package/commands/forget.ts +12 -0
- package/commands/keyword-add/[keyword:string].ts +15 -0
- package/commands/keyword-list.ts +14 -0
- package/commands/keyword-remove/[keyword:string].ts +14 -0
- package/commands/mypoints.ts +12 -0
- package/commands/mystats.ts +12 -0
- package/commands/rank.ts +12 -0
- package/commands/stats-rank.ts +20 -0
- package/commands/stats-week.ts +20 -0
- package/commands/stats.ts +21 -0
- package/commands/teach-list/[page:number=1].ts +13 -0
- package/commands/teach-regex.ts +12 -0
- package/commands/teach.ts +12 -0
- package/lib/checkin-lib.d.ts +18 -0
- package/lib/checkin-lib.d.ts.map +1 -0
- package/lib/checkin-lib.js +118 -0
- package/lib/checkin-lib.js.map +1 -0
- package/lib/config.d.ts +4 -57
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +18 -40
- package/lib/config.js.map +1 -1
- package/lib/db-store.d.ts +12 -0
- package/lib/db-store.d.ts.map +1 -0
- package/lib/db-store.js +38 -0
- package/lib/db-store.js.map +1 -0
- package/lib/index.d.ts +9 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -29
- package/lib/index.js.map +1 -1
- package/lib/keyword-store.d.ts +6 -0
- package/lib/keyword-store.d.ts.map +1 -0
- package/lib/keyword-store.js +21 -0
- package/lib/keyword-store.js.map +1 -0
- package/lib/memory-store.d.ts +29 -0
- package/lib/memory-store.d.ts.map +1 -0
- package/lib/memory-store.js +59 -0
- package/lib/memory-store.js.map +1 -0
- package/lib/runtime-state.d.ts +24 -0
- package/lib/runtime-state.d.ts.map +1 -0
- package/lib/runtime-state.js +21 -0
- package/lib/runtime-state.js.map +1 -0
- package/lib/shared-runtime.d.ts +20 -0
- package/lib/shared-runtime.d.ts.map +1 -0
- package/lib/shared-runtime.js +34 -0
- package/lib/shared-runtime.js.map +1 -0
- package/lib/stats-lib.d.ts +29 -0
- package/lib/stats-lib.d.ts.map +1 -0
- package/lib/stats-lib.js +173 -0
- package/lib/stats-lib.js.map +1 -0
- package/lib/tables.d.ts +4 -0
- package/lib/tables.d.ts.map +1 -0
- package/lib/tables.js +40 -0
- package/lib/tables.js.map +1 -0
- package/lib/teach-lib.d.ts +22 -0
- package/lib/teach-lib.d.ts.map +1 -0
- package/lib/teach-lib.js +233 -0
- package/lib/teach-lib.js.map +1 -0
- package/middlewares/keyword-reply.ts +37 -0
- package/middlewares/stats-count.ts +22 -0
- package/middlewares/teach-reply.ts +22 -0
- package/package.json +46 -13
- package/plugin.ts +39 -0
- package/schema.json +17 -0
- package/src/checkin-lib.ts +148 -0
- package/src/config.ts +23 -57
- package/src/db-store.ts +51 -0
- package/src/index.ts +47 -33
- package/src/keyword-store.ts +24 -0
- package/src/memory-store.ts +88 -0
- package/src/runtime-state.ts +44 -0
- package/src/shared-runtime.ts +44 -0
- package/src/stats-lib.ts +202 -0
- package/src/tables.ts +46 -0
- package/src/teach-lib.ts +301 -0
- package/tools/checkin-query/handler.ts +2 -2
- package/tools/checkin-rank/handler.ts +1 -1
- package/tools/stats-query/handler.ts +2 -2
- package/tools/stats-user/handler.ts +3 -2
- package/lib/admin.d.ts +0 -4
- package/lib/admin.d.ts.map +0 -1
- package/lib/admin.js +0 -123
- package/lib/admin.js.map +0 -1
- package/lib/checkin.d.ts +0 -5
- package/lib/checkin.d.ts.map +0 -1
- package/lib/checkin.js +0 -168
- package/lib/checkin.js.map +0 -1
- package/lib/daily-analysis.d.ts +0 -7
- package/lib/daily-analysis.d.ts.map +0 -1
- package/lib/daily-analysis.js +0 -333
- package/lib/daily-analysis.js.map +0 -1
- package/lib/shared.d.ts +0 -25
- package/lib/shared.d.ts.map +0 -1
- package/lib/shared.js +0 -40
- package/lib/shared.js.map +0 -1
- package/lib/stats.d.ts +0 -12
- package/lib/stats.d.ts.map +0 -1
- package/lib/stats.js +0 -258
- package/lib/stats.js.map +0 -1
- package/lib/teach.d.ts +0 -4
- package/lib/teach.d.ts.map +0 -1
- package/lib/teach.js +0 -294
- package/lib/teach.js.map +0 -1
- package/plugin.yml +0 -3
- package/src/admin.ts +0 -145
- package/src/checkin.ts +0 -196
- package/src/daily-analysis.ts +0 -458
- package/src/shared.ts +0 -51
- package/src/stats.ts +0 -298
- package/src/teach.ts +0 -307
- /package/{skills/checkin/SKILL.md → agent/skills/checkin.md} +0 -0
- /package/{skills/group-daily-analysis/SKILL.md → agent/skills/group-daily-analysis.md} +0 -0
package/lib/config.js
CHANGED
|
@@ -1,41 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
streakCap: Schema.number().default(50).min(0).max(500),
|
|
20
|
-
rankSize: Schema.number()
|
|
21
|
-
.default(10)
|
|
22
|
-
.min(3)
|
|
23
|
-
.max(50)
|
|
24
|
-
.description("签到排行与消息统计排行显示人数"),
|
|
25
|
-
statsRetentionDays: Schema.number().default(90).min(7).max(365),
|
|
26
|
-
analysisDays: Schema.number().default(1).min(1).max(30),
|
|
27
|
-
autoAnalysisEnabled: Schema.boolean().default(false),
|
|
28
|
-
autoAnalysisCron: Schema.string().default("0 0 9 * * *"),
|
|
29
|
-
analysisGroups: Schema.list(Schema.string())
|
|
30
|
-
.default([])
|
|
31
|
-
.description("启用群日报的群 ID 白名单(空=不限制)"),
|
|
32
|
-
analysisGroupsBlock: Schema.list(Schema.string())
|
|
33
|
-
.default([])
|
|
34
|
-
.description("禁用群日报的群 ID"),
|
|
35
|
-
analysisMaxMessages: Schema.number().default(500).min(100).max(5000),
|
|
36
|
-
teachMaxPerGroup: Schema.number().default(200).min(1).max(1000),
|
|
37
|
-
teachCooldownMs: Schema.number().default(3000).min(0).max(60000),
|
|
38
|
-
teachAllowRegex: Schema.boolean().default(true),
|
|
39
|
-
teachPageSize: Schema.number().default(10).min(5).max(50),
|
|
40
|
-
});
|
|
1
|
+
export const DEFAULT_GROUP_SUITE_CONFIG = {
|
|
2
|
+
keywordReply: false,
|
|
3
|
+
basePointsMin: 10,
|
|
4
|
+
basePointsMax: 30,
|
|
5
|
+
streakBonus: 5,
|
|
6
|
+
streakCap: 50,
|
|
7
|
+
rankSize: 10,
|
|
8
|
+
teachMaxPerGroup: 200,
|
|
9
|
+
teachCooldownMs: 3000,
|
|
10
|
+
teachAllowRegex: true,
|
|
11
|
+
teachPageSize: 10,
|
|
12
|
+
};
|
|
13
|
+
export function resolveGroupSuiteConfig(raw) {
|
|
14
|
+
return {
|
|
15
|
+
...DEFAULT_GROUP_SUITE_CONFIG,
|
|
16
|
+
...raw,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
41
19
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,0BAA0B,GAAqB;IAC1D,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE,EAAE;IACjB,aAAa,EAAE,EAAE;IACjB,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,EAAE;IACZ,gBAAgB,EAAE,GAAG;IACrB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,EAAE;CAClB,CAAC;AAEF,MAAM,UAAU,uBAAuB,CACrC,GAA0C;IAE1C,OAAO;QACL,GAAG,0BAA0B;QAC7B,GAAG,GAAG;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type GroupSuiteMemoryDb, type GroupSuiteModel } from './memory-store.js';
|
|
2
|
+
/** Ensure an in-memory store when Runtime DatabaseFeature Resource is not wired yet. */
|
|
3
|
+
export declare function ensureGroupSuiteMemoryDb(): GroupSuiteMemoryDb;
|
|
4
|
+
export declare function getGroupSuiteDb(): GroupSuiteMemoryDb | null;
|
|
5
|
+
export declare function setGroupSuiteDb(db: GroupSuiteMemoryDb | null): void;
|
|
6
|
+
export declare function registerGroupSuiteDb(db: GroupSuiteMemoryDb): () => void;
|
|
7
|
+
/** Test helper: clear module store. */
|
|
8
|
+
export declare function resetGroupSuiteDb(): void;
|
|
9
|
+
export declare function getCheckinModel(db?: GroupSuiteMemoryDb | null): GroupSuiteModel | null;
|
|
10
|
+
export declare function getTeachModel(db?: GroupSuiteMemoryDb | null): GroupSuiteModel | null;
|
|
11
|
+
export declare function getStatsModel(db?: GroupSuiteMemoryDb | null): GroupSuiteModel | null;
|
|
12
|
+
//# sourceMappingURL=db-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-store.d.ts","sourceRoot":"","sources":["../src/db-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAK3B,wFAAwF;AACxF,wBAAgB,wBAAwB,IAAI,kBAAkB,CAG7D;AAED,wBAAgB,eAAe,IAAI,kBAAkB,GAAG,IAAI,CAE3D;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAEnE;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,kBAAkB,GAAG,MAAM,IAAI,CAOvE;AAED,uCAAuC;AACvC,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,wBAAgB,eAAe,CAAC,EAAE,4BAAoB,GAAG,eAAe,GAAG,IAAI,CAE9E;AAED,wBAAgB,aAAa,CAAC,EAAE,4BAAoB,GAAG,eAAe,GAAG,IAAI,CAE5E;AAED,wBAAgB,aAAa,CAAC,EAAE,4BAAoB,GAAG,eAAe,GAAG,IAAI,CAE5E"}
|
package/lib/db-store.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CHECKIN_TABLE, createInMemoryGroupSuiteDb, STATS_TABLE, TEACH_TABLE, } from './memory-store.js';
|
|
2
|
+
let _db = null;
|
|
3
|
+
const registrations = [];
|
|
4
|
+
/** Ensure an in-memory store when Runtime DatabaseFeature Resource is not wired yet. */
|
|
5
|
+
export function ensureGroupSuiteMemoryDb() {
|
|
6
|
+
if (!_db)
|
|
7
|
+
_db = createInMemoryGroupSuiteDb();
|
|
8
|
+
return _db;
|
|
9
|
+
}
|
|
10
|
+
export function getGroupSuiteDb() {
|
|
11
|
+
return registrations[registrations.length - 1]?.value ?? ensureGroupSuiteMemoryDb();
|
|
12
|
+
}
|
|
13
|
+
export function setGroupSuiteDb(db) {
|
|
14
|
+
_db = db;
|
|
15
|
+
}
|
|
16
|
+
export function registerGroupSuiteDb(db) {
|
|
17
|
+
const registration = Object.freeze({ value: db });
|
|
18
|
+
registrations.push(registration);
|
|
19
|
+
return () => {
|
|
20
|
+
const index = registrations.lastIndexOf(registration);
|
|
21
|
+
if (index >= 0)
|
|
22
|
+
registrations.splice(index, 1);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Test helper: clear module store. */
|
|
26
|
+
export function resetGroupSuiteDb() {
|
|
27
|
+
_db = null;
|
|
28
|
+
}
|
|
29
|
+
export function getCheckinModel(db = getGroupSuiteDb()) {
|
|
30
|
+
return db?.models.get(CHECKIN_TABLE) ?? null;
|
|
31
|
+
}
|
|
32
|
+
export function getTeachModel(db = getGroupSuiteDb()) {
|
|
33
|
+
return db?.models.get(TEACH_TABLE) ?? null;
|
|
34
|
+
}
|
|
35
|
+
export function getStatsModel(db = getGroupSuiteDb()) {
|
|
36
|
+
return db?.models.get(STATS_TABLE) ?? null;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=db-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-store.js","sourceRoot":"","sources":["../src/db-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,0BAA0B,EAC1B,WAAW,EACX,WAAW,GAGZ,MAAM,mBAAmB,CAAC;AAE3B,IAAI,GAAG,GAA8B,IAAI,CAAC;AAC1C,MAAM,aAAa,GAAkD,EAAE,CAAC;AAExE,wFAAwF;AACxF,MAAM,UAAU,wBAAwB;IACtC,IAAI,CAAC,GAAG;QAAE,GAAG,GAAG,0BAA0B,EAAE,CAAC;IAC7C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,IAAI,wBAAwB,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAA6B;IAC3D,GAAG,GAAG,EAAE,CAAC;AACX,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,EAAsB;IACzD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IAClD,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE;QACV,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACtD,IAAI,KAAK,IAAI,CAAC;YAAE,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,iBAAiB;IAC/B,GAAG,GAAG,IAAI,CAAC;AACb,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAE,GAAG,eAAe,EAAE;IACpD,OAAO,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAE,GAAG,eAAe,EAAE;IAClD,OAAO,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAE,GAAG,eAAe,EAAE;IAClD,OAAO,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;AAC7C,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { DEFAULT_GROUP_SUITE_CONFIG, resolveGroupSuiteConfig, } from './config.js';
|
|
2
|
+
export type { GroupSuiteConfig } from './config.js';
|
|
3
|
+
export { doCheckin, myPoints, pointsRank } from './checkin-lib.js';
|
|
4
|
+
export { addKeyword, listKeywords, matchKeyword, removeKeyword, resetKeywords, } from './keyword-store.js';
|
|
5
|
+
export { ensureGroupSuiteMemoryDb, getCheckinModel, getGroupSuiteDb, getStatsModel, getTeachModel, resetGroupSuiteDb, registerGroupSuiteDb, setGroupSuiteDb, } from './db-store.js';
|
|
6
|
+
export { createGroupSuiteRuntime, groupSuiteRuntimeToken, resolveGroupSuiteRuntime, } from './runtime-state.js';
|
|
7
|
+
export type { GroupSuiteRuntime, PendingStatsIncrement } from './runtime-state.js';
|
|
8
|
+
export { parseTeachPair, resetTeachCooldown, teachAdd, teachForget, teachList, tryTeachReply, } from './teach-lib.js';
|
|
9
|
+
export { flushStatsBuffer, monthStartStr, myStatsText, queryStats, recordMessage, resetStatsBuffer, statsRankText, weekStartStr, } from './stats-lib.js';
|
|
2
10
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,30 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* enabled: true
|
|
9
|
-
* groupSuite:
|
|
10
|
-
* noticeAdapters: [icqq]
|
|
11
|
-
* autoAnalysisEnabled: true
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
import { formatCompact, usePlugin } from "zhin.js";
|
|
15
|
-
import { groupSuiteSchema } from "./config.js";
|
|
16
|
-
import { registerAdmin } from "./admin.js";
|
|
17
|
-
import { registerCheckin } from "./checkin.js";
|
|
18
|
-
import { registerDailyAnalysis } from "./daily-analysis.js";
|
|
19
|
-
import { registerStats } from "./stats.js";
|
|
20
|
-
import { registerTeach } from "./teach.js";
|
|
21
|
-
const plugin = usePlugin();
|
|
22
|
-
const { logger, declareConfig } = plugin;
|
|
23
|
-
const cfg = declareConfig("groupSuite", groupSuiteSchema);
|
|
24
|
-
registerAdmin(plugin, cfg);
|
|
25
|
-
registerCheckin(plugin, cfg);
|
|
26
|
-
registerStats(plugin, cfg);
|
|
27
|
-
registerDailyAnalysis(plugin, cfg);
|
|
28
|
-
registerTeach(plugin, cfg);
|
|
29
|
-
logger.info(formatCompact({ 模块: "群组套件", 状态: "已加载" }));
|
|
1
|
+
export { DEFAULT_GROUP_SUITE_CONFIG, resolveGroupSuiteConfig, } from './config.js';
|
|
2
|
+
export { doCheckin, myPoints, pointsRank } from './checkin-lib.js';
|
|
3
|
+
export { addKeyword, listKeywords, matchKeyword, removeKeyword, resetKeywords, } from './keyword-store.js';
|
|
4
|
+
export { ensureGroupSuiteMemoryDb, getCheckinModel, getGroupSuiteDb, getStatsModel, getTeachModel, resetGroupSuiteDb, registerGroupSuiteDb, setGroupSuiteDb, } from './db-store.js';
|
|
5
|
+
export { createGroupSuiteRuntime, groupSuiteRuntimeToken, resolveGroupSuiteRuntime, } from './runtime-state.js';
|
|
6
|
+
export { parseTeachPair, resetTeachCooldown, teachAdd, teachForget, teachList, tryTeachReply, } from './teach-lib.js';
|
|
7
|
+
export { flushStatsBuffer, monthStartStr, myStatsText, queryStats, recordMessage, resetStatsBuffer, statsRankText, weekStartStr, } from './stats-lib.js';
|
|
30
8
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function addKeyword(keyword: string, reply: string, store?: Map<string, string>): void;
|
|
2
|
+
export declare function removeKeyword(keyword: string, store?: Map<string, string>): boolean;
|
|
3
|
+
export declare function listKeywords(store?: Map<string, string>): Array<[string, string]>;
|
|
4
|
+
export declare function matchKeyword(text: string, store?: Map<string, string>): string | null;
|
|
5
|
+
export declare function resetKeywords(): void;
|
|
6
|
+
//# sourceMappingURL=keyword-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyword-store.d.ts","sourceRoot":"","sources":["../src/keyword-store.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,sBAAW,GAAG,IAAI,CAEjF;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,sBAAW,GAAG,OAAO,CAExE;AAED,wBAAgB,YAAY,CAAC,KAAK,sBAAW,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAEtE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,sBAAW,GAAG,MAAM,GAAG,IAAI,CAK1E;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const keywords = new Map();
|
|
2
|
+
export function addKeyword(keyword, reply, store = keywords) {
|
|
3
|
+
store.set(keyword, reply);
|
|
4
|
+
}
|
|
5
|
+
export function removeKeyword(keyword, store = keywords) {
|
|
6
|
+
return store.delete(keyword);
|
|
7
|
+
}
|
|
8
|
+
export function listKeywords(store = keywords) {
|
|
9
|
+
return Array.from(store.entries());
|
|
10
|
+
}
|
|
11
|
+
export function matchKeyword(text, store = keywords) {
|
|
12
|
+
for (const [keyword, reply] of store) {
|
|
13
|
+
if (text.includes(keyword))
|
|
14
|
+
return reply;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export function resetKeywords() {
|
|
19
|
+
keywords.clear();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=keyword-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyword-store.js","sourceRoot":"","sources":["../src/keyword-store.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE3C,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,KAAa,EAAE,KAAK,GAAG,QAAQ;IACzE,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,KAAK,GAAG,QAAQ;IAC7D,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAK,GAAG,QAAQ;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,KAAK,GAAG,QAAQ;IACzD,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;IAC3C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory group-suite models (slice-2) until Plugin Runtime DatabaseFeature Resource lands.
|
|
3
|
+
*/
|
|
4
|
+
export interface GroupSuiteRow extends Record<string, unknown> {
|
|
5
|
+
id: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GroupSuiteModel {
|
|
8
|
+
select: () => {
|
|
9
|
+
where: (query: Record<string, unknown>) => Promise<GroupSuiteRow[]>;
|
|
10
|
+
then: <TResult1 = GroupSuiteRow[], TResult2 = never>(onfulfilled?: ((value: GroupSuiteRow[]) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null) => Promise<TResult1 | TResult2>;
|
|
11
|
+
};
|
|
12
|
+
insert: (row: Record<string, unknown>) => Promise<GroupSuiteRow>;
|
|
13
|
+
delete: () => {
|
|
14
|
+
where: (query: Record<string, unknown>) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
update: (patch: Record<string, unknown>) => {
|
|
17
|
+
where: (query: Record<string, unknown>) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface GroupSuiteMemoryDb {
|
|
21
|
+
models: {
|
|
22
|
+
get: (name: string) => GroupSuiteModel | undefined;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare const CHECKIN_TABLE = "checkin_records";
|
|
26
|
+
export declare const TEACH_TABLE = "teach_qa";
|
|
27
|
+
export declare const STATS_TABLE = "message_stats";
|
|
28
|
+
export declare function createInMemoryGroupSuiteDb(): GroupSuiteMemoryDb;
|
|
29
|
+
//# sourceMappingURL=memory-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../src/memory-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5D,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM;QACZ,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;QACpE,IAAI,EAAE,CAAC,QAAQ,GAAG,aAAa,EAAE,EAAE,QAAQ,GAAG,KAAK,EACjD,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,EACnF,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,KACxE,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;KACnC,CAAC;IACF,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,EAAE,MAAM;QAAE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;IAC3E,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;QAC1C,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC1D,CAAC;CACH;AA6CD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE;QACN,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAAC;KACpD,CAAC;CACH;AAED,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAC/C,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAE3C,wBAAgB,0BAA0B,IAAI,kBAAkB,CAW/D"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory group-suite models (slice-2) until Plugin Runtime DatabaseFeature Resource lands.
|
|
3
|
+
*/
|
|
4
|
+
function createMemoryModel() {
|
|
5
|
+
const rows = [];
|
|
6
|
+
let nextId = 1;
|
|
7
|
+
function matches(row, query) {
|
|
8
|
+
return Object.entries(query).every(([key, value]) => row[key] === value);
|
|
9
|
+
}
|
|
10
|
+
function all() {
|
|
11
|
+
return rows.map((row) => ({ ...row }));
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
select: () => {
|
|
15
|
+
const promise = Promise.resolve(all());
|
|
16
|
+
return {
|
|
17
|
+
where: async (query) => rows.filter((row) => matches(row, query)).map((row) => ({ ...row })),
|
|
18
|
+
then: (onfulfilled, onrejected) => promise.then(onfulfilled, onrejected),
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
insert: async (row) => {
|
|
22
|
+
const withId = { id: String(nextId++), ...row };
|
|
23
|
+
rows.push(withId);
|
|
24
|
+
return { ...withId };
|
|
25
|
+
},
|
|
26
|
+
delete: () => ({
|
|
27
|
+
where: async (query) => {
|
|
28
|
+
for (let i = rows.length - 1; i >= 0; i -= 1) {
|
|
29
|
+
if (matches(rows[i], query))
|
|
30
|
+
rows.splice(i, 1);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
update: (patch) => ({
|
|
35
|
+
where: async (query) => {
|
|
36
|
+
for (const row of rows) {
|
|
37
|
+
if (matches(row, query))
|
|
38
|
+
Object.assign(row, patch);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export const CHECKIN_TABLE = 'checkin_records';
|
|
45
|
+
export const TEACH_TABLE = 'teach_qa';
|
|
46
|
+
export const STATS_TABLE = 'message_stats';
|
|
47
|
+
export function createInMemoryGroupSuiteDb() {
|
|
48
|
+
const models = new Map([
|
|
49
|
+
[CHECKIN_TABLE, createMemoryModel()],
|
|
50
|
+
[TEACH_TABLE, createMemoryModel()],
|
|
51
|
+
[STATS_TABLE, createMemoryModel()],
|
|
52
|
+
]);
|
|
53
|
+
return {
|
|
54
|
+
models: {
|
|
55
|
+
get: (name) => models.get(name),
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=memory-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-store.js","sourceRoot":"","sources":["../src/memory-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAqBH,SAAS,iBAAiB;IACxB,MAAM,IAAI,GAAoB,EAAE,CAAC;IACjC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,SAAS,OAAO,CAAC,GAA4B,EAAE,KAA8B;QAC3E,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,K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AC;oBAC7C,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAE,EAAE,KAAK,CAAC;wBAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;SACF,CAAC;QACF,MAAM,EAAE,CAAC,KAA8B,EAAE,EAAE,CAAC,CAAC;YAC3C,KAAK,EAAE,KAAK,EAAE,KAA8B,EAAE,EAAE;gBAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;oBACvB,IAAI,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;wBAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC;SACF,CAAC;KACH,CAAC;AACJ,CAAC;AAQD,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAC/C,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AACtC,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAE3C,MAAM,UAAU,0BAA0B;IACxC,MAAM,MAAM,GAAG,IAAI,GAAG,CAA0B;QAC9C,CAAC,aAAa,EAAE,iBAAiB,EAAE,CAAC;QACpC,CAAC,WAAW,EAAE,iBAAiB,EAAE,CAAC;QAClC,CAAC,WAAW,EAAE,iBAAiB,EAAE,CAAC;KACnC,CAAC,CAAC;IACH,OAAO;QACL,MAAM,EAAE;YACN,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;SACxC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GroupSuiteMemoryDb } from './memory-store.js';
|
|
2
|
+
export interface PendingStatsIncrement {
|
|
3
|
+
user_id: string;
|
|
4
|
+
user_name: string;
|
|
5
|
+
group_id: string;
|
|
6
|
+
date: string;
|
|
7
|
+
count: number;
|
|
8
|
+
}
|
|
9
|
+
/** All mutable state owned by one group-suite plugin instance. */
|
|
10
|
+
export interface GroupSuiteRuntime {
|
|
11
|
+
readonly db: GroupSuiteMemoryDb;
|
|
12
|
+
readonly keywords: Map<string, string>;
|
|
13
|
+
readonly teachCooldowns: Map<string, number>;
|
|
14
|
+
readonly statsBuffer: Map<string, PendingStatsIncrement>;
|
|
15
|
+
}
|
|
16
|
+
export declare const groupSuiteRuntimeToken: import("@zhin.js/plugin-runtime").Token<GroupSuiteRuntime>;
|
|
17
|
+
export declare function createGroupSuiteRuntime(db: GroupSuiteMemoryDb): GroupSuiteRuntime;
|
|
18
|
+
export declare function resolveGroupSuiteRuntime(context: {
|
|
19
|
+
owner?: {
|
|
20
|
+
id?: unknown;
|
|
21
|
+
};
|
|
22
|
+
use<T>(token: typeof groupSuiteRuntimeToken): T;
|
|
23
|
+
}): GroupSuiteRuntime | undefined;
|
|
24
|
+
//# sourceMappingURL=runtime-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-state.d.ts","sourceRoot":"","sources":["../src/runtime-state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,kEAAkE;AAClE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,kBAAkB,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CAC1D;AAED,eAAO,MAAM,sBAAsB,4DAGlC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,kBAAkB,GAAG,iBAAiB,CAOjF;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,KAAK,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACzB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,sBAAsB,GAAG,CAAC,CAAC;CACjD,GAAG,iBAAiB,GAAG,SAAS,CAOhC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createToken } from '@zhin.js/plugin-runtime';
|
|
2
|
+
export const groupSuiteRuntimeToken = createToken('zhin.group-suite.runtime', 'Owner-scoped Group Suite database and ephemeral state');
|
|
3
|
+
export function createGroupSuiteRuntime(db) {
|
|
4
|
+
return {
|
|
5
|
+
db,
|
|
6
|
+
keywords: new Map(),
|
|
7
|
+
teachCooldowns: new Map(),
|
|
8
|
+
statsBuffer: new Map(),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function resolveGroupSuiteRuntime(context) {
|
|
12
|
+
try {
|
|
13
|
+
return context.use(groupSuiteRuntimeToken);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (context.owner?.id)
|
|
17
|
+
throw error;
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=runtime-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-state.js","sourceRoot":"","sources":["../src/runtime-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAmBtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAC/C,0BAA0B,EAC1B,uDAAuD,CACxD,CAAC;AAEF,MAAM,UAAU,uBAAuB,CAAC,EAAsB;IAC5D,OAAO;QACL,EAAE;QACF,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,cAAc,EAAE,IAAI,GAAG,EAAE;QACzB,WAAW,EAAE,IAAI,GAAG,EAAE;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAGxC;IACC,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAsB,CAAC;IAClE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE;YAAE,MAAM,KAAK,CAAC;QACnC,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare function todayStr(): string;
|
|
2
|
+
export declare function yesterdayStr(): string;
|
|
3
|
+
export declare function ts(): string;
|
|
4
|
+
export declare function randomInt(min: number, max: number): number;
|
|
5
|
+
/** Runtime Message → group/global context */
|
|
6
|
+
export declare function resolveContextKey(input: {
|
|
7
|
+
target?: string;
|
|
8
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
9
|
+
}): {
|
|
10
|
+
type: string;
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function resolveSender(input: {
|
|
14
|
+
sender?: string;
|
|
15
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
16
|
+
}): {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=shared-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-runtime.d.ts","sourceRoot":"","sources":["../src/shared-runtime.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,IAAI,MAAM,CAGjC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAIrC;AAED,wBAAgB,EAAE,IAAI,MAAM,CAE3B;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,6CAA6C;AAC7C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC9C,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAU/B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC9C,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAK/B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function todayStr() {
|
|
2
|
+
const d = new Date();
|
|
3
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
4
|
+
}
|
|
5
|
+
export function yesterdayStr() {
|
|
6
|
+
const d = new Date();
|
|
7
|
+
d.setDate(d.getDate() - 1);
|
|
8
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
9
|
+
}
|
|
10
|
+
export function ts() {
|
|
11
|
+
return new Date().toISOString();
|
|
12
|
+
}
|
|
13
|
+
export function randomInt(min, max) {
|
|
14
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
15
|
+
}
|
|
16
|
+
/** Runtime Message → group/global context */
|
|
17
|
+
export function resolveContextKey(input) {
|
|
18
|
+
const meta = input.metadata ?? {};
|
|
19
|
+
const channelType = String(meta.type ?? meta.channelType ?? '');
|
|
20
|
+
if (channelType === 'group' || channelType === 'guild') {
|
|
21
|
+
return { type: 'group', id: String(input.target ?? meta.channelId ?? '') };
|
|
22
|
+
}
|
|
23
|
+
if (input.target && channelType !== 'private') {
|
|
24
|
+
return { type: 'group', id: String(input.target) };
|
|
25
|
+
}
|
|
26
|
+
return { type: 'global', id: '' };
|
|
27
|
+
}
|
|
28
|
+
export function resolveSender(input) {
|
|
29
|
+
const meta = input.metadata ?? {};
|
|
30
|
+
const id = String(input.sender ?? meta.senderId ?? '');
|
|
31
|
+
const name = String(meta.senderName ?? meta.name ?? '用户');
|
|
32
|
+
return { id, name };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=shared-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-runtime.js","sourceRoot":"","sources":["../src/shared-runtime.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ;IACtB,MAAM,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IACrB,OAAO,GAAG,CAAC,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACnH,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IACrB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACnH,CAAC;AAED,MAAM,UA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,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;IAC1D,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GroupSuiteConfig } from './config.js';
|
|
2
|
+
import type { GroupSuiteRuntime } from './runtime-state.js';
|
|
3
|
+
export declare function weekStartStr(): string;
|
|
4
|
+
export declare function monthStartStr(): string;
|
|
5
|
+
export declare function resolveGroupId(input: {
|
|
6
|
+
target?: string;
|
|
7
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
8
|
+
}): string;
|
|
9
|
+
export declare function recordMessage(input: {
|
|
10
|
+
sender?: string;
|
|
11
|
+
target?: string;
|
|
12
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
13
|
+
}, runtime?: GroupSuiteRuntime): void;
|
|
14
|
+
export declare function flushStatsBuffer(runtime?: GroupSuiteRuntime): Promise<void>;
|
|
15
|
+
export declare function queryStats(groupId: string, fromDate: string, runtime?: GroupSuiteRuntime): Promise<Map<string, {
|
|
16
|
+
name: string;
|
|
17
|
+
count: number;
|
|
18
|
+
}>>;
|
|
19
|
+
type MessageInput = {
|
|
20
|
+
sender?: string;
|
|
21
|
+
target?: string;
|
|
22
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
23
|
+
};
|
|
24
|
+
export declare function statsRankText(input: MessageInput, cfg: GroupSuiteConfig, fromDate: string, title: string, runtime?: GroupSuiteRuntime): Promise<string>;
|
|
25
|
+
export declare function myStatsText(input: MessageInput, runtime?: GroupSuiteRuntime): Promise<string>;
|
|
26
|
+
/** Test helper */
|
|
27
|
+
export declare function resetStatsBuffer(): void;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=stats-lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats-lib.d.ts","sourceRoot":"","sources":["../src/stats-lib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,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