koishi-plugin-chat-patch 0.8.2 → 0.8.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/lib/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare const filter = false;
5
5
  export declare const inject: {
6
6
  required: string[];
7
7
  };
8
- export declare const usage = "\n---\n\n\u5F00\u542F\u540E\uFF0C\u5373\u53EF\u5728koishi\u63A7\u5236\u53F0\u64CD\u4F5C\u673A\u5668\u4EBA\u6536\u53D1\u6D88\u606F\u5566\n\n\u6682\u65F6\u53EA\u652F\u6301\u63A5\u53D7\u56FE\u6587\u6D88\u606F / \u53D1\u9001\u6587\u5B57\u6D88\u606F\n\n---\n";
8
+ export declare const usage = "\n\n---\n\n\u5F00\u542F\u540E\uFF0C\u5373\u53EF\u5728koishi\u63A7\u5236\u53F0\u64CD\u4F5C\u673A\u5668\u4EBA\u6536\u53D1\u6D88\u606F\u5566\n\n\u6682\u65F6\u53EA\u652F\u6301\u63A5\u53D7\u56FE\u6587\u6D88\u606F / \u53D1\u9001\u6587\u5B57\u6D88\u606F\n\n---\n";
9
9
  export interface Config {
10
10
  loggerinfo: boolean;
11
11
  maxMessagesPerChannel: number;
package/lib/index.js CHANGED
@@ -1,10 +1,47 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
2
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name2 in all)
10
+ __defProp(target, name2, { get: all[name2], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
3
29
 
4
30
  // src/index.ts
5
- import { Schema } from "koishi";
6
- import path from "node:path";
7
- import fs from "node:fs";
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ Config: () => Config,
34
+ apply: () => apply,
35
+ filter: () => filter,
36
+ inject: () => inject,
37
+ name: () => name,
38
+ reusable: () => reusable,
39
+ usage: () => usage
40
+ });
41
+ module.exports = __toCommonJS(src_exports);
42
+ var import_koishi = require("koishi");
43
+ var import_node_path = __toESM(require("node:path"));
44
+ var import_node_fs = __toESM(require("node:fs"));
8
45
  var name = "chat-patch";
9
46
  var reusable = false;
10
47
  var filter = false;
@@ -12,6 +49,7 @@ var inject = {
12
49
  required: ["console"]
13
50
  };
14
51
  var usage = `
52
+
15
53
  ---
16
54
 
17
55
  开启后,即可在koishi控制台操作机器人收发消息啦
@@ -20,13 +58,13 @@ var usage = `
20
58
 
21
59
  ---
