koishi-plugin-starfx-bot 0.7.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,4 +1,4 @@
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;
@@ -16,6 +16,7 @@ export interface Config {
16
16
  openRepeat: boolean;
17
17
  minRepeatTimes: number;
18
18
  repeatPossibility: number;
19
+ saveArchive: boolean;
19
20
  replyBot: string;
20
21
  iLoveYou: boolean;
21
22
  }
@@ -24,6 +25,7 @@ export declare const Config: Schema<Schemastery.ObjectS<{
24
25
  openSold: Schema<boolean, boolean>;
25
26
  bangdreamBorder: Schema<boolean, boolean>;
26
27
  record: Schema<boolean, boolean>;
28
+ saveArchive: Schema<boolean, boolean>;
27
29
  atNotSay: Schema<boolean, boolean>;
28
30
  atNotSayProperty: Schema<number, number>;
29
31
  atNotSayOther: Schema<boolean, boolean>;
@@ -38,6 +40,7 @@ export declare const Config: Schema<Schemastery.ObjectS<{
38
40
  openSold: boolean;
39
41
  bangdreamBorder: boolean;
40
42
  record: boolean;
43
+ saveArchive: boolean;
41
44
  atNotSay: boolean;
42
45
  atNotSayProperty: number;
43
46
  atNotSayOther: boolean;
@@ -50,26 +53,3 @@ export declare const Config: Schema<Schemastery.ObjectS<{
50
53
  } & import("cosmokit").Dict>;
51
54
  export declare const usage = "<h5>StarFreedomX\u7684\u81EA\u7528\u63D2\u4EF6 \u653E\u4E86\u4E00\u4E9B\u5C0F\u529F\u80FD</h5>\n ";
52
55
  export declare function apply(ctx: Context, cfg: Config): void;
53
- export declare function addRecord(ctx: Context, gid: string, avatarUrl: string): Promise<string>;
54
- export declare function getRecord(gid: string): Promise<string>;
55
- export declare function getImageSrc(session: Session, param: string, option?: {
56
- number?: boolean;
57
- img?: boolean;
58
- at?: boolean;
59
- noParam?: boolean;
60
- quote?: boolean;
61
- }): Promise<string>;
62
- export declare function handleBanGDreamConfig(ctx: Context, options: any): Promise<{
63
- color: string;
64
- band: string;
65
- starType: string;
66
- starNum: number;
67
- border: string;
68
- }>;
69
- export declare function drawLock(ctx: Context, baseImage: string): Promise<"发生错误" | "输入无效" | h>;
70
- /**
71
- * "卖掉了"绘图函数
72
- * @param ctx
73
- * @param baseImage
74
- */
75
- export declare function drawSold(ctx: Context, baseImage: string): Promise<"发生错误" | "输入无效" | h>;
package/lib/index.js CHANGED
@@ -40,146 +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,
54
48
  repeatContextMap: () => repeatContextMap,
55
49
  starfxLogger: () => starfxLogger,
56
50
  usage: () => usage
57
51
  });
58
52
  module.exports = __toCommonJS(src_exports);
53
+ var import_koishi2 = require("koishi");
54
+ var fs2 = __toESM(require("fs"));
55
+
56
+ // src/utils.ts
59
57
  var import_koishi = require("koishi");
58
+ var import_fs = __toESM(require("fs"));
59
+ var import_node_path = __toESM(require("node:path"));
60
60
  var import_sharp = __toESM(require("sharp"));
61
- var fs = __toESM(require("fs"));
62
61
  var import_jimp = require("jimp");
