koishi-plugin-chat-analyse 1.3.1 → 1.3.2
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/lib/index.js +46 -17
- package/package.json +1 -1
- package/readme.md +73 -61
package/lib/index.js
CHANGED
|
@@ -1527,7 +1527,7 @@ var Renderer = class {
|
|
|
1527
1527
|
border-bottom: 1px solid var(--border-color);
|
|
1528
1528
|
}
|
|
1529
1529
|
.title-text {
|
|
1530
|
-
font-size:
|
|
1530
|
+
font-size: 16px; font-weight: 600; color: var(--header-color);
|
|
1531
1531
|
margin: 0; text-align: center;
|
|
1532
1532
|
}
|
|
1533
1533
|
.stat-chip, .time-label {
|
|
@@ -1631,7 +1631,7 @@ var Renderer = class {
|
|
|
1631
1631
|
.main-table { border-collapse: collapse; width: 100%; }
|
|
1632
1632
|
.main-table th, .main-table td { padding: 9px 16px; vertical-align: middle; text-align: left; }
|
|
1633
1633
|
.main-table thead { border-bottom: 1px solid var(--border-color); }
|
|
1634
|
-
.main-table th { font-size: 12px; font-weight: 500; color: var(--sub-text-color); text-transform: uppercase; }
|
|
1634
|
+
.main-table th { font-size: 12px; font-weight: 500; color: var(--sub-text-color); text-transform: uppercase; white-space: nowrap; }
|
|
1635
1635
|
.main-table td { font-size: 14px; color: var(--text-color); }
|
|
1636
1636
|
.main-table tbody tr:nth-child(even) { background-color: var(--stripe-bg); }
|
|
1637
1637
|
.rank-cell, .count-cell, .date-cell, .percent-cell { text-align: right; white-space: nowrap; width: 1%; font-variant-numeric: tabular-nums; }
|
|
@@ -1843,11 +1843,11 @@ var Stat = class {
|
|
|
1843
1843
|
}
|
|
1844
1844
|
}, "handleAction");
|
|
1845
1845
|
if (this.config.enableCmdStat) {
|
|
1846
|
-
cmd.subcommand("cmdstat", "命令统计").usage("查询命令统计,可指定查询范围,默认当前群组。").option("user", "-u <user:string> 指定用户").option("guild", "-g <guildId:string> 指定群组").option("separate", "-s
|
|
1846
|
+
cmd.subcommand("cmdstat", "命令统计").usage("查询命令统计,可指定查询范围,默认当前群组。").option("user", "-u <user:string> 指定用户").option("guild", "-g <guildId:string> 指定群组").option("separate", "-p 分离子命令").option("sortByTime", "-s 以时间排序").option("all", "-a 全局统计").action(({ session, options }) => handleAction(session, (async () => {
|
|
1847
1847
|
const scope = await this.parseScope(session, options);
|
|
1848
1848
|
if (scope.error) return scope.error;
|
|
1849
1849
|
const query = scope.uids ? { uid: { $in: scope.uids } } : {};
|
|
1850
|
-
const stats = await this.ctx.database.select("analyse_cmd").where(query).groupBy("command", { count: /* @__PURE__ */ __name((row) => import_koishi3.$.sum(row.count), "count"), lastUsed: /* @__PURE__ */ __name((row) => import_koishi3.$.max(row.timestamp), "lastUsed") }).
|
|
1850
|
+
const stats = await this.ctx.database.select("analyse_cmd").where(query).groupBy("command", { count: /* @__PURE__ */ __name((row) => import_koishi3.$.sum(row.count), "count"), lastUsed: /* @__PURE__ */ __name((row) => import_koishi3.$.max(row.timestamp), "lastUsed") }).execute();
|
|
1851
1851
|
if (stats.length === 0) return "暂无统计数据";
|
|
1852
1852
|
let processedStats;
|
|
1853
1853
|
if (options.separate) {
|
|
@@ -1861,7 +1861,12 @@ var Stat = class {
|
|
|
1861
1861
|
if (stat.lastUsed > existing.lastUsed) existing.lastUsed = stat.lastUsed;
|
|
1862
1862
|
merged.set(mainCmd, existing);
|
|
1863
1863
|
}
|
|
1864
|
-
processedStats = Array.from(merged.entries()).map(([command, data]) => ({ ...data, command }))
|
|
1864
|
+
processedStats = Array.from(merged.entries()).map(([command, data]) => ({ ...data, command }));
|
|
1865
|
+
}
|
|
1866
|
+
if (options.sortByTime) {
|
|
1867
|
+
processedStats.sort((a, b) => b.lastUsed.getTime() - a.lastUsed.getTime());
|
|
1868
|
+
} else {
|
|
1869
|
+
processedStats.sort((a, b) => b.count - a.count);
|
|
1865
1870
|
}
|
|
1866
1871
|
const total = processedStats.reduce((sum, r) => sum + r.count, 0);
|
|
1867
1872
|
const list = processedStats.map((item) => [item.command, item.count, item.lastUsed]);
|
|
@@ -1870,15 +1875,23 @@ var Stat = class {
|
|
|
1870
1875
|
})()));
|
|
1871
1876
|
}
|
|
1872
1877
|
if (this.config.enableMsgStat) {
|
|
1873
|
-
cmd.subcommand("msgstat", "发言统计").usage("查询发言统计,可指定查询范围,默认当前群组。").option("user", "-u <user:string> 指定用户").option("guild", "-g <guildId:string> 指定群组").option("type", "-t <type:string> 指定类型").option("all", "-a 全局统计").action(({ session, options }) => handleAction(session, (async () => {
|
|
1878
|
+
cmd.subcommand("msgstat", "发言统计").usage("查询发言统计,可指定查询范围,默认当前群组。").option("user", "-u <user:string> 指定用户").option("guild", "-g <guildId:string> 指定群组").option("type", "-t <type:string> 指定类型").option("sortByTime", "-s 以时间排序").option("all", "-a 全局统计").action(({ session, options }) => handleAction(session, (async () => {
|
|
1874
1879
|
const scope = await this.parseScope(session, options);
|
|
1875
1880
|
if (scope.error) return scope.error;
|
|
1876
1881
|
const query = scope.uids ? { uid: { $in: scope.uids } } : {};
|
|
1877
1882
|
if (options.type) query.type = options.type;
|
|
1878
1883
|
const title = await generateTitle(this.ctx, scope.scopeDesc, { main: "发言", subtype: options.type });
|
|
1884
|
+
const applySort = /* @__PURE__ */ __name((stats2) => {
|
|
1885
|
+
if (options.sortByTime) {
|
|
1886
|
+
stats2.sort((a, b) => b.lastUsed.getTime() - a.lastUsed.getTime());
|
|
1887
|
+
} else {
|
|
1888
|
+
stats2.sort((a, b) => b.count - a.count);
|
|
1889
|
+
}
|
|
1890
|
+
}, "applySort");
|
|
1879
1891
|
if (options.user && options.guild) {
|
|
1880
|
-
const stats2 = await this.ctx.database.select("analyse_msg").where(query).groupBy("type", { count: /* @__PURE__ */ __name((row) => import_koishi3.$.sum(row.count), "count"), lastUsed: /* @__PURE__ */ __name((row) => import_koishi3.$.max(row.timestamp), "lastUsed") }).
|
|
1892
|
+
const stats2 = await this.ctx.database.select("analyse_msg").where(query).groupBy("type", { count: /* @__PURE__ */ __name((row) => import_koishi3.$.sum(row.count), "count"), lastUsed: /* @__PURE__ */ __name((row) => import_koishi3.$.max(row.timestamp), "lastUsed") }).execute();
|
|
1881
1893
|
if (stats2.length === 0) return "暂无统计数据";
|
|
1894
|
+
applySort(stats2);
|
|
1882
1895
|
const total2 = stats2.reduce((sum, r) => sum + r.count, 0);
|
|
1883
1896
|
const list2 = stats2.map((item) => [item.type, item.count, item.lastUsed]);
|
|
1884
1897
|
return this.renderer.renderList({ title, time: /* @__PURE__ */ new Date(), total: total2, list: list2 }, ["类型", "条数", "最后发言"]);
|
|
@@ -1886,20 +1899,29 @@ var Stat = class {
|
|
|
1886
1899
|
if (options.user) {
|
|
1887
1900
|
const userRecords = await this.ctx.database.get("analyse_user", { uid: { $in: scope.uids } });
|
|
1888
1901
|
const uidToChannelMap = new Map(userRecords.map((u) => [u.uid, u.channelName || u.channelId]));
|
|
1889
|
-
const stats2 = await this.ctx.database.select("analyse_msg").where(query).groupBy("uid", { count: /* @__PURE__ */ __name((row) => import_koishi3.$.sum(row.count), "count"), lastUsed: /* @__PURE__ */ __name((row) => import_koishi3.$.max(row.timestamp), "lastUsed") }).
|
|
1902
|
+
const stats2 = await this.ctx.database.select("analyse_msg").where(query).groupBy("uid", { count: /* @__PURE__ */ __name((row) => import_koishi3.$.sum(row.count), "count"), lastUsed: /* @__PURE__ */ __name((row) => import_koishi3.$.max(row.timestamp), "lastUsed") }).execute();
|
|
1890
1903
|
if (stats2.length === 0) return "暂无统计数据";
|
|
1904
|
+
applySort(stats2);
|
|
1891
1905
|
const total2 = stats2.reduce((sum, r) => sum + r.count, 0);
|
|
1892
1906
|
const list2 = stats2.map((item) => [uidToChannelMap.get(item.uid) || `未知群组`, item.count, item.lastUsed]);
|
|
1893
1907
|
return this.renderer.renderList({ title, time: /* @__PURE__ */ new Date(), total: total2, list: list2 }, ["群组", "条数", "最后发言"]);
|
|
1894
1908
|
}
|
|
1895
|
-
const stats = await this.ctx.database.select("analyse_msg").where(query).groupBy("uid", { count: /* @__PURE__ */ __name((row) => import_koishi3.$.sum(row.count), "count"), lastUsed: /* @__PURE__ */ __name((row) => import_koishi3.$.max(row.timestamp), "lastUsed") }).
|
|
1909
|
+
const stats = await this.ctx.database.select("analyse_msg").where(query).groupBy("uid", { count: /* @__PURE__ */ __name((row) => import_koishi3.$.sum(row.count), "count"), lastUsed: /* @__PURE__ */ __name((row) => import_koishi3.$.max(row.timestamp), "lastUsed") }).execute();
|
|
1896
1910
|
if (stats.length === 0) return "暂无统计数据";
|
|
1911
|
+
applySort(stats);
|
|
1897
1912
|
const allUids = stats.map((s) => s.uid);
|
|
1898
|
-
const
|
|
1899
|
-
const
|
|
1913
|
+
const userNameMap = /* @__PURE__ */ new Map();
|
|
1914
|
+
const BATCH_SIZE2 = 4096;
|
|
1915
|
+
for (let i = 0; i < allUids.length; i += BATCH_SIZE2) {
|
|
1916
|
+
const batchUids = allUids.slice(i, i + BATCH_SIZE2);
|
|
1917
|
+
const users = await this.ctx.database.get("analyse_user", { uid: { $in: batchUids } }, ["uid", "userName"]);
|
|
1918
|
+
for (const user of users) {
|
|
1919
|
+
userNameMap.set(user.uid, user.userName);
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1900
1922
|
const total = stats.reduce((sum, r) => sum + r.count, 0);
|
|
1901
1923
|
const list = stats.map((item) => [userNameMap.get(item.uid) || `UID ${item.uid}`, item.count, item.lastUsed]);
|
|
1902
|
-
return this.renderer.renderList({ title, time: /* @__PURE__ */ new Date(), total, list }, ["用户", "
|
|
1924
|
+
return this.renderer.renderList({ title, time: /* @__PURE__ */ new Date(), total, list }, ["用户", "条数", "最后发言"]);
|
|
1903
1925
|
})()));
|
|
1904
1926
|
}
|
|
1905
1927
|
if (this.config.enableRankStat) {
|
|
@@ -1931,15 +1953,22 @@ var Stat = class {
|
|
|
1931
1953
|
const stats = await this.ctx.database.select("analyse_rank").where(query).groupBy("uid", { count: /* @__PURE__ */ __name((row) => import_koishi3.$.sum(row.count), "count") }).orderBy("count", "desc").execute();
|
|
1932
1954
|
if (stats.length === 0) return "暂无统计数据";
|
|
1933
1955
|
const allUids = stats.map((s) => s.uid);
|
|
1934
|
-
const
|
|
1935
|
-
const
|
|
1956
|
+
const userNameMap = /* @__PURE__ */ new Map();
|
|
1957
|
+
const BATCH_SIZE2 = 4096;
|
|
1958
|
+
for (let i = 0; i < allUids.length; i += BATCH_SIZE2) {
|
|
1959
|
+
const batchUids = allUids.slice(i, i + BATCH_SIZE2);
|
|
1960
|
+
const users = await this.ctx.database.get("analyse_user", { uid: { $in: batchUids } }, ["uid", "userName"]);
|
|
1961
|
+
for (const user of users) {
|
|
1962
|
+
userNameMap.set(user.uid, user.userName);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1936
1965
|
const total = stats.reduce((sum, r) => sum + r.count, 0);
|
|
1937
1966
|
const list = stats.map((r) => [userNameMap.get(r.uid) || `UID ${r.uid}`, r.count, total > 0 ? `${(r.count / total * 100).toFixed(2)}%` : "0.00%"]);
|
|
1938
|
-
return this.renderer.renderList({ title, time: /* @__PURE__ */ new Date(), total, list }, ["用户", "
|
|
1967
|
+
return this.renderer.renderList({ title, time: /* @__PURE__ */ new Date(), total, list }, ["用户", "条数", "占比"]);
|
|
1939
1968
|
})()));
|
|
1940
1969
|
}
|
|
1941
1970
|
if (this.config.enableActivity) {
|
|
1942
|
-
cmd.subcommand("activity", "活跃统计").usage("查询活跃统计,可指定查询范围,默认当前群组。").option("user", "-u <user:string> 指定用户").option("guild", "-g <guildId:string> 指定群组").option("duration", "-n <units:number> 指定时长", { fallback: 24 }).option("offset", "-o <units:number> 指定偏移").option("days", "-d
|
|
1971
|
+
cmd.subcommand("activity", "活跃统计").usage("查询活跃统计,可指定查询范围,默认当前群组。").option("user", "-u <user:string> 指定用户").option("guild", "-g <guildId:string> 指定群组").option("duration", "-n <units:number> 指定时长", { fallback: 24 }).option("offset", "-o <units:number> 指定偏移").option("days", "-d 以天为粒度").option("all", "-a 全局统计").action(({ session, options }) => handleAction(session, (async () => {
|
|
1943
1972
|
const scope = await this.parseScope(session, options);
|
|
1944
1973
|
if (scope.error) return scope.error;
|
|
1945
1974
|
const timeUnit = options.days ? import_koishi3.Time.day : import_koishi3.Time.hour;
|
|
@@ -2101,7 +2130,7 @@ var Data = class {
|
|
|
2101
2130
|
return "数据恢复失败";
|
|
2102
2131
|
}
|
|
2103
2132
|
});
|
|
2104
|
-
cmd.subcommand(".clear", "清除数据", { authority: 4 }).usage(`清除指定统计数据,可精确控制清除范围。`).option("table", "-t <table:string> 指定表名").option("guild", "-g <guildId:string> 指定群组").option("user", "-u <user:string> 指定用户").option("days", "-d <days:number> 指定天数").option("command", "-c <command:string> 指定命令").option("all", "-a
|
|
2133
|
+
cmd.subcommand(".clear", "清除数据", { authority: 4 }).usage(`清除指定统计数据,可精确控制清除范围。`).option("table", "-t <table:string> 指定表名").option("guild", "-g <guildId:string> 指定群组").option("user", "-u <user:string> 指定用户").option("days", "-d <days:number> 指定天数").option("command", "-c <command:string> 指定命令").option("all", "-a 全部清除").action(async ({ options }) => {
|
|
2105
2134
|
if (Object.keys(options).length === 0) return "请指定清除条件";
|
|
2106
2135
|
if (options.table && !ALL_TABLES.includes(options.table)) return `表名 ${options.table} 无效`;
|
|
2107
2136
|
try {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -8,98 +8,103 @@
|
|
|
8
8
|
|
|
9
9
|
- **高效数据收集**:采用异步、高并发和缓存机制,在不影响机器人性能的前提下,精确高效地收集聊天数据。
|
|
10
10
|
- **多维度统计分析**:
|
|
11
|
-
- **命令统计** (`cmdstat`)
|
|
12
|
-
- **发言统计** (`msgstat`)
|
|
13
|
-
- **发言排行** (`rankstat`)
|
|
14
|
-
- **活跃度分析** (`activity`)
|
|
11
|
+
- **命令统计** (`cmdstat`):追踪指令使用频率,了解用户最常用的功能,支持按次数或时间排序。
|
|
12
|
+
- **发言统计** (`msgstat`):分析用户发言类型与数量,掌握核心用户群体,支持按条数或时间排序。
|
|
13
|
+
- **发言排行** (`rankstat`):生成指定时间范围内的用户发言排行榜,发掘群聊中的“龙王”。
|
|
14
|
+
- **活跃度分析** (`activity`):以小时或天为单位,生成直观的周期性活跃度图表,洞察社群活跃时段。
|
|
15
15
|
- **高级文本分析**:
|
|
16
|
-
- **词云生成** (`wordcloud`):基于聊天记录,利用 Jieba
|
|
17
|
-
- **提及追踪** (`whoatme`)
|
|
16
|
+
- **词云生成** (`wordcloud`):基于聊天记录,利用 Jieba 分词生成热门话题词云图,快速了解近期热点。
|
|
17
|
+
- **提及追踪** (`whoatme`):轻松查询谁在什么时候因为什么内容提及了您,不再错过重要信息。
|
|
18
18
|
- **强大的数据管理**:
|
|
19
|
-
- **备份与恢复** (
|
|
20
|
-
- **精确清理** (
|
|
19
|
+
- **备份与恢复** (`.backup`/`.restore`):一键备份所有统计数据至本地,并可随时恢复,保障数据安全。
|
|
20
|
+
- **精确清理** (`.clear`):提供多维度的筛选条件(如按时间、用户、群组、命令),精确清理不再需要的数据。
|
|
21
21
|
- **精美图表渲染**:借助 Puppeteer 服务,将复杂的统计数据渲染成美观、易读的图片,方便在聊天中分享。
|
|
22
22
|
- **高度可配置**:所有功能模块均可独立开关,并可自定义数据保留时长等核心参数,以适应不同场景的需求。
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
## ⚙️ 前置服务
|
|
25
25
|
|
|
26
26
|
本插件依赖以下 Koishi 服务,请确保您已正确安装并启用了它们:
|
|
27
27
|
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
28
|
+
- **`database`**:用于存储所有统计分析数据。
|
|
29
|
+
- **`puppeteer`**:用于将统计结果渲染成图片。
|
|
30
|
+
- **`cron`**:用于执行数据定时清理任务。
|
|
31
31
|
|
|
32
32
|
## 📝 使用说明
|
|
33
33
|
|
|
34
|
-
所有功能都集成在主指令 `analyse`
|
|
34
|
+
所有功能都集成在主指令 `analyse` 之下。大部分指令不加任何参数时,默认查询**当前群组**的数据。
|
|
35
35
|
|
|
36
36
|
### 指令列表
|
|
37
37
|
|
|
38
38
|
| 指令 | 别名 | 描述 | 选项 |
|
|
39
|
-
|
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `analyse.list` | 列出数据 | 列出已记录的频道和命令 | (无) |
|
|
47
|
-
| `analyse.backup` | 备份数据 | 将所有数据备份为本地 JSON 文件 | (无) |
|
|
48
|
-
| `analyse.restore` | 恢复数据 | 从本地 JSON 文件恢复数据 | (无) |
|
|
49
|
-
| `analyse.clear` | 清除数据 | 根据条件精确清理数据 | `-t
|
|
39
|
+
| :--- | :--- | :--- | :--- |
|
|
40
|
+
| `cmdstat` | 命令统计 | 查询命令使用情况,展示方式根据选项变化 | `-u`, `-g`, `-a`, `-p`, `-s` |
|
|
41
|
+
| `msgstat` | 发言统计 | 查询用户发言统计,展示方式根据选项变化 | `-u`, `-g`, `-a`, `-t`, `-s` |
|
|
42
|
+
| `rankstat` | 发言排行 | 查询指定时间内的发言排行,展示方式根据选项变化 | `-u`, `-g`, `-a`, `-t`, `-n`, `-o` |
|
|
43
|
+
| `activity` | 活跃统计 | 查询周期性活跃度图表 | `-u`, `-g`, `-a`, `-d`, `-n`, `-o` |
|
|
44
|
+
| `wordcloud` | 生成词云 | 基于聊天记录生成词云图 | `-u`, `-g`, `-t` |
|
|
45
|
+
| `whoatme` | 谁提及我 | 查看最近谁提及了您 | (无) |
|
|
46
|
+
| `analyse.list` | 列出数据 | (管理) 列出已记录的频道和命令 | (无) |
|
|
47
|
+
| `analyse.backup` | 备份数据 | (管理) 将所有数据备份为本地 JSON 文件 | (无) |
|
|
48
|
+
| `analyse.restore` | 恢复数据 | (管理) 从本地 JSON 文件恢复数据 | (无) |
|
|
49
|
+
| `analyse.clear` | 清除数据 | (管理) 根据条件精确清理数据 | `-t`, `-g`, `-u`, `-d`, `-c`, `-a` |
|
|
50
|
+
|
|
51
|
+
**通用选项说明:**
|
|
52
|
+
|
|
53
|
+
- `-u, --user <user>`: 指定用户 (可使用 @ 或 userID)。
|
|
54
|
+
- `-g, --guild <guild>`: 指定群组 (需使用群组ID)。
|
|
55
|
+
- `-a, --all`: 查询全局数据。
|
|
50
56
|
|
|
51
57
|
### 🔎 指令详解
|
|
52
58
|
|
|
53
|
-
#### `
|
|
59
|
+
#### `cmdstat` (命令统计)
|
|
54
60
|
|
|
55
|
-
- **`
|
|
56
|
-
- **`
|
|
57
|
-
- **`
|
|
58
|
-
- **`
|
|
59
|
-
- **`
|
|
60
|
-
- **选项 `-
|
|
61
|
+
- **`cmdstat`**: 查询**当前群组**所有用户的命令统计。
|
|
62
|
+
- **`cmdstat -u @用户`**: 查询**指定用户**在**所有群组**的命令统计。
|
|
63
|
+
- **`cmdstat -g <群组ID>`**: 查询**指定群组**所有用户的命令统计。
|
|
64
|
+
- **`cmdstat -u @用户 -g <群组ID>`**: 查询**指定用户**在**指定群组**的命令统计。
|
|
65
|
+
- **`cmdstat -a`**: 查询**全局**(所有用户+所有群组)的命令统计。
|
|
66
|
+
- **选项 `-p, --separate`**: 分离展示子命令,不合并到主命令。
|
|
67
|
+
- **选项 `-s, --sortByTime`**: 按最后使用时间降序排序(默认按使用次数)。
|
|
61
68
|
|
|
62
|
-
#### `
|
|
69
|
+
#### `msgstat` (发言统计)
|
|
63
70
|
|
|
64
|
-
- **`
|
|
65
|
-
- **`
|
|
66
|
-
- **`
|
|
67
|
-
- **`
|
|
68
|
-
- **`
|
|
69
|
-
- **选项 `-t <类型>`**:
|
|
71
|
+
- **`msgstat`**: 查询**当前群组**的发言统计 (按**用户**展示)。
|
|
72
|
+
- **`msgstat -u @用户`**: 查询**指定用户**的发言统计 (按**群组**展示)。
|
|
73
|
+
- **`msgstat -g <群组ID>`**: 查询**指定群组**的发言统计 (按**用户**展示)。
|
|
74
|
+
- **`msgstat -u @用户 -g <群组ID>`**: 查询**指定用户**在**指定群组**的发言统计 (按**消息类型**展示)。
|
|
75
|
+
- **`msgstat -a`**: 查询**全局**发言统计 (按**用户**展示)。
|
|
76
|
+
- **选项 `-t, --type <类型>`**: 筛选指定消息类型 (`text`, `face`, `image` 等),不改变上述展示逻辑。
|
|
77
|
+
- **选项 `-s, --sortByTime`**: 按最后发言时间降序排序(默认按发言条数)。
|
|
70
78
|
|
|
71
|
-
#### `
|
|
79
|
+
#### `rankstat` (发言排行)
|
|
72
80
|
|
|
73
|
-
- **`
|
|
74
|
-
- **`
|
|
75
|
-
- **`
|
|
76
|
-
- **`
|
|
77
|
-
-
|
|
78
|
-
- **选项 `-
|
|
79
|
-
- **选项 `-
|
|
80
|
-
- **选项 `-t <类型>`**: 筛选指定消息类型,不改变上述展示逻辑。
|
|
81
|
+
- **`rankstat`**: 查询**当前群组**的发言排行 (按**用户**排名)。
|
|
82
|
+
- **`rankstat -u @用户`**: 查询**指定用户**的发言排行 (按**群组**排名)。
|
|
83
|
+
- **`rankstat -u @用户 -g <群组ID>`**: 查询**指定用户**在**指定群组**的发言排行 (按**消息类型**排名)。
|
|
84
|
+
- **`rankstat -a`**: 查询**全局**发言排行 (按**用户**排名)。
|
|
85
|
+
- **选项 `-n, --duration <小时数>`**: 指定查询范围的时长,默认为 `24`。
|
|
86
|
+
- **选项 `-o, --offset <小时数>`"**: 指定查询结束时间的偏移量(从现在往前推的小时数),默认为 `0`。
|
|
87
|
+
- **选项 `-t, --type <类型>`**: 筛选指定消息类型。
|
|
81
88
|
|
|
82
|
-
#### `
|
|
89
|
+
#### `activity` (活跃统计)
|
|
83
90
|
|
|
84
|
-
- **`
|
|
85
|
-
- **`
|
|
86
|
-
- **`
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
- **选项 `-n
|
|
90
|
-
- **选项 `-o <数值>`**: 指定查询结束时间的偏移量,默认为 `0`。
|
|
91
|
-
- **选项 `-d`**: 将 `-n` 和 `-o` 的单位从**小时**切换为**天**。
|
|
91
|
+
- **`activity`**: 查询**当前群组**的活跃度。
|
|
92
|
+
- **`activity -a`**: 查询**全局**活跃度。
|
|
93
|
+
- **`activity -u @用户 -g <群组ID>`**: 查询**指定用户**在**指定群组**的活跃度。
|
|
94
|
+
- **选项 `-n, --duration <数值>`**: 指定查询范围的时长,默认为 `24`。
|
|
95
|
+
- **选项 `-o, --offset <数值>`**: 指定查询结束时间的偏移量,默认为 `0`。
|
|
96
|
+
- **选项 `-d, --days`**: 将 `-n` 和 `-o` 的单位从**小时**切换为**天**。
|
|
92
97
|
|
|
93
|
-
|
|
98
|
+
## 🔧 配置项
|
|
94
99
|
|
|
95
100
|
您可以在插件的配置页面中调整以下选项:
|
|
96
101
|
|
|
97
|
-
|
|
102
|
+
### 杂项配置
|
|
98
103
|
|
|
99
104
|
- `enableListener`: **启用消息监听**。总开关,关闭后插件将停止所有数据收集。 (默认: `true`)
|
|
100
|
-
- `enableDataIO`: **启用数据管理**。控制 `.backup`, `.restore`, `.clear`, `.list`
|
|
105
|
+
- `enableDataIO`: **启用数据管理**。控制 `.backup`, `.restore`, `.clear`, `.list` 等管理指令的可用性。 (默认: `true`)
|
|
101
106
|
|
|
102
|
-
|
|
107
|
+
### 基础分析配置
|
|
103
108
|
|
|
104
109
|
- `enableCmdStat`: **启用命令统计**。 (默认: `true`)
|
|
105
110
|
- `enableMsgStat`: **启用消息统计**。 (默认: `true`)
|
|
@@ -109,8 +114,15 @@
|
|
|
109
114
|
- `enableWhoAt`: **启用提及记录**。 (默认: `true`)
|
|
110
115
|
- `atRetentionDays`: **提及保留天数**。`whoatme` 数据的保留时长(天),`0` 为永久保留。 (默认: `3`)
|
|
111
116
|
|
|
112
|
-
|
|
117
|
+
### 高级分析配置
|
|
113
118
|
|
|
114
119
|
- `enableOriRecord`: **启用原始记录**。是否记录原始消息内容以供词云等功能使用。 (默认: `true`)
|
|
115
120
|
- `enableWordCloud`: **启用词云生成**。 (默认: `true`)
|
|
116
121
|
- `cacheRetentionDays`: **原始记录保留天数**。原始消息记录的保留时长(天),`0` 为永久保留。 (默认: `30`)
|
|
122
|
+
|
|
123
|
+
## 📌 注意事项
|
|
124
|
+
|
|
125
|
+
1. **Puppeteer 配置**:本插件的图片渲染强依赖 `puppeteer` 服务。请确保您已正确安装并配置了该服务,包括正确设置了可执行文件路径(如有需要)。渲染失败通常与此有关。
|
|
126
|
+
2. **初始数据积累**:插件启用后,需要一段时间来收集数据。因此,在刚安装插件后立即查询可能不会返回任何结果。
|
|
127
|
+
3. **数据清理**:插件会根据您设置的保留天数自动清理过期数据。对于手动清理 (`.clear`),请谨慎操作,特别是 `-a` (清除全部) 选项,该操作不可逆。
|
|
128
|
+
4. **性能考虑**:尽管插件经过优化,但在极大规模的机器人(数千群聊)上,长时间积累的大量数据仍可能对数据库造成压力。建议定期使用 `.clear -d <天数>` 清理过旧的数据。
|