koishi-plugin-starfx-bot 0.6.0 → 0.8.0

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
@@ -1,8 +1,9 @@
1
- import { Context, h, Logger, Schema, Session } from 'koishi';
1
+ import { Context, Logger, Schema } from 'koishi';
2
2
  export declare const name = "starfx-bot";
3
3
  export declare let baseDir: string;
4
4
  export declare let assetsDir: string;
5
5
  export declare const starfxLogger: Logger;
6
+ export declare const repeatContextMap: Map<string, [string, number]>;
6
7
  export interface Config {
7
8
  openLock: boolean;
8
9
  openSold: boolean;
@@ -12,6 +13,10 @@ export interface Config {
12
13
  atNotSayProperty: number;
13
14
  atNotSayOtherProperty: number;
14
15
  record: boolean;
16
+ openRepeat: boolean;
17
+ minRepeatTimes: number;
18
+ repeatPossibility: number;
19
+ saveArchive: boolean;
15
20
  replyBot: string;
16
21
  iLoveYou: boolean;
17
22
  }
@@ -20,10 +25,14 @@ export declare const Config: Schema<Schemastery.ObjectS<{
20
25
  openSold: Schema<boolean, boolean>;
21
26
  bangdreamBorder: Schema<boolean, boolean>;
22
27
  record: Schema<boolean, boolean>;
28
+ saveArchive: Schema<boolean, boolean>;
23
29
  atNotSay: Schema<boolean, boolean>;
24
30
  atNotSayProperty: Schema<number, number>;
25
31
  atNotSayOther: Schema<boolean, boolean>;
26
32
  atNotSayOtherProperty: Schema<number, number>;
33
+ openRepeat: Schema<boolean, boolean>;
34
+ minRepeatTimes: Schema<number, number>;
35
+ repeatPossibility: Schema<number, number>;
27
36
  iLoveYou: Schema<boolean, boolean>;
28
37
  replyBot: Schema<"关闭" | "无需at" | "必须at", "关闭" | "无需at" | "必须at">;
29
38
  }>, {
@@ -31,35 +40,16 @@ export declare const Config: Schema<Schemastery.ObjectS<{
31
40
  openSold: boolean;
32
41
  bangdreamBorder: boolean;
33
42
  record: boolean;
43
+ saveArchive: boolean;
34
44
  atNotSay: boolean;
35
45
  atNotSayProperty: number;
36
46
  atNotSayOther: boolean;
37
47
  atNotSayOtherProperty: number;
48
+ openRepeat: boolean;
49
+ minRepeatTimes: number;
50
+ repeatPossibility: number;
38
51
  iLoveYou: boolean;
39
52
  replyBot: "关闭" | "无需at" | "必须at";
40
53
  } & import("cosmokit").Dict>;
41
54
  export declare const usage = "<h5>StarFreedomX\u7684\u81EA\u7528\u63D2\u4EF6 \u653E\u4E86\u4E00\u4E9B\u5C0F\u529F\u80FD</h5>\n ";
42
55
  export declare function apply(ctx: Context, cfg: Config): void;
43
- export declare function addRecord(ctx: Context, gid: string, avatarUrl: string): Promise<string>;
44
- export declare function getRecord(gid: string): Promise<string>;
45
- export declare function getImageSrc(session: Session, param: string, option?: {
46
- number?: boolean;
47
- img?: boolean;
48
- at?: boolean;
49
- noParam?: boolean;
50
- quote?: boolean;
51
- }): Promise<string>;
52
- export declare function handleBanGDreamConfig(ctx: Context, options: any): Promise<{
53
- color: string;
54
- band: string;
55
- starType: string;
56
- starNum: number;
57
- border: string;
58
- }>;
59
- export declare function drawLock(ctx: Context, baseImage: string): Promise<"发生错误" | "输入无效" | h>;
60
- /**
61
- * "卖掉了"绘图函数
62
- * @param ctx
63
- * @param baseImage
64
- */
65
- export declare function drawSold(ctx: Context, baseImage: string): Promise<"发生错误" | "输入无效" | h>;
package/lib/index.js CHANGED
@@ -40,128 +40,35 @@ var require_zh_CN = __commonJS({
40
40
  // src/index.ts
41
41
  var src_exports = {};
42
42
  __export(src_exports, {
43
- Config: () => Config,
44
- addRecord: () => addRecord,
43
+ Config: () => Config2,
45
44
  apply: () => apply,
46
45
  assetsDir: () => assetsDir,
47
46
  baseDir: () => baseDir,
48
- drawLock: () => drawLock,
49
- drawSold: () => drawSold,
50
- getImageSrc: () => getImageSrc,
51
- getRecord: () => getRecord,
52
- handleBanGDreamConfig: () => handleBanGDreamConfig,
53
47
  name: () => name,
48
+ repeatContextMap: () => repeatContextMap,
54
49
  starfxLogger: () => starfxLogger,
55
50
  usage: () => usage
56
51
  });
57
52
  module.exports = __toCommonJS(src_exports);
53
+ var import_koishi2 = require("koishi");
54
+ var fs2 = __toESM(require("fs"));
55
+
56
+ // src/utils.ts
58
57
  var import_koishi = require("koishi");
58
+ var import_fs = __toESM(require("fs"));
59
+ var import_node_path = __toESM(require("node:path"));
59
60
  var import_sharp = __toESM(require("sharp"));
60
- var fs = __toESM(require("fs"));
61
61
  var import_jimp = require("jimp");
62
- var import_node_path = __toESM(require("node:path"));
63
- var name = "starfx-bot";
64
- var baseDir;
65
- var assetsDir;
66
- var starfxLogger = new import_koishi.Logger("starfx-bot");
67
- var Config = import_koishi.Schema.intersect([
68
- import_koishi.Schema.object({
69
- openLock: import_koishi.Schema.boolean().default(true).description("开启明日方舟封印功能"),
70
- openSold: import_koishi.Schema.boolean().default(true).description('开启闲鱼"卖掉了"功能'),
71
- bangdreamBorder: import_koishi.Schema.boolean().default(true).description("开启BanG Dream!边框功能"),
72
- record: import_koishi.Schema.boolean().default(true).description("开启群语录功能"),
73
- atNotSay: import_koishi.Schema.boolean().default(true).description("开启‘艾特我又不说话’功能"),
74
- atNotSayProperty: import_koishi.Schema.number().role("slider").min(0).max(1).step(0.01).default(0.5).description("'艾特我又不说话'回复概率"),
75
- atNotSayOther: import_koishi.Schema.boolean().default(true).description("开启‘艾特他又不说话’功能"),
76
- atNotSayOtherProperty: import_koishi.Schema.number().role("slider").min(0).max(1).step(0.01).default(0.5).description("'艾特他又不说话'回复概率"),
77
- iLoveYou: import_koishi.Schema.boolean().default(true).description("开启‘我喜欢你’功能"),
78
- replyBot: import_koishi.Schema.union(["关闭", "无需at", "必须at"]).default("无需at").description("回复‘我才不是机器人!’功能")
79
- })
80
- ]);
81
- var usage = `<h5>StarFreedomX的自用插件 放了一些小功能</h5>
82
- `;
83
- function apply(ctx, cfg) {
84
- ctx.i18n.define("zh-CN", require_zh_CN());
85
- baseDir = ctx.baseDir;
86
- assetsDir = `${ctx.baseDir}/data/starfx-bot/assets`;
87
- initAssets();
88
- if (cfg.openLock) {
89
- ctx.command("封印 [param]").action(async ({ session }, param) => {
90
- return await drawLock(ctx, await getImageSrc(session, param));
91
- });
92
- }
93
- if (cfg.openSold) {
94
- ctx.command("卖掉了 [param]").action(async ({ session }, param) => {
95
- return await drawSold(ctx, await getImageSrc(session, param));
96
- });
97
- }
98
- if (cfg.bangdreamBorder) {
99
- ctx.command("bangdreamborder [param]").alias("bdbd").option("starNum", "-n <starNum: number>").option("color", "-c <color: string>").option("train", "-t <train: string>").option("band", "-b <band: string>").action(async ({ session, options }, param) => {
100
- session.send("图片处理中请稍等...");
101
- console.log(param);
102
- const drawConfig = await handleBanGDreamConfig(ctx, options);
103
- const imageBase64 = await drawBanGDream(await getImageSrc(session, param), drawConfig);
104
- return import_koishi.h.image(imageBase64);
105
- });
106
- }
107
- if (cfg.record) {
108
- ctx.command("投稿 [param]").action(async ({ session }, param) => {
109
- const imageSrc = await getImageSrc(
110
- session,
111
- param,
112
- {
113
- img: true,
114
- at: false,
115
- quote: true,
116
- noParam: false,
117
- number: false
118
- }
119
- );
120
- if (!imageSrc) {
121
- return "请发送带图片的指令消息或引用图片消息进行投稿";
122
- }
123
- return await addRecord(ctx, session.gid.replace(":", "_"), imageSrc);
124
- });
125
- }
126
- ctx.middleware(async (session, next) => {
127
- const elements = session.elements;
128
- await atNotSayReply(cfg, session, elements);
129
- await replyBot(cfg, session, elements);
130
- await iLoveYou(cfg, session, elements);
131
- if (cfg.record && session.content?.startsWith("语录")) {
132
- const filepath = await getRecord(session.gid.replace(":", "_"));
133
- starfxLogger.info(`send record: ${filepath}`);
134
- if (!filepath) return "暂无语录呢";
135
- return import_koishi.h.image(filepath);
136
- }
137
- return next();
138
- });
139
- function initAssets() {
140
- const fromUrl = `${__dirname}/../assets`;
141
- assetsDir = `${ctx.baseDir}/data/starfx-bot/assets`;
142
- if (!fs.existsSync(fromUrl)) return;
143
- if (!fs.readdirSync(fromUrl)?.length) return;
144
- if (!fs.existsSync(assetsDir)) {
145
- fs.mkdirSync(assetsDir, { recursive: true });
146
- }
147
- fs.cpSync(fromUrl, assetsDir, { recursive: true, force: true });
148
- if (process.env.NODE_ENV !== "development") {
149
- fs.rmSync(fromUrl, { recursive: true });
150
- }
151
- }
152
- __name(initAssets, "initAssets");
153
- }
154
- __name(apply, "apply");
155
62
  async function addRecord(ctx, gid, avatarUrl) {
156
63
  const recordDir = `${assetsDir}/record/${gid}`;
157
64
  const avatarBuffer = await ctx.http.get(avatarUrl, { responseType: "arraybuffer" });
158
65
  saveImage(avatarBuffer, recordDir);
159
- return "添加成功!";
66
+ return "投稿收到啦";
160
67
  }
161
68
  __name(addRecord, "addRecord");
162
69
  async function getRecord(gid) {
163
70
  const recordDir = `${assetsDir}/record/${gid}`;
164
- const files = fs.readdirSync(recordDir);
71
+ const files = import_fs.default.readdirSync(recordDir);
165
72
  return files?.length ? import_node_path.default.join(recordDir, import_koishi.Random.pick(files)) : null;
166
73
  }
167
74
  __name(getRecord, "getRecord");
@@ -173,9 +80,9 @@ function getTodayPrefix() {
173
80
  return `${yyyy}${mm}${dd}`;
174
81
  }
175
82
  __name(getTodayPrefix, "getTodayPrefix");
176
- function getNextSequenceNumber(directory, prefix) {
177
- const files = fs.existsSync(directory) ? fs.readdirSync(directory) : [];
178
- const regex = new RegExp(`^${prefix}-(\\d+)\\.jpg$`);
83
+ function getNextSequenceNumber(directory, prefix, suffix = "jpg") {
84
+ const files = import_fs.default.existsSync(directory) ? import_fs.default.readdirSync(directory) : [];
85
+ const regex = new RegExp(`^${prefix}-(\\d+)\\.${suffix}$`);
179
86
  let maxNum = 0;
180
87
  files.forEach((file) => {
181
88
  const match = file.match(regex);
@@ -189,16 +96,18 @@ function getNextSequenceNumber(directory, prefix) {
189
96
  return maxNum + 1;
190
97
  }
191
98
  __name(getNextSequenceNumber, "getNextSequenceNumber");
192
- function saveImage(arrayBuffer, directory) {
193
- const prefix = getTodayPrefix();
194
- const seq = getNextSequenceNumber(directory, prefix);
195
- const filename = `${prefix}-${seq}.jpg`;
99
+ function saveImage(arrayBuffer, directory, filename) {
100
+ if (!filename) {
101
+ const prefix = getTodayPrefix();
102
+ const seq = getNextSequenceNumber(directory, prefix);
103
+ filename = `${prefix}-${seq}.jpg`;
104
+ }
196
105
  const filepath = import_node_path.default.join(directory, filename);
197
- if (!fs.existsSync(directory)) {
198
- fs.mkdirSync(directory, { recursive: true });
106
+ if (!import_fs.default.existsSync(directory)) {
107
+ import_fs.default.mkdirSync(directory, { recursive: true });
199
108
  }
200
109
  const buffer = Buffer.from(arrayBuffer);
201
- fs.writeFileSync(filepath, buffer);
110
+ import_fs.default.writeFileSync(filepath, buffer);
202
111
  console.log(`已保存图片:${filepath}`);
203
112
  }
204
113
  __name(saveImage, "saveImage");
@@ -232,7 +141,7 @@ async function getImageSrc(session, param, option) {
232
141
  return "";
233
142
  }
234
143
  __name(getImageSrc, "getImageSrc");
235
- async function handleBanGDreamConfig(ctx, options) {
144
+ async function handleBanGDreamConfig(options) {
236
145
  const types = {
237
146
  cool: ["cool", "blue", "蓝", "蓝色"],
238
147
  powerful: ["powerful", "red", "红", "红色"],
@@ -260,7 +169,7 @@ async function handleBanGDreamConfig(ctx, options) {
260
169
  starNum: 0,
261
170
  border: ""
262
171
  };
263
- if (options.color) {
172
+ if (options?.color) {
264
173
  for (const [type, aliases] of Object.entries(types)) {
265
174
  if (aliases.includes(options.color.toLowerCase())) {
266
175
  drawConfig.color = type;
@@ -268,7 +177,7 @@ async function handleBanGDreamConfig(ctx, options) {
268
177
  }
269
178
  }
270
179
  }
271
- if (options.band) {
180
+ if (options?.band) {
272
181
  for (const [band, aliases] of Object.entries(bands)) {
273
182
  if (aliases.includes(options.band.toLowerCase())) {
274
183
  drawConfig.band = band;
@@ -276,9 +185,9 @@ async function handleBanGDreamConfig(ctx, options) {
276
185
  }
277
186
  }
278
187
  }
279
- const starNum = options.starNum ? parseInt(options.starNum) : 0;
188
+ const starNum = options?.starNum ? parseInt(options.starNum) : 0;
280
189
  drawConfig.starNum = starNum > 0 && starNum < 10 ? starNum : 0;
281
- if (options.train) {
190
+ if (options?.train) {
282
191
  for (const [train, aliases] of Object.entries(trains)) {
283
192
  if (aliases.includes(options.train.toLowerCase())) {
284
193
  drawConfig.starType = train;
@@ -441,19 +350,144 @@ async function drawBanGDream(avatar, inputOptions) {
441
350
  return `data:image/png;base64,${(await image.getBuffer("image/jpeg")).toString("base64")}`;
442
351
  }
443
352
  __name(drawBanGDream, "drawBanGDream");
353
+
354
+ // src/index.ts
355
+ var name = "starfx-bot";
356
+ var baseDir;
357
+ var assetsDir;
358
+ var starfxLogger = new import_koishi2.Logger("starfx-bot");
359
+ var repeatContextMap = /* @__PURE__ */ new Map();
360
+ var Config2 = import_koishi2.Schema.intersect([
361
+ import_koishi2.Schema.object({
362
+ openLock: import_koishi2.Schema.boolean().default(true).description("开启明日方舟封印功能"),
363
+ openSold: import_koishi2.Schema.boolean().default(true).description('开启闲鱼"卖掉了"功能'),
364
+ bangdreamBorder: import_koishi2.Schema.boolean().default(true).description("开启BanG Dream!边框功能"),
365
+ record: import_koishi2.Schema.boolean().default(true).description("开启群语录功能"),
366
+ saveArchive: import_koishi2.Schema.boolean().default(false).description("开启入典功能").hidden(),
367
+ atNotSay: import_koishi2.Schema.boolean().default(true).description("开启‘艾特我又不说话’功能"),
368
+ atNotSayProperty: import_koishi2.Schema.number().role("slider").min(0).max(1).step(0.01).default(0.5).description("'艾特我又不说话'回复概率"),
369
+ atNotSayOther: import_koishi2.Schema.boolean().default(true).description("开启‘艾特他又不说话’功能"),
370
+ atNotSayOtherProperty: import_koishi2.Schema.number().role("slider").min(0).max(1).step(0.01).default(0.5).description("'艾特他又不说话'回复概率"),
371
+ openRepeat: import_koishi2.Schema.boolean().default(true).description("开启复读功能"),
372
+ minRepeatTimes: import_koishi2.Schema.number().default(2).description("最少重复次数"),
373
+ repeatPossibility: import_koishi2.Schema.number().role("slider").min(0).max(1).step(0.01).default(0.3).description("复读发生概率"),
374
+ iLoveYou: import_koishi2.Schema.boolean().default(true).description("开启‘我喜欢你’功能"),
375
+ replyBot: import_koishi2.Schema.union(["关闭", "无需at", "必须at"]).default("无需at").description("回复‘我才不是机器人!’功能")
376
+ })
377
+ ]);
378
+ var usage = `<h5>StarFreedomX的自用插件 放了一些小功能</h5>
379
+ `;
380
+ function apply(ctx, cfg) {
381
+ ctx.i18n.define("zh-CN", require_zh_CN());
382
+ baseDir = ctx.baseDir;
383
+ assetsDir = `${ctx.baseDir}/data/starfx-bot/assets`;
384
+ initAssets();
385
+ if (cfg.openLock) {
386
+ ctx.command("封印 [param]").action(async ({ session }, param) => {
387
+ return await drawLock(ctx, await getImageSrc(session, param));
388
+ });
389
+ }
390
+ if (cfg.openSold) {
391
+ ctx.command("卖掉了 [param]").action(async ({ session }, param) => {
392
+ return await drawSold(ctx, await getImageSrc(session, param));
393
+ });
394
+ }
395
+ if (cfg.bangdreamBorder) {
396
+ ctx.command("bangdreamborder [param]").alias("bdbd").option("starNum", "-n <starNum: number>").option("color", "-c <color: string>").option("train", "-t <train: string>").option("band", "-b <band: string>").action(async ({ session, options }, param) => {
397
+ const p = session.send("图片处理中请稍等...");
398
+ console.log(param);
399
+ const drawConfig = await handleBanGDreamConfig(options);
400
+ const imageBase64 = await drawBanGDream(await getImageSrc(session, param), drawConfig);
401
+ await p;
402
+ return import_koishi2.h.image(imageBase64);
403
+ });
404
+ }
405
+ if (cfg.record) {
406
+ ctx.command("投稿 [param]").action(async ({ session }, param) => {
407
+ const imageSrc = await getImageSrc(
408
+ session,
409
+ param,
410
+ {
411
+ img: true,
412
+ at: false,
413
+ quote: true,
414
+ noParam: false,
415
+ number: false
416
+ }
417
+ );
418
+ if (!imageSrc) {
419
+ return "请发送带图片的指令消息或引用图片消息进行投稿";
420
+ }
421
+ return await addRecord(ctx, session.gid.replace(":", "_"), imageSrc);
422
+ });
423
+ ctx.command("语录").action(async ({ session }) => {
424
+ const filepath = await getRecord(session.gid.replace(":", "_"));
425
+ starfxLogger.info(`send record: ${filepath}`);
426
+ if (!filepath) return "暂无语录呢";
427
+ return import_koishi2.h.image(filepath);
428
+ });
429
+ }
430
+ if (cfg.saveArchive) {
431
+ ctx.command("入典 [param]").action(async ({ session }, param) => {
432
+ const imageSrc = await getImageSrc(
433
+ session,
434
+ param,
435
+ {
436
+ img: true,
437
+ at: false,
438
+ quote: true,
439
+ noParam: false,
440
+ number: false
441
+ }
442
+ );
443
+ if (!imageSrc) {
444
+ return "请发送带图片的指令消息或引用图片消息进行投稿";
445
+ }
446
+ });
447
+ }
448
+ ctx.middleware(async (session, next) => {
449
+ const elements = session.elements;
450
+ if (cfg.openRepeat) {
451
+ const content = session.content;
452
+ const ctxArr = repeatContextMap.get(session.gid);
453
+ if (!ctxArr || ctxArr[0] !== content) {
454
+ repeatContextMap.set(session.gid, [content, 1]);
455
+ } else {
456
+ if (ctxArr[1] !== -1 && ++ctxArr[1] >= cfg.minRepeatTimes && import_koishi2.Random.bool(cfg.repeatPossibility)) {
457
+ ctxArr[1] = -1;
458
+ await session.send(content);
459
+ }
460
+ }
461
+ }
462
+ await atNotSayReply(cfg, session, elements);
463
+ await replyBot(cfg, session, elements);
464
+ await iLoveYou(cfg, session, elements);
465
+ return next();
466
+ });
467
+ function initAssets() {
468
+ const fromUrl = `${__dirname}/../assets`;
469
+ assetsDir = `${ctx.baseDir}/data/starfx-bot/assets`;
470
+ if (!fs2.existsSync(fromUrl)) return;
471
+ if (!fs2.readdirSync(fromUrl)?.length) return;
472
+ if (!fs2.existsSync(assetsDir)) {
473
+ fs2.mkdirSync(assetsDir, { recursive: true });
474
+ }
475
+ fs2.cpSync(fromUrl, assetsDir, { recursive: true, force: true });
476
+ if (process.env.NODE_ENV !== "development") {
477
+ fs2.rmSync(fromUrl, { recursive: true });
478
+ }
479
+ }
480
+ __name(initAssets, "initAssets");
481
+ }
482
+ __name(apply, "apply");
444
483
  // Annotate the CommonJS export names for ESM import in node:
445
484
  0 && (module.exports = {
446
485
  Config,
447
- addRecord,
448
486
  apply,
449
487
  assetsDir,
450
488
  baseDir,
451
- drawLock,
452
- drawSold,
453
- getImageSrc,
454
- getRecord,
455
- handleBanGDreamConfig,
456
489
  name,
490
+ repeatContextMap,
457
491
  starfxLogger,
458
492
  usage
459
493
  });
package/lib/utils.d.ts ADDED
@@ -0,0 +1,122 @@
1
+ import { Context, h, Session } from "koishi";
2
+ import sharp from "sharp";
3
+ import { Config } from "./index";
4
+ /**
5
+ * 添加投稿
6
+ * @param ctx Context
7
+ * @param gid 当前群组的gid,注意需要把:替换为_等其它字符
8
+ * @param avatarUrl 图片的Url网络地址
9
+ */
10
+ export declare function addRecord(ctx: Context, gid: string, avatarUrl: string): Promise<string>;
11
+ /**
12
+ * 从当前群组的语录中随机获取一张,同样需要把gid的:替换为_
13
+ * @param gid
14
+ * @return 图片的文件路径
15
+ */
16
+ export declare function getRecord(gid: string): Promise<string>;
17
+ /**
18
+ * 返回当前日期,格式为yyyyMMdd
19
+ * @return 日期
20
+ */
21
+ export declare function getTodayPrefix(): string;
22
+ /**
23
+ * 获取当前目录下特定`前缀+{数字}.后缀名`的{数字}的最大值+1
24
+ * @param directory 检索的目录
25
+ * @param prefix 前缀
26
+ * @param suffix 后缀(可选,默认jpg)
27
+ * @return 当前被使用的序列最大值+1
28
+ */
29
+ export declare function getNextSequenceNumber(directory: string, prefix: string, suffix?: string): number;
30
+ /**
31
+ * 保存图片到本地
32
+ * @param arrayBuffer 传入的buffer,注意是arraybuffer
33
+ * @param directory 保存的目录
34
+ * @param filename 文件名 默认为yyyyMMdd-{num}.jpg
35
+ */
36
+ export declare function saveImage(arrayBuffer: ArrayBuffer, directory: string, filename?: string): void;
37
+ /**
38
+ * 通过session、param判断获取图片的url
39
+ * @param session 当前会话的Session
40
+ * @param param 当前指令传入的param
41
+ * @param option 获取选项
42
+ *
43
+ * @param option.number 通过发送消息param的数字转换为qq头像
44
+ * @param option.img 是否检测发送消息中携带的字符串
45
+ * @param option.at 是否检测发送消息所at对象返回qq头像
46
+ * @param option.noParam 是否在没有参数时使用自身头像
47
+ * @param option.quote 是否包括引用的消息
48
+ * @return 图片url
49
+ */
50
+ export declare function getImageSrc(session: Session, param: string, option?: {
51
+ number?: boolean;
52
+ img?: boolean;
53
+ at?: boolean;
54
+ noParam?: boolean;
55
+ quote?: boolean;
56
+ }): Promise<string>;
57
+ /**
58
+ * 将options的参数转换为drawBanGDreamBorder的配置
59
+ * @param options
60
+ * @return 适用于边框绘制的参数
61
+ */
62
+ export declare function handleBanGDreamConfig(options: any): Promise<{
63
+ color: string;
64
+ band: string;
65
+ starType: string;
66
+ starNum: number;
67
+ border: string;
68
+ }>;
69
+ /**
70
+ * "封印"绘图功能
71
+ * @param ctx Context
72
+ * @param baseImage 被封印的图片url
73
+ * @return 画完的图片 h对象
74
+ */
75
+ export declare function drawLock(ctx: Context, baseImage: string): Promise<"发生错误" | "输入无效" | h>;
76
+ /**
77
+ * "卖掉了"绘图函数
78
+ * @param ctx
79
+ * @param baseImage
80
+ * @return 画完的图片 h对象
81
+ */
82
+ export declare function drawSold(ctx: Context, baseImage: string): Promise<"发生错误" | "输入无效" | h>;
83
+ /**
84
+ * 从url下载图片并返回sharp对象
85
+ * @param ctx Context
86
+ * @param url 要下载的图片url
87
+ * @return sharp对象或数字 -2代表url为空 -1代表下载异常
88
+ */
89
+ export declare function getImageFromUrl(ctx: Context, url: string): Promise<-2 | -1 | sharp.Sharp>;
90
+ /**
91
+ * at不说话功能实现
92
+ * @param cfg Koishi插件配置
93
+ * @param session 当前会话Session对象
94
+ * @param elements 当前消息elements
95
+ */
96
+ export declare function atNotSayReply(cfg: Config, session: Session, elements: h[]): Promise<void>;
97
+ /**
98
+ * “我才不是机器人”回复功能
99
+ * @param cfg Koishi插件配置
100
+ * @param session 当前会话Session
101
+ * @param elements 当前消息elements
102
+ */
103
+ export declare function replyBot(cfg: Config, session: Session, elements: h[]): Promise<void>;
104
+ /**
105
+ * 回复“我喜欢你”功能
106
+ * @param cfg Koishi插件配置
107
+ * @param session 当前会话Session
108
+ * @param elements 当前消息elements
109
+ */
110
+ export declare function iLoveYou(cfg: Config, session: Session, elements: h[]): Promise<void>;
111
+ /**
112
+ * BanG Dream!边框绘制功能
113
+ * @param avatar 要绘制的底图
114
+ * @param inputOptions 输入参数,接受color band starType starNum border
115
+ */
116
+ export declare function drawBanGDream(avatar: string, inputOptions?: {
117
+ color: string;
118
+ band: string;
119
+ starType: string;
120
+ starNum: number;
121
+ border: string;
122
+ }): Promise<string>;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "contributors": [
5
5
  "StarFreedomX <starfreedomx@outlook.com>"
6
6
  ],
7
- "version": "0.6.0",
7
+ "version": "0.8.0",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
10
10
  "files": [
package/readme.md CHANGED
@@ -11,20 +11,31 @@ StarFreedomX机器人的小功能,自用
11
11
  * 艾特我/他又不说话
12
12
  * 我才不是机器人!
13
13
  * 我也喜欢你!
14
+ * BanG Dream!边框绘制
15
+ * 群语录
16
+ * 复读
17
+
18
+ # List to Do
19
+
20
+ * 为每种功能添加单独的群聊控制开关
21
+ * 修改BanG Dream!边框的绘制为使用sharp,加快速度
22
+ * 增加入典功能
14
23
 
15
24
  # 更新日志
16
- | 版本 | 更新日志 |
17
- |---------|-----------------------------|
18
- | `0.0.1` | 加入封印功能 |
19
- | `0.1.0` | 加入"卖掉了"功能 |
20
- | `0.2.0` | 加入"艾特我又不说话"回复功能 |
21
- | `0.3.0` | 加入"我喜欢你"和"我才不是机器人!"回复功能 |
22
- | `0.3.3` | 修订添加"我才不是机器人"是否需要at |
23
- | `0.3.4` | 分离"艾特我/他又不说话"的两个选项为单独的开关 |
24
- | `0.3.5` | 修复丢失的assets |
25
- | `0.3.6` | 添加"艾特我/他又不说话"的概率配置 |
26
- | `0.4.0` | 更改处理库为sharp |
27
- | `0.4.1` | 修复sharp处理w>h的图报错的bug |
28
- | `0.5.0` | 加入BanG Dream!边框功能 |
29
- | `0.5.1` | 对边框的参数做了限定,修复了异常输入导致的报错 |
30
- | `0.6.0` | 加入群语录功能,修复一处bangdream绘制的bug |
25
+ | 版本 | 更新日志 |
26
+ |---------|-------------------------------|
27
+ | `0.0.1` | 加入封印功能 |
28
+ | `0.1.0` | 加入"卖掉了"功能 |
29
+ | `0.2.0` | 加入"艾特我又不说话"回复功能 |
30
+ | `0.3.0` | 加入"我喜欢你"和"我才不是机器人!"回复功能 |
31
+ | `0.3.3` | 修订添加"我才不是机器人"是否需要at |
32
+ | `0.3.4` | 分离"艾特我/他又不说话"的两个选项为单独的开关 |
33
+ | `0.3.5` | 修复丢失的assets |
34
+ | `0.3.6` | 添加"艾特我/他又不说话"的概率配置 |
35
+ | `0.4.0` | 更改处理库为sharp |
36
+ | `0.4.1` | 修复sharp处理w>h的图报错的bug |
37
+ | `0.5.0` | 加入BanG Dream!边框功能 |
38
+ | `0.5.1` | 对边框的参数做了限定,修复了异常输入导致的报错 |
39
+ | `0.6.0` | 加入群语录功能,修复一处bangdream绘制的bug |
40
+ | `0.7.0` | 加入复读功能 |
41
+ | `0.8.0` | 将各个工具函数封装在utils.ts中,更改语录的触发方式 |