63
- var import_node_path = __toESM(require("node:path"));
64
- var name = "starfx-bot";
65
- var baseDir;
66
- var assetsDir;
67
- var starfxLogger = new import_koishi.Logger("starfx-bot");
68
- var repeatContextMap = /* @__PURE__ */ new Map();
69
- var Config = import_koishi.Schema.intersect([
70
- import_koishi.Schema.object({
71
- openLock: import_koishi.Schema.boolean().default(true).description("开启明日方舟封印功能"),
72
- openSold: import_koishi.Schema.boolean().default(true).description('开启闲鱼"卖掉了"功能'),
73
- bangdreamBorder: import_koishi.Schema.boolean().default(true).description("开启BanG Dream!边框功能"),
74
- record: import_koishi.Schema.boolean().default(true).description("开启群语录功能"),
75
- atNotSay: import_koishi.Schema.boolean().default(true).description("开启‘艾特我又不说话’功能"),
76
- atNotSayProperty: import_koishi.Schema.number().role("slider").min(0).max(1).step(0.01).default(0.5).description("'艾特我又不说话'回复概率"),
77
- atNotSayOther: import_koishi.Schema.boolean().default(true).description("开启‘艾特他又不说话’功能"),
78
- atNotSayOtherProperty: import_koishi.Schema.number().role("slider").min(0).max(1).step(0.01).default(0.5).description("'艾特他又不说话'回复概率"),
79
- openRepeat: import_koishi.Schema.boolean().default(true).description("开启复读功能"),
80
- minRepeatTimes: import_koishi.Schema.number().default(2).description("最少重复次数"),
81
- repeatPossibility: import_koishi.Schema.number().role("slider").min(0).max(1).step(0.01).default(0.3).description("复读发生概率"),
82
- iLoveYou: import_koishi.Schema.boolean().default(true).description("开启‘我喜欢你’功能"),
83
- replyBot: import_koishi.Schema.union(["关闭", "无需at", "必须at"]).default("无需at").description("回复‘我才不是机器人!’功能")
84
- })
85
- ]);
86
- var usage = `<h5>StarFreedomX的自用插件 放了一些小功能</h5>
87
- `;
88
- function apply(ctx, cfg) {
89
- ctx.i18n.define("zh-CN", require_zh_CN());
90
- baseDir = ctx.baseDir;
91
- assetsDir = `${ctx.baseDir}/data/starfx-bot/assets`;
92
- initAssets();
93
- if (cfg.openLock) {
94
- ctx.command("封印 [param]").action(async ({ session }, param) => {
95
- return await drawLock(ctx, await getImageSrc(session, param));
96
- });
97
- }
98
- if (cfg.openSold) {
99
- ctx.command("卖掉了 [param]").action(async ({ session }, param) => {
100
- return await drawSold(ctx, await getImageSrc(session, param));
101
- });
102
- }
103
- if (cfg.bangdreamBorder) {
104
- 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) => {
105
- session.send("图片处理中请稍等...");
106
- console.log(param);
107
- const drawConfig = await handleBanGDreamConfig(ctx, options);
108
- const imageBase64 = await drawBanGDream(await getImageSrc(session, param), drawConfig);
109
- return import_koishi.h.image(imageBase64);
110
- });
111
- }
112
- if (cfg.record) {
113
- ctx.command("投稿 [param]").action(async ({ session }, param) => {
114
- const imageSrc = await getImageSrc(
115
- session,
116
- param,
117
- {
118
- img: true,
119
- at: false,
120
- quote: true,
121
- noParam: false,
122
- number: false
123
- }
124
- );
125
- if (!imageSrc) {
126
- return "请发送带图片的指令消息或引用图片消息进行投稿";
127
- }
128
- return await addRecord(ctx, session.gid.replace(":", "_"), imageSrc);
129
- });
130
- }
131
- ctx.middleware(async (session, next) => {
132
- const elements = session.elements;
133
- if (cfg.openRepeat) {
134
- const gid = session.gid;
135
- const content = session.content;
136
- const groupMap = repeatContextMap.get(gid);
137
- if (!groupMap || groupMap[0] !== content) {
138
- repeatContextMap.set(gid, [content, 1]);
139
- } else {
140
- if (groupMap[1] !== -1 && ++groupMap[1] >= cfg.minRepeatTimes && import_koishi.Random.bool(cfg.repeatPossibility)) {
141
- groupMap[1] = -1;
142
- await session.send(content);
143
- }
144
- }
145
- }
146
- await atNotSayReply(cfg, session, elements);
147
- await replyBot(cfg, session, elements);
148
- await iLoveYou(cfg, session, elements);
149
- if (cfg.record && session.content?.startsWith("语录")) {
150
- const filepath = await getRecord(session.gid.replace(":", "_"));
151
- starfxLogger.info(`send record: ${filepath}`);
152
- if (!filepath) return "暂无语录呢";
153
- return import_koishi.h.image(filepath);
154
- }
155
- return next();
156
- });
157
- function initAssets() {
158
- const fromUrl = `${__dirname}/../assets`;
159
- assetsDir = `${ctx.baseDir}/data/starfx-bot/assets`;
160
- if (!fs.existsSync(fromUrl)) return;
161
- if (!fs.readdirSync(fromUrl)?.length) return;
162
- if (!fs.existsSync(assetsDir)) {
163
- fs.mkdirSync(assetsDir, { recursive: true });
164
- }
165
- fs.cpSync(fromUrl, assetsDir, { recursive: true, force: true });
166
- if (process.env.NODE_ENV !== "development") {
167
- fs.rmSync(fromUrl, { recursive: true });
168
- }
169
- }
170
- __name(initAssets, "initAssets");
171
- }
172
- __name(apply, "apply");
173
62
  async function addRecord(ctx, gid, avatarUrl) {
174
63
  const recordDir = `${assetsDir}/record/${gid}`;
175
64
  const avatarBuffer = await ctx.http.get(avatarUrl, { responseType: "arraybuffer" });
176
65
  saveImage(avatarBuffer, recordDir);
177
- return "添加成功!";
66
+ return "投稿收到啦";
178
67
  }
