koishi-plugin-node-async-bot-all 2.26.6 → 2.27.1

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/fun.d.ts CHANGED
@@ -34,7 +34,7 @@ export declare function getHongKongTime(): string;
34
34
  export declare function readInfoFile(ctx: Context): Promise<string>;
35
35
  export declare function formatTimestampDiff(start: number, end: number): string;
36
36
  export declare function getMsgCount(ctx: Context): Promise<Object>;
37
- export declare function random(type: number | undefined, data: any, data2?: any): number;
37
+ export declare function random(type: number | undefined, data: number | number[], data2?: number): number;
38
38
  export declare function request<T = any>(url: string, options?: RequestInit, timeout?: number, log?: any): Promise<HttpResponse<T>>;
39
39
  export declare function readUserCardFile(userInfo: APIUserInfo): Promise<string>;
40
40
  export declare function readUserMsgFile(userName: string, userAvatar: string, msg: string, inversion: boolean | undefined, replyUserName: string | undefined, replyMsg: string | undefined): Promise<string>;
package/lib/index.d.ts CHANGED
@@ -43,6 +43,8 @@ export interface Config {
43
43
  catAPI: string;
44
44
  qqAPI: string;
45
45
  slNews: string[];
46
+ specialMsg: string[];
47
+ reactionId: number[];
46
48
  }
47
49
  export declare const Config: Schema<Config>;
48
50
  export declare function apply(ctx: Context): void;
package/lib/index.js CHANGED
@@ -178,10 +178,13 @@ function random(type = 0, data, data2) {
178
178
  const random2 = new import_koishi.Random(() => Math.random());
179
179
  switch (type) {
180
180
  case 0:
181
+ if (typeof data != "number" || data2 == void 0) return 0;
181
182
  return random2.int(data, data2);
182
183
  case 1:
184
+ if (typeof data != "number" || data2 == void 0) return 0;
183
185
  return random2.real(data, data2);
184
186
  case 2:
187
+ if (typeof data != "object") return 0;
185
188
  return random2.pick(data);
186
189
  default:
187
190
  return 0;
@@ -940,7 +943,7 @@ async function getUse(ctx, session, qq, desc) {
940
943
  __name(getUse, "getUse");
941
944
 
942
945
  // package.json
943
- var version = "2.26.6";
946
+ var version = "2.27.1";
944
947
 
945
948
  // src/index.ts
946
949
  var inject = ["database", "installer", "puppeteer", "cron"];
@@ -987,6 +990,10 @@ var Config = import_koishi3.Schema.intersect([
987
990
  slNews: import_koishi3.Schema.array(String).default([""]).description("{platform}:{channelId}"),
988
991
  newsAPI: import_koishi3.Schema.string().default("https://api.steampowered.com/ISteamNews/GetNewsForApp/v2/?appid=700330&count=1").description("新闻 API")
989
992
  }).description("SL新闻列表"),
993
+ import_koishi3.Schema.object({
994
+ specialMsg: import_koishi3.Schema.array(String).default([]).description("特殊消息"),
995
+ reactionId: import_koishi3.Schema.array(Number).default([]).description("回应表情 ID")
996
+ }).description("特殊消息回应"),
990
997
  import_koishi3.Schema.object({
991
998
  slTest: import_koishi3.Schema.array(import_koishi3.Schema.object({
992
999
  id: import_koishi3.Schema.string().description("服务器 ID"),
@@ -1036,6 +1043,13 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
1036
1043
  await ctx.broadcast(ctx.config.slNews, outMsg.msg);
1037
1044
  }
1038
1045
  });
1046
+ ctx.on("message", async (session) => {
1047
+ for (const content of ctx.config.specialMsg) {
1048
+ if (session.content === content) {
1049
+ await session.bot.createReaction(session.channelId, session.messageId, `face|${String(random(2, ctx.config.reactionId))}`);
1050
+ }
1051
+ }
1052
+ });
1039
1053
  na.subcommand("cxGame").action(async ({ session }) => {
1040
1054
  const cx = await getServer(ctx, session);
1041
1055
  if (cx["success"] == 0) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-node-async-bot-all",
3
3
  "description": "NodeAsync Bot插件(自用)",
4
- "version": "2.26.6",
4
+ "version": "2.27.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [