koishi-plugin-chat-analyse 1.0.6 → 1.0.8
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 +5 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -302,8 +302,9 @@ var Renderer = class {
|
|
|
302
302
|
*/
|
|
303
303
|
async htmlToImage(fullHtmlContent) {
|
|
304
304
|
const page = await this.ctx.puppeteer.page();
|
|
305
|
+
page.on("console", (msg) => this.ctx.logger.info(`[Puppeteer Console] ${msg.text()}`));
|
|
305
306
|
try {
|
|
306
|
-
await page.setViewport({ width:
|
|
307
|
+
await page.setViewport({ width: 720, height: 1080, deviceScaleFactor: 2 });
|
|
307
308
|
await page.setContent(fullHtmlContent, { waitUntil: "networkidle0" });
|
|
308
309
|
const { width, height } = await page.evaluate(() => ({
|
|
309
310
|
width: document.body.scrollWidth,
|
|
@@ -315,6 +316,7 @@ var Renderer = class {
|
|
|
315
316
|
this.ctx.logger.error("图片渲染失败:", error);
|
|
316
317
|
return null;
|
|
317
318
|
} finally {
|
|
319
|
+
page.off("console", (msg) => this.ctx.logger.info(`[Puppeteer Console] ${msg.text()}`));
|
|
318
320
|
await page.close().catch((e) => this.ctx.logger.error("关闭页面失败:", e));
|
|
319
321
|
}
|
|
320
322
|
}
|
|
@@ -596,7 +598,7 @@ var Stat = class {
|
|
|
596
598
|
}));
|
|
597
599
|
}
|
|
598
600
|
if (this.config.enableRankStat) {
|
|
599
|
-
cmd.subcommand("rankstat", "发言排行").usage("查询发言排行,可指定查询范围,默认当前群组。").option("guild", "-g <guildId:string> 指定群组").option("type", "-t <type:string> 指定类型").option("hours", "-
|
|
601
|
+
cmd.subcommand("rankstat", "发言排行").usage("查询发言排行,可指定查询范围,默认当前群组。").option("guild", "-g <guildId:string> 指定群组").option("type", "-t <type:string> 指定类型").option("hours", "-o <hours:number> 指定时长", { fallback: 24 }).option("all", "-a 全局").action(createHandler(async (scope, options) => {
|
|
600
602
|
const { hours, type } = options;
|
|
601
603
|
const since = new Date(Date.now() - hours * import_koishi3.Time.hour);
|
|
602
604
|
const query = { uid: { $in: scope.uids }, timestamp: { $gte: since } };
|
|
@@ -928,6 +930,7 @@ var Analyse = class {
|
|
|
928
930
|
const wordCounts = words.reduce((map, word) => map.set(word, (map.get(word) || 0) + 1), /* @__PURE__ */ new Map());
|
|
929
931
|
const wordList = Array.from(wordCounts.entries()).sort((a, b) => b[1] - a[1]);
|
|
930
932
|
const title = await generateTitle(this.ctx, scope.scopeDesc, { main: "词云" });
|
|
933
|
+
this.ctx.logger.info(`准备渲染词云(词数:${wordList.length}):${JSON.stringify(wordList.slice(0, 10))}`);
|
|
931
934
|
const result = await this.renderer.renderWordCloud({ title, time: /* @__PURE__ */ new Date(), words: wordList });
|
|
932
935
|
if (typeof result === "string") return result;
|
|
933
936
|
if (Array.isArray(result) && result.length > 0) {
|