179
68
  __name(addRecord, "addRecord");
180
69
  async function getRecord(gid) {
181
70
  const recordDir = `${assetsDir}/record/${gid}`;
182
- const files = fs.readdirSync(recordDir);
71
+ const files = import_fs.default.readdirSync(recordDir);
183
72
  return files?.length ? import_node_path.default.join(recordDir, import_koishi.Random.pick(files)) : null;
184
73
  }
185
74
  __name(getRecord, "getRecord");
@@ -191,9 +80,9 @@ function getTodayPrefix() {
191
80
  return `${yyyy}${mm}${dd}`;
192
81
  }
193
82
  __name(getTodayPrefix, "getTodayPrefix");
194
- function getNextSequenceNumber(directory, prefix) {
195
- const files = fs.existsSync(directory) ? fs.readdirSync(directory) : [];
196
- 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}$`);
197
86
  let maxNum = 0;
198
87
  files.forEach((file) => {
199
88
  const match = file.match(regex);
@@ -207,16 +96,18 @@ function getNextSequenceNumber(directory, prefix) {
207
96
  return maxNum + 1;
208
97
  }
209
98
  __name(getNextSequenceNumber, "getNextSequenceNumber");
210
- function saveImage(arrayBuffer, directory) {
211
- const prefix = getTodayPrefix();
212
- const seq = getNextSequenceNumber(directory, prefix);
213
- 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
+ }
214
105
  const filepath = import_node_path.default.join(directory, filename);
215
- if (!fs.existsSync(directory)) {
216
- fs.mkdirSync(directory, { recursive: true });
106
+ if (!import_fs.default.existsSync(directory)) {
107
+ import_fs.default.mkdirSync(directory, { recursive: true });
217
108
  }
218
109
  const buffer = Buffer.from(arrayBuffer);
219
- fs.writeFileSync(filepath, buffer);
110
+ import_fs.default.writeFileSync(filepath, buffer);
220
111
  console.log(`已保存图片:${filepath}`);
221
112
  }
222
113
  __name(saveImage, "saveImage");
@@ -250,7 +141,7 @@ async function getImageSrc(session, param, option) {
250
141
  return "";
251
142
  }
252
143
  __name(getImageSrc, "getImageSrc");
253
- async function handleBanGDreamConfig(ctx, options) {
144
+ async function handleBanGDreamConfig(options) {
254
145
  const types = {
255
146
  cool: ["cool", "blue", "蓝", "蓝色"],
256
147
  powerful: ["powerful", "red", "红", "红色"],
@@ -278,7 +169,7 @@ async function handleBanGDreamConfig(ctx, options) {
278
169
  starNum: 0,
279
170
  border: ""
280
171
  };
281
- if (options.color) {
172
+ if (options?.color) {
282
173
  for (const [type, aliases] of Object.entries(types)) {
283
174
  if (aliases.includes(options.color.toLowerCase())) {
284
175
  drawConfig.color = type;
@@ -286,7 +177,7 @@ async function handleBanGDreamConfig(ctx, options) {
286
177
  }
287
178
  }
288
179
  }
289
- if (options.band) {
180
+ if (options?.band) {
290
181
  for (const [band, aliases] of Object.entries(bands)) {
291
182
  if (aliases.includes(options.band.toLowerCase())) {
292
183
  drawConfig.band = band;
@@ -294,9 +185,9 @@ async function handleBanGDreamConfig(ctx, options) {
294
185
  }
295
186
  }
296
187
  }
297
- const starNum = options.starNum ? parseInt(options.starNum) : 0;
188
+ const starNum = options?.starNum ? parseInt(options.starNum) : 0;
298
189
  drawConfig.starNum = starNum > 0 && starNum < 10 ? starNum : 0;
299
- if (options.train) {
190
+ if (options?.train) {
300
191
  for (const [train, aliases] of Object.entries(trains)) {
301
192
  if (aliases.includes(options.train.toLowerCase())) {
302
193
  drawConfig.starType = train;
@@ -459,18 +350,142 @@ async function drawBanGDream(avatar, inputOptions) {
459
350
  return `data:image/png;base64,${(await image.getBuffer("image/jpeg")).toString("base64")}`;
460
351
  }
461
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");
462
483
  // Annotate the CommonJS export names for ESM import in node:
463
484
  0 && (module.exports = {
464
485
  Config,
465
- addRecord,
466
486
  apply,
467
487
  assetsDir,
468
488
  baseDir,
469
- drawLock,
470
- drawSold,
471
- getImageSrc,
472
- getRecord,
473
- handleBanGDreamConfig,
474
489
  name,
475
490
  repeatContextMap,
476
491
  starfxLogger,
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.7.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,21 +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 |
31
- | `0.6.0` | 加入复读功能 |
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中,更改语录的触发方式 |