koishi-plugin-chat-analyse 1.4.1 → 1.4.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 +7 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2281,10 +2281,9 @@ var Data = class {
|
|
|
2281
2281
|
}
|
|
2282
2282
|
});
|
|
2283
2283
|
if (this.config.enableOriRecord) {
|
|
2284
|
-
cmd.subcommand(".view
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
if (isNaN(since.getTime())) return "时间格式无效";
|
|
2284
|
+
cmd.subcommand(".view [time:string]", "查询消息记录", { authority: 4 }).usage("查询指定时间点之前的消息记录,默认查询当前群组。").option("user", "-u <user:string> 指定用户").option("guild", "-g <guildId:string> 指定群组").option("count", "-n <count:number> 指定数量", { fallback: 100 }).action(async ({ session, options }, time) => {
|
|
2285
|
+
const until = time ? new Date(time) : /* @__PURE__ */ new Date();
|
|
2286
|
+
if (time && isNaN(until.getTime())) return "时间格式无效";
|
|
2288
2287
|
try {
|
|
2289
2288
|
const userQuery = {};
|
|
2290
2289
|
if (!options.guild && !options.user) {
|
|
@@ -2299,12 +2298,13 @@ var Data = class {
|
|
|
2299
2298
|
const uids = usersInScope.map((u) => u.uid);
|
|
2300
2299
|
const records = await this.ctx.database.get("analyse_cache", {
|
|
2301
2300
|
uid: { $in: uids },
|
|
2302
|
-
timestamp: { $
|
|
2301
|
+
timestamp: { $lte: until }
|
|
2303
2302
|
}, {
|
|
2304
|
-
sort: { timestamp: "
|
|
2305
|
-
limit:
|
|
2303
|
+
sort: { timestamp: "desc" },
|
|
2304
|
+
limit: options.count
|
|
2306
2305
|
});
|
|
2307
2306
|
if (records.length === 0) return "暂无统计数据";
|
|
2307
|
+
records.reverse();
|
|
2308
2308
|
const recordUids = [...new Set(records.map((r) => r.uid))];
|
|
2309
2309
|
const users = await this.ctx.database.get("analyse_user", { uid: { $in: recordUids } }, ["uid", "userName", "userId"]);
|
|
2310
2310
|
const userInfoMap = new Map(users.map((u) => [u.uid, { name: u.userName, id: u.userId }]));
|