koishi-plugin-chat-analyse 0.6.0 → 0.6.1
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 +6 -4
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -861,11 +861,12 @@ var Analyse = class {
|
|
|
861
861
|
}
|
|
862
862
|
registerCommands(cmd) {
|
|
863
863
|
if (this.config.enableWordCloud) {
|
|
864
|
-
cmd.subcommand(".wordcloud", "生成词云"
|
|
864
|
+
cmd.subcommand(".wordcloud", "生成词云").usage("基于指定范围内的聊天记录生成词云图。").option("guild", "-g <guildId:string> 指定群组").option("user", "-u <user:string> 指定用户").option("all", "-a 全局").option("hours", "-h <hours:number> 指定时长", { fallback: 24 }).action(async ({ session, options }) => {
|
|
865
865
|
if (!this.isNlpReady) return "文本分析尚未就绪,请稍后再试";
|
|
866
866
|
const scope = await parseQueryScope(this.ctx, session, options);
|
|
867
867
|
if (scope.error) return scope.error;
|
|
868
|
-
const
|
|
868
|
+
const since = new Date(Date.now() - options.hours * import_koishi6.Time.hour);
|
|
869
|
+
const records = await this.ctx.database.select("analyse_cache").where({ uid: { $in: scope.uids }, timestamp: { $gte: since } }).project(["content"]).execute();
|
|
869
870
|
if (records.length === 0) return "暂无统计数据";
|
|
870
871
|
const allText = records.map((r) => r.content).join(" ");
|
|
871
872
|
const result = await this.nlp.process("zh", allText);
|
|
@@ -885,13 +886,14 @@ var Analyse = class {
|
|
|
885
886
|
});
|
|
886
887
|
}
|
|
887
888
|
if (this.config.enableVocabulary) {
|
|
888
|
-
cmd.subcommand(".vocabulary", "词汇排行"
|
|
889
|
+
cmd.subcommand(".vocabulary", "词汇排行").usage("根据不重复词汇量占总词汇量的比例进行排行。").option("guild", "-g <guildId:string> 指定群组").option("all", "-a 全局").option("hours", "-h <hours:number> 指定时长", { fallback: 24 }).action(async ({ session, options }) => {
|
|
889
890
|
if (!this.isNlpReady) return "文本分析尚未就绪,请稍后再试";
|
|
890
891
|
const scope = await parseQueryScope(this.ctx, session, options);
|
|
891
892
|
if (scope.error) return scope.error;
|
|
892
893
|
const users = await this.ctx.database.get("analyse_user", { uid: { $in: scope.uids } }, ["uid", "userName"]);
|
|
893
894
|
const userNameMap = new Map(users.map((u) => [u.uid, u.userName]));
|
|
894
|
-
const
|
|
895
|
+
const since = new Date(Date.now() - options.hours * import_koishi6.Time.hour);
|
|
896
|
+
const allRecords = await this.ctx.database.get("analyse_cache", { uid: { $in: scope.uids }, timestamp: { $gte: since } }, ["uid", "content"]);
|
|
895
897
|
if (allRecords.length === 0) return "暂无统计数据";
|
|
896
898
|
const messagesByUid = /* @__PURE__ */ new Map();
|
|
897
899
|
for (const record of allRecords) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chat-analyse",
|
|
3
3
|
"description": "聊天记录分析",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Yis_Rime <yis_rime@outlook.com>"
|
|
7
7
|
],
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"koishi": "4.18.8"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@nlpjs/basic": "^
|
|
43
|
-
"@nlpjs/lang-zh": "^
|
|
42
|
+
"@nlpjs/basic": "^4.26.1",
|
|
43
|
+
"@nlpjs/lang-zh": "^4.26.1"
|
|
44
44
|
}
|
|
45
45
|
}
|