22
60
  `;
23
- var Config = Schema.intersect([
24
- Schema.object({
25
- maxMessagesPerChannel: Schema.number().default(500).description("每个群组最大保存消息数量").min(50).max(5e3),
26
- keepMessagesOnClear: Schema.number().default(0).description("手动清理历史记录时保留的消息数量").min(0).max(1e3),
27
- blockedPlatforms: Schema.array(Schema.object({
28
- platformName: Schema.string().description("平台名称或关键词"),
29
- exactMatch: Schema.boolean().default(false).description("完全匹配?如果关闭,包含关键词即屏蔽").default(true)
61
+ var Config = import_koishi.Schema.intersect([
62
+ import_koishi.Schema.object({
63
+ maxMessagesPerChannel: import_koishi.Schema.number().default(1e3).description("每个群组最大保存消息数量").min(50).max(5e3),
64
+ keepMessagesOnClear: import_koishi.Schema.number().default(0).description("手动清理历史记录时保留的消息数量").min(0).max(1e3),
65
+ blockedPlatforms: import_koishi.Schema.array(import_koishi.Schema.object({
66
+ platformName: import_koishi.Schema.string().description("平台名称或关键词"),
67
+ exactMatch: import_koishi.Schema.boolean().default(false).description("完全匹配?如果关闭,包含关键词即屏蔽").default(true)
30
68
  })).role("table").description("屏蔽的平台列表").default([
31
69
  {
32
70
  "platformName": "qq",
@@ -42,14 +80,14 @@ var Config = Schema.intersect([
42
80
  }
43
81
  ])
44
82
  }).description("基础设置"),
45
- Schema.object({
46
- chatContainerHeight: Schema.number().default(80).description("手机端使用的视口高度(防止文本输入框被挡住)").min(50).max(100),
47
- loggerinfo: Schema.boolean().default(false).description("日志调试模式").experimental()
83
+ import_koishi.Schema.object({
84
+ chatContainerHeight: import_koishi.Schema.number().default(80).description("手机端使用的视口高度(防止文本输入框被挡住)").min(50).max(100),
85
+ loggerinfo: import_koishi.Schema.boolean().default(false).description("日志调试模式").experimental()
48
86
  }).description("进阶设置")
49
87
  ]);
50
88
  async function apply(ctx, config) {
51
89
  const logger = ctx.logger("chat-patch");
52
- const dataFilePath = path.resolve(ctx.baseDir, "data", "chat-patch", "chat-data.json");
90
+ const dataFilePath = import_node_path.default.resolve(ctx.baseDir, "data", "chat-patch", "chat-data.json");
53
91
  const initialData = readChatDataFromFile();
54
92
  const cleanedData = cleanExcessMessages(initialData);
55
93
  const originalCount = Object.values(initialData.messages).reduce((total, msgs) => total + msgs.length, 0);
@@ -355,8 +393,8 @@ async function apply(ctx, config) {
355
393
  }
356
394
  });
357
395
  ctx.console.addEntry({
358
- dev: path.resolve(__dirname, "../client/index.ts"),
359
- prod: path.resolve(__dirname, "../dist")
396
+ dev: import_node_path.default.resolve(__dirname, "../client/index.ts"),
397
+ prod: import_node_path.default.resolve(__dirname, "../dist")
360
398
  });
361
399
  function logInfo(...args) {
362
400
  if (config.loggerinfo) {
@@ -385,16 +423,16 @@ async function apply(ctx, config) {
385
423
  }
386
424
  __name(isPlatformBlocked, "isPlatformBlocked");
387
425
  function ensureDataDir() {
388
- const dir = path.dirname(dataFilePath);
389
- if (!fs.existsSync(dir)) {
390
- fs.mkdirSync(dir, { recursive: true });
426
+ const dir = import_node_path.default.dirname(dataFilePath);
427
+ if (!import_node_fs.default.existsSync(dir)) {
428
+ import_node_fs.default.mkdirSync(dir, { recursive: true });
391
429
  }
392
430
  }
393
431
  __name(ensureDataDir, "ensureDataDir");
394
432
  function readChatDataFromFile() {
395
433
  try {
396
- if (fs.existsSync(dataFilePath)) {
397
- const jsonData = fs.readFileSync(dataFilePath, "utf8");
434
+ if (import_node_fs.default.existsSync(dataFilePath)) {
435
+ const jsonData = import_node_fs.default.readFileSync(dataFilePath, "utf8");
398
436
  const data = JSON.parse(jsonData);
399
437
  return {
400
438
  bots: data.bots || {},
@@ -426,7 +464,7 @@ async function apply(ctx, config) {
426
464
  ensureDataDir();
427
465
  data.lastSaveTime = Date.now();
428
466
  const jsonData = JSON.stringify(data, null, 2);
429
- fs.writeFileSync(dataFilePath, jsonData, "utf8");
467
+ import_node_fs.default.writeFileSync(dataFilePath, jsonData, "utf8");
430
468
  } catch (error) {
431
469
  logger.error("写入聊天数据失败:", error);
432
470
  }
@@ -583,7 +621,8 @@ async function apply(ctx, config) {
583
621
  __name(broadcastMessageEvent, "broadcastMessageEvent");
584
622
  }
585
623
  __name(apply, "apply");
586
- export {
624
+ // Annotate the CommonJS export names for ESM import in node:
625
+ 0 && (module.exports = {
587
626
  Config,
588
627
  apply,
589
628
  filter,
@@ -591,4 +630,4 @@ export {
591
630
  name,
592
631
  reusable,
593
632
  usage
594
- };
633
+ });
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "koishi-plugin-chat-patch",
3
3
  "description": "[<ruby>chat-patch<rp>(</rp><rt>点我预览效果</rt><rp>)</rp></ruby>](https://i0.hdslb.com/bfs/openplatform/71074dfc9e5256fc3333d8bd8478bec1af874046.png) 视奸小插件((bushi( (低性能警告)。手机端适配。灵感来自 chat 插件。",
4
- "version": "0.8.2",
5
- "type": "module",
4
+ "version": "0.8.3",
6
5
  "main": "lib/index.js",
6
+ "typings": "lib/index.d.ts",
7
7
  "files": [
8
8
  "client",
9
9
  "dist",
@@ -37,4 +37,4 @@
37
37
  "@koishijs/client": "^5.11.0",
38
38
  "koishi": "^4.16.0"
39
39
  }
40
- }
40
+ }