@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/README.md
CHANGED
|
@@ -1,80 +1,64 @@
|
|
|
1
1
|
# @zhin.js/plugin-group-suite
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Plugin Runtime 群运营能力包,提供签到积分、消息统计、关键词回复与群问答。所有能力
|
|
4
|
+
由 `commands/`、`middlewares/` 和 `agent/` 约定目录发现,不注册 legacy Plugin 回调。
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
- `@zhin.js/plugin-checkin`
|
|
7
|
-
- `@zhin.js/plugin-stats`
|
|
8
|
-
- `@zhin.js/plugin-group-daily-analysis`
|
|
9
|
-
- `@zhin.js/plugin-teach`
|
|
10
|
-
|
|
11
|
-
## 安装
|
|
6
|
+
## 安装与拓扑
|
|
12
7
|
|
|
13
8
|
```bash
|
|
14
9
|
pnpm add @zhin.js/plugin-group-suite
|
|
15
10
|
```
|
|
16
11
|
|
|
17
|
-
|
|
12
|
+
父插件在 `package.json#zhin.plugins` 中声明子插件:
|
|
18
13
|
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"package": "@zhin.js/plugin-group-suite",
|
|
17
|
+
"instanceKey": "group-suite"
|
|
18
|
+
}
|
|
22
19
|
```
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
配置位于该实例的层级节点:
|
|
25
22
|
|
|
26
23
|
```yaml
|
|
27
24
|
plugins:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# 可整段省略,使用默认值
|
|
40
|
-
groupSuite:
|
|
41
|
-
noticeAdapters: [icqq]
|
|
42
|
-
autoAnalysisEnabled: true
|
|
43
|
-
autoAnalysisCron: "0 9 * * *"
|
|
25
|
+
group-suite:
|
|
26
|
+
keywordReply: false
|
|
27
|
+
basePointsMin: 10
|
|
28
|
+
basePointsMax: 30
|
|
29
|
+
streakBonus: 5
|
|
30
|
+
streakCap: 50
|
|
31
|
+
rankSize: 10
|
|
32
|
+
teachMaxPerGroup: 200
|
|
33
|
+
teachCooldownMs: 3000
|
|
34
|
+
teachAllowRegex: true
|
|
35
|
+
teachPageSize: 10
|
|
44
36
|
```
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
| 字段 | 默认 | 说明 |
|
|
49
|
-
|------|------|------|
|
|
50
|
-
| `welcome` | 欢迎新成员… | 入群欢迎语 |
|
|
51
|
-
| `recallNotify` | `true` | 撤回提示 |
|
|
52
|
-
| `keywordReply` | `false` | 内置关键词(建议用 teach) |
|
|
53
|
-
| `noticeAdapters` | `[icqq]` | 处理 notice 的适配器 |
|
|
54
|
-
| `basePointsMin` / `basePointsMax` | 10 / 30 | 签到积分 |
|
|
55
|
-
| `rankSize` | 10 | 签到与统计排行人数 |
|
|
56
|
-
| `statsRetentionDays` | 90 | 统计保留天数 |
|
|
57
|
-
| `analysisDays` | 1 | 群分析天数 |
|
|
58
|
-
| `analysisGroups` | `[]` | 日报白名单(空=不限制) |
|
|
59
|
-
| `analysisGroupsBlock` | `[]` | 日报黑名单 |
|
|
60
|
-
| `teachMaxPerGroup` | 200 | 每群问答上限 |
|
|
61
|
-
| `teachCooldownMs` | 3000 | 问答冷却(毫秒) |
|
|
38
|
+
完整约束以 [`schema.json`](./schema.json) 为 SSOT。数据优先写入 Runtime
|
|
39
|
+
`DatabaseHost`;未配置数据库时使用插件实例私有的内存存储,适合测试。
|
|
62
40
|
|
|
63
|
-
|
|
41
|
+
数据库、关键词、教学冷却和消息统计缓冲统一封装为 owner-scoped
|
|
42
|
+
`GroupSuiteRuntime`。commands/middlewares 只通过 Capability Context 解析该资源;因此同一
|
|
43
|
+
进程中的多个实例、HMR 新旧 generation 不会共享可变状态。
|
|
64
44
|
|
|
65
|
-
|
|
45
|
+
## 能力
|
|
66
46
|
|
|
67
|
-
|
|
68
|
-
|
|
47
|
+
| 路径 | 说明 |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `checkin` / `mypoints` / `rank` | 签到、积分与排行 |
|
|
50
|
+
| `stats` / `stats-week` / `stats-rank` / `mystats` | 消息统计 |
|
|
51
|
+
| `teach` / `teach-regex` / `teach-list` / `forget` | 群问答管理 |
|
|
52
|
+
| `keyword-add` / `keyword-list` / `keyword-remove` | 关键词回复管理 |
|
|
53
|
+
| `middlewares/*` | 入站统计、关键词和问答匹配 |
|
|
54
|
+
| `agent/tools/group_announce.ts` | 可选 Agent 群公告工具 |
|
|
69
55
|
|
|
70
|
-
|
|
56
|
+
本 major 不包含 Adapter side-event 欢迎/撤回、AI 群日报或 HTML 报表。这些旧能力
|
|
57
|
+
需要独立的事件与渲染 Feature,已从 schema 移除,避免出现“可配置但不生效”的字段。
|
|
71
58
|
|
|
72
|
-
##
|
|
59
|
+
## 验证
|
|
73
60
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
| `群分析` / `分析设置` | 日报 |
|
|
79
|
-
| `teach` / `teach-regex` / `forget` / `teach-list` | 问答(`teach 问题 回答` 或 `teach 问题\|答案`) |
|
|
80
|
-
| `添加关键词` … | 仅 `keywordReply: true` |
|
|
61
|
+
```bash
|
|
62
|
+
pnpm --filter @zhin.js/plugin-group-suite build
|
|
63
|
+
pnpm --filter @zhin.js/plugin-group-suite test
|
|
64
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export default defineAgentTool<{ message: string }>({
|
|
5
|
+
description: '向群聊发送公告/通知消息',
|
|
6
|
+
inputSchema: z.object({ message: z.string().min(1) }),
|
|
7
|
+
keywords: ['群公告', '通知', 'announce'],
|
|
8
|
+
async execute({ message }) {
|
|
9
|
+
if (!message?.trim()) return '公告内容不能为空';
|
|
10
|
+
return `📢 群公告:\n${message}`;
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import { resolveGroupSuiteConfig, type GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { doCheckin } from '../src/checkin-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '每日签到获得积分',
|
|
9
|
+
execute({ config, input, owner, use }) {
|
|
10
|
+
return doCheckin(input ?? {}, resolveGroupSuiteConfig(config), resolveGroupSuiteRuntime({ owner, use }));
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import type { GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { teachForget } from '../src/teach-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '忘记问答(删除问答对)',
|
|
9
|
+
execute({ input, args, owner, use }) {
|
|
10
|
+
return teachForget(input ?? {}, args.join(' '), resolveGroupSuiteRuntime({ owner, use }));
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import { addKeyword } from '../../src/keyword-store.js';
|
|
3
|
+
import type { GroupSuiteConfig } from '../../src/config.js';
|
|
4
|
+
import { resolveGroupSuiteRuntime } from '../../src/runtime-state.js';
|
|
5
|
+
|
|
6
|
+
export default defineCommand<GroupSuiteConfig>({
|
|
7
|
+
description: '添加关键词自动回复',
|
|
8
|
+
execute({ params, args, owner, use }) {
|
|
9
|
+
const keyword = String(params.keyword ?? '');
|
|
10
|
+
const reply = args.join(' ').trim();
|
|
11
|
+
if (!keyword || !reply) return '请提供关键词和回复内容';
|
|
12
|
+
addKeyword(keyword, reply, resolveGroupSuiteRuntime({ owner, use })?.keywords);
|
|
13
|
+
return `已添加关键词「${keyword}」→「${reply}」`;
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import { listKeywords } from '../src/keyword-store.js';
|
|
3
|
+
import type { GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
5
|
+
|
|
6
|
+
export default defineCommand<GroupSuiteConfig>({
|
|
7
|
+
description: '查看所有关键词回复对',
|
|
8
|
+
execute({ owner, use }) {
|
|
9
|
+
const entries = listKeywords(resolveGroupSuiteRuntime({ owner, use })?.keywords);
|
|
10
|
+
if (entries.length === 0) return '当前没有设置任何关键词';
|
|
11
|
+
const lines = entries.map(([k, v], i) => `${i + 1}. 「${k}」→「${v}」`);
|
|
12
|
+
return `关键词列表(共 ${entries.length} 条):\n${lines.join('\n')}`;
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import { removeKeyword } from '../../src/keyword-store.js';
|
|
3
|
+
import type { GroupSuiteConfig } from '../../src/config.js';
|
|
4
|
+
import { resolveGroupSuiteRuntime } from '../../src/runtime-state.js';
|
|
5
|
+
|
|
6
|
+
export default defineCommand<GroupSuiteConfig>({
|
|
7
|
+
description: '删除关键词自动回复',
|
|
8
|
+
execute({ params, owner, use }) {
|
|
9
|
+
const keyword = String(params.keyword ?? '');
|
|
10
|
+
if (!keyword) return '请提供要删除的关键词';
|
|
11
|
+
if (!removeKeyword(keyword, resolveGroupSuiteRuntime({ owner, use })?.keywords)) return `关键词「${keyword}」不存在`;
|
|
12
|
+
return `已删除关键词「${keyword}」`;
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import type { GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { myPoints } from '../src/checkin-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '查看个人积分与签到信息',
|
|
9
|
+
execute({ input, owner, use }) {
|
|
10
|
+
return myPoints(input ?? {}, resolveGroupSuiteRuntime({ owner, use }));
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import type { GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { myStatsText } from '../src/stats-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '查看个人消息统计',
|
|
9
|
+
execute({ input, owner, use }) {
|
|
10
|
+
return myStatsText(input ?? {}, resolveGroupSuiteRuntime({ owner, use }));
|
|
11
|
+
},
|
|
12
|
+
});
|
package/commands/rank.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import { resolveGroupSuiteConfig, type GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { pointsRank } from '../src/checkin-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '查看积分排行榜',
|
|
9
|
+
execute({ config, input, owner, use }) {
|
|
10
|
+
return pointsRank(input ?? {}, resolveGroupSuiteConfig(config), resolveGroupSuiteRuntime({ owner, use }));
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import { resolveGroupSuiteConfig, type GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { monthStartStr, resolveGroupId, statsRankText } from '../src/stats-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '查看本月话唠排行',
|
|
9
|
+
execute({ config, input, owner, use }) {
|
|
10
|
+
const groupId = resolveGroupId(input ?? {});
|
|
11
|
+
const title = groupId ? '本月话唠排行' : '全局话唠排行';
|
|
12
|
+
return statsRankText(
|
|
13
|
+
input ?? {},
|
|
14
|
+
resolveGroupSuiteConfig(config),
|
|
15
|
+
monthStartStr(),
|
|
16
|
+
title,
|
|
17
|
+
resolveGroupSuiteRuntime({ owner, use }),
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import { resolveGroupSuiteConfig, type GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { resolveGroupId, statsRankText, weekStartStr } from '../src/stats-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '查看本周消息统计',
|
|
9
|
+
execute({ config, input, owner, use }) {
|
|
10
|
+
const groupId = resolveGroupId(input ?? {});
|
|
11
|
+
const title = groupId ? '本周本群消息统计' : '本周全局消息统计';
|
|
12
|
+
return statsRankText(
|
|
13
|
+
input ?? {},
|
|
14
|
+
resolveGroupSuiteConfig(config),
|
|
15
|
+
weekStartStr(),
|
|
16
|
+
title,
|
|
17
|
+
resolveGroupSuiteRuntime({ owner, use }),
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import { resolveGroupSuiteConfig, type GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { todayStr } from '../src/shared-runtime.js';
|
|
5
|
+
import { resolveGroupId, statsRankText } from '../src/stats-lib.js';
|
|
6
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
7
|
+
|
|
8
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
9
|
+
description: '查看今日消息统计',
|
|
10
|
+
execute({ config, input, owner, use }) {
|
|
11
|
+
const groupId = resolveGroupId(input ?? {});
|
|
12
|
+
const title = groupId ? '今日本群消息统计' : '今日全局消息统计';
|
|
13
|
+
return statsRankText(
|
|
14
|
+
input ?? {},
|
|
15
|
+
resolveGroupSuiteConfig(config),
|
|
16
|
+
todayStr(),
|
|
17
|
+
title,
|
|
18
|
+
resolveGroupSuiteRuntime({ owner, use }),
|
|
19
|
+
);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import { resolveGroupSuiteConfig, type GroupSuiteConfig } from '../../src/config.js';
|
|
4
|
+
import { teachList } from '../../src/teach-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '查看问答列表',
|
|
9
|
+
execute({ config, input, params, owner, use }) {
|
|
10
|
+
const page = Number(params.page ?? 1);
|
|
11
|
+
return teachList(input ?? {}, resolveGroupSuiteConfig(config), page, resolveGroupSuiteRuntime({ owner, use }));
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import { resolveGroupSuiteConfig, type GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { teachAdd } from '../src/teach-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '教我正则问答',
|
|
9
|
+
execute({ config, input, args, owner, use }) {
|
|
10
|
+
return teachAdd(input ?? {}, resolveGroupSuiteConfig(config), args.join(' '), true, resolveGroupSuiteRuntime({ owner, use }));
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineCommand } from '@zhin.js/command';
|
|
2
|
+
import type { Message } from '@zhin.js/core/runtime';
|
|
3
|
+
import { resolveGroupSuiteConfig, type GroupSuiteConfig } from '../src/config.js';
|
|
4
|
+
import { teachAdd } from '../src/teach-lib.js';
|
|
5
|
+
import { resolveGroupSuiteRuntime } from '../src/runtime-state.js';
|
|
6
|
+
|
|
7
|
+
export default defineCommand<GroupSuiteConfig, string, Message>({
|
|
8
|
+
description: '教我问答(teach 问题 回答 或 问题|答案)',
|
|
9
|
+
execute({ config, input, args, owner, use }) {
|
|
10
|
+
return teachAdd(input ?? {}, resolveGroupSuiteConfig(config), args.join(' '), false, resolveGroupSuiteRuntime({ owner, use }));
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GroupSuiteConfig } from './config.js';
|
|
2
|
+
import type { GroupSuiteRuntime } from './runtime-state.js';
|
|
3
|
+
export declare function doCheckin(input: {
|
|
4
|
+
sender?: string;
|
|
5
|
+
target?: string;
|
|
6
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
7
|
+
}, cfg: GroupSuiteConfig, runtime?: GroupSuiteRuntime): Promise<string>;
|
|
8
|
+
export declare function myPoints(input: {
|
|
9
|
+
sender?: string;
|
|
10
|
+
target?: string;
|
|
11
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
12
|
+
}, runtime?: GroupSuiteRuntime): Promise<string>;
|
|
13
|
+
export declare function pointsRank(input: {
|
|
14
|
+
sender?: string;
|
|
15
|
+
target?: string;
|
|
16
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
17
|
+
}, cfg: GroupSuiteConfig, runtime?: GroupSuiteRuntime): Promise<string>;
|
|
18
|
+
//# sourceMappingURL=checkin-lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkin-lib.d.ts","sourceRoot":"","sources":["../src/checkin-lib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAUpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAsC5D,wBAAsB,SAAS,CAC7B,KAAK,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,EACzF,GAAG,EAAE,gBAAgB,EACrB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAyCjB;AAED,wBAAsB,QAAQ,CAC5B,KAAK,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,EACzF,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAqBjB;AAED,wBAAsB,UAAU,CAC9B,KAAK,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,EACzF,GAAG,EAAE,gBAAgB,EACrB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAsBjB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { getCheckinModel } from './db-store.js';
|
|
2
|
+
import { randomInt, resolveContextKey, resolveSender, todayStr, ts, yesterdayStr, } from './shared-runtime.js';
|
|
3
|
+
async function getOrCreateUser(model, userId, userName, ctxType, ctxId) {
|
|
4
|
+
const rows = (await model.select().where({
|
|
5
|
+
user_id: userId,
|
|
6
|
+
context_type: ctxType,
|
|
7
|
+
context_id: ctxId,
|
|
8
|
+
}));
|
|
9
|
+
if (rows.length > 0)
|
|
10
|
+
return rows[0];
|
|
11
|
+
await model.insert({
|
|
12
|
+
user_id: userId,
|
|
13
|
+
user_name: userName,
|
|
14
|
+
points: 0,
|
|
15
|
+
total_checkins: 0,
|
|
16
|
+
streak: 0,
|
|
17
|
+
max_streak: 0,
|
|
18
|
+
last_checkin: '',
|
|
19
|
+
context_type: ctxType,
|
|
20
|
+
context_id: ctxId,
|
|
21
|
+
created_at: ts(),
|
|
22
|
+
updated_at: ts(),
|
|
23
|
+
});
|
|
24
|
+
const created = (await model.select().where({
|
|
25
|
+
user_id: userId,
|
|
26
|
+
context_type: ctxType,
|
|
27
|
+
context_id: ctxId,
|
|
28
|
+
}));
|
|
29
|
+
return created[0] ?? null;
|
|
30
|
+
}
|
|
31
|
+
export async function doCheckin(input, cfg, runtime) {
|
|
32
|
+
const M = getCheckinModel(runtime?.db);
|
|
33
|
+
if (!M)
|
|
34
|
+
return '签到数据库尚未就绪,请稍后重试';
|
|
35
|
+
const { id: userId, name: userName } = resolveSender(input);
|
|
36
|
+
if (!userId)
|
|
37
|
+
return '无法获取用户信息';
|
|
38
|
+
const { type: ctxType, id: ctxId } = resolveContextKey(input);
|
|
39
|
+
const user = await getOrCreateUser(M, userId, userName, ctxType, ctxId);
|
|
40
|
+
if (!user)
|
|
41
|
+
return '签到失败,请重试';
|
|
42
|
+
const today = todayStr();
|
|
43
|
+
if (user.last_checkin === today) {
|
|
44
|
+
return `你今天已经签到过了哦~\n当前积分: ${user.points}\n连续签到: ${user.streak} 天`;
|
|
45
|
+
}
|
|
46
|
+
const isConsecutive = user.last_checkin === yesterdayStr();
|
|
47
|
+
const newStreak = isConsecutive ? Number(user.streak) + 1 : 1;
|
|
48
|
+
const base = randomInt(cfg.basePointsMin, cfg.basePointsMax);
|
|
49
|
+
const bonus = Math.min(newStreak * cfg.streakBonus, cfg.streakCap);
|
|
50
|
+
const earned = base + bonus;
|
|
51
|
+
const newPoints = Number(user.points || 0) + earned;
|
|
52
|
+
await M.update({
|
|
53
|
+
points: newPoints,
|
|
54
|
+
total_checkins: Number(user.total_checkins || 0) + 1,
|
|
55
|
+
streak: newStreak,
|
|
56
|
+
max_streak: Math.max(Number(user.max_streak || 0), newStreak),
|
|
57
|
+
last_checkin: today,
|
|
58
|
+
user_name: userName,
|
|
59
|
+
updated_at: ts(),
|
|
60
|
+
}).where({
|
|
61
|
+
user_id: userId,
|
|
62
|
+
context_type: ctxType,
|
|
63
|
+
context_id: ctxId,
|
|
64
|
+
});
|
|
65
|
+
const lines = [`签到成功!`, `基础积分: +${base}`];
|
|
66
|
+
if (bonus > 0)
|
|
67
|
+
lines.push(`连续奖励: +${bonus} (连续${newStreak}天)`);
|
|
68
|
+
lines.push(`本次获得: +${earned}`, `当前积分: ${newPoints}`);
|
|
69
|
+
return lines.join('\n');
|
|
70
|
+
}
|
|
71
|
+
export async function myPoints(input, runtime) {
|
|
72
|
+
const M = getCheckinModel(runtime?.db);
|
|
73
|
+
if (!M)
|
|
74
|
+
return '签到数据库尚未就绪';
|
|
75
|
+
const { id: userId } = resolveSender(input);
|
|
76
|
+
const { type: ctxType, id: ctxId } = resolveContextKey(input);
|
|
77
|
+
const rows = (await M.select().where({
|
|
78
|
+
user_id: userId,
|
|
79
|
+
context_type: ctxType,
|
|
80
|
+
context_id: ctxId,
|
|
81
|
+
}));
|
|
82
|
+
if (rows.length === 0)
|
|
83
|
+
return '你还没有签到记录哦,发送「checkin」开始吧!';
|
|
84
|
+
const u = rows[0];
|
|
85
|
+
const checkedToday = u.last_checkin === todayStr();
|
|
86
|
+
return [
|
|
87
|
+
`${u.user_name || '用户'} 的积分信息`,
|
|
88
|
+
`积分: ${u.points}`,
|
|
89
|
+
`累计签到: ${u.total_checkins} 天`,
|
|
90
|
+
`连续签到: ${u.streak} 天`,
|
|
91
|
+
`最长连续: ${u.max_streak} 天`,
|
|
92
|
+
checkedToday ? '今日已签到 ✓' : '今日未签到',
|
|
93
|
+
].join('\n');
|
|
94
|
+
}
|
|
95
|
+
export async function pointsRank(input, cfg, runtime) {
|
|
96
|
+
const M = getCheckinModel(runtime?.db);
|
|
97
|
+
if (!M)
|
|
98
|
+
return '签到数据库尚未就绪';
|
|
99
|
+
const { type: ctxType, id: ctxId } = resolveContextKey(input);
|
|
100
|
+
const all = (await M.select().where(ctxType === 'global'
|
|
101
|
+
? { context_type: 'global' }
|
|
102
|
+
: { context_type: ctxType, context_id: ctxId }));
|
|
103
|
+
if (all.length === 0)
|
|
104
|
+
return '还没有人签到过哦~';
|
|
105
|
+
const sorted = all.sort((a, b) => Number(b.points || 0) - Number(a.points || 0));
|
|
106
|
+
const top = sorted.slice(0, cfg.rankSize);
|
|
107
|
+
const medals = ['🥇', '🥈', '🥉'];
|
|
108
|
+
const lines = top.map((u, i) => {
|
|
109
|
+
const prefix = i < 3 ? medals[i] : `${i + 1}.`;
|
|
110
|
+
return `${prefix} ${u.user_name || u.user_id} — ${u.points}分 (${u.total_checkins}天)`;
|
|
111
|
+
});
|
|
112
|
+
const title = ctxType === 'group' ? '本群积分排行' : '全局积分排行';
|
|
113
|
+
const { id: userId } = resolveSender(input);
|
|
114
|
+
const myRank = sorted.findIndex((u) => u.user_id === userId);
|
|
115
|
+
const footer = myRank >= 0 ? `\n你的排名: 第${myRank + 1}名` : '';
|
|
116
|
+
return `${title}\n${lines.join('\n')}${footer}`;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=checkin-lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkin-lib.js","sourceRoot":"","sources":["../src/checkin-lib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,EAAE,EACF,YAAY,GACb,MAAM,qBAAqB,CAAC;AAG7B,KAAK,UAAU,eAAe,CAC5B,KAAU,EACV,MAAc,EACd,QAAgB,EAChB,OAAe,EACf,KAAa;IAEb,MAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC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C,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;QAC/C,OAAO,GAAG,MAAM,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,cAAc,IAAI,CAAC;IACvF,CAAC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxD,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5D,OAAO,GAAG,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC;AAClD,CAAC"}
|
package/lib/config.d.ts
CHANGED
|
@@ -1,68 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
/** 扁平 groupSuite 配置(单层字段,默认值覆盖多数场景) */
|
|
3
|
-
export declare const groupSuiteSchema: Schema<{
|
|
4
|
-
welcome?: string | undefined;
|
|
5
|
-
recallNotify?: boolean | undefined;
|
|
6
|
-
keywordReply?: boolean | undefined;
|
|
7
|
-
noticeAdapters?: string[] | undefined;
|
|
8
|
-
basePointsMin?: number | undefined;
|
|
9
|
-
basePointsMax?: number | undefined;
|
|
10
|
-
streakBonus?: number | undefined;
|
|
11
|
-
streakCap?: number | undefined;
|
|
12
|
-
rankSize?: number | undefined;
|
|
13
|
-
statsRetentionDays?: number | undefined;
|
|
14
|
-
analysisDays?: number | undefined;
|
|
15
|
-
autoAnalysisEnabled?: boolean | undefined;
|
|
16
|
-
autoAnalysisCron?: string | undefined;
|
|
17
|
-
analysisGroups?: string[] | undefined;
|
|
18
|
-
analysisGroupsBlock?: string[] | undefined;
|
|
19
|
-
analysisMaxMessages?: number | undefined;
|
|
20
|
-
teachMaxPerGroup?: number | undefined;
|
|
21
|
-
teachCooldownMs?: number | undefined;
|
|
22
|
-
teachAllowRegex?: boolean | undefined;
|
|
23
|
-
teachPageSize?: number | undefined;
|
|
24
|
-
}, {
|
|
25
|
-
welcome?: string | undefined;
|
|
26
|
-
recallNotify?: boolean | undefined;
|
|
27
|
-
keywordReply?: boolean | undefined;
|
|
28
|
-
noticeAdapters?: string[] | undefined;
|
|
29
|
-
basePointsMin?: number | undefined;
|
|
30
|
-
basePointsMax?: number | undefined;
|
|
31
|
-
streakBonus?: number | undefined;
|
|
32
|
-
streakCap?: number | undefined;
|
|
33
|
-
rankSize?: number | undefined;
|
|
34
|
-
statsRetentionDays?: number | undefined;
|
|
35
|
-
analysisDays?: number | undefined;
|
|
36
|
-
autoAnalysisEnabled?: boolean | undefined;
|
|
37
|
-
autoAnalysisCron?: string | undefined;
|
|
38
|
-
analysisGroups?: string[] | undefined;
|
|
39
|
-
analysisGroupsBlock?: string[] | undefined;
|
|
40
|
-
analysisMaxMessages?: number | undefined;
|
|
41
|
-
teachMaxPerGroup?: number | undefined;
|
|
42
|
-
teachCooldownMs?: number | undefined;
|
|
43
|
-
teachAllowRegex?: boolean | undefined;
|
|
44
|
-
teachPageSize?: number | undefined;
|
|
45
|
-
}>;
|
|
46
|
-
export type GroupSuiteConfig = {
|
|
47
|
-
welcome: string;
|
|
48
|
-
recallNotify: boolean;
|
|
1
|
+
export interface GroupSuiteConfig {
|
|
49
2
|
keywordReply: boolean;
|
|
50
|
-
noticeAdapters: string[];
|
|
51
3
|
basePointsMin: number;
|
|
52
4
|
basePointsMax: number;
|
|
53
5
|
streakBonus: number;
|
|
54
6
|
streakCap: number;
|
|
55
7
|
rankSize: number;
|
|
56
|
-
statsRetentionDays: number;
|
|
57
|
-
analysisDays: number;
|
|
58
|
-
autoAnalysisEnabled: boolean;
|
|
59
|
-
autoAnalysisCron: string;
|
|
60
|
-
analysisGroups: string[];
|
|
61
|
-
analysisGroupsBlock: string[];
|
|
62
|
-
analysisMaxMessages: number;
|
|
63
8
|
teachMaxPerGroup: number;
|
|
64
9
|
teachCooldownMs: number;
|
|
65
10
|
teachAllowRegex: boolean;
|
|
66
11
|
teachPageSize: number;
|
|
67
|
-
}
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_GROUP_SUITE_CONFIG: GroupSuiteConfig;
|
|
14
|
+
export declare function resolveGroupSuiteConfig(raw: Partial<GroupSuiteConfig> | undefined): GroupSuiteConfig;
|
|
68
15
|
//# sourceMappingURL=config.d.ts.map
|
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,0BAA0B,EAAE,gBAWxC,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,SAAS,GACzC,gBAAgB,CAKlB"}
|