koishi-plugin-node-async-bot-all 2.3.0 → 2.4.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
@@ -12,7 +12,8 @@ interface botDataTables {
12
12
  export declare const name = "node-async-bot-all";
13
13
  export declare const usage = "\u8FD9\u662F\u4E00\u4E2A\u79C1\u6709\u63D2\u4EF6\u3002";
14
14
  export interface Config {
15
- cxAPI: string;
15
+ cxV2Group: Array<string>;
16
+ cxV2API: Array<string>;
16
17
  rwAPI: string;
17
18
  timeout: number;
18
19
  }
package/lib/index.js CHANGED
@@ -179,17 +179,22 @@ async function getServer(ctx, session) {
179
179
  const log = ctx.logger("cx");
180
180
  log.info(`Got: {"form":"${session.event.guild.id}","user":"${session.event.user.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message.id}"}`);
181
181
  let msg;
182
- let api;
183
182
  let dataError;
184
183
  let data;
185
184
  let error;
186
185
  const time = getHongKongTime();
187
- if (session.event.guild.id == "757729218" || session.event.guild.id == "1047732162" || session.event.guild.id == "917260212") {
186
+ if (ctx.config.cxV2Group.includes(session.event.guild.id)) {
188
187
  try {
189
- if (session.event.guild.id == "917260212") {
190
- api = ctx.config.cxAPI2;
191
- } else {
192
- api = ctx.config.cxAPI;
188
+ const api = ctx.config.cxV2API[ctx.config.cxV2Group.indexOf(session.event.guild.id)];
189
+ if (api == void 0) {
190
+ msg = {
191
+ "time": time,
192
+ "data": "未指定查询 API",
193
+ "success": 1
194
+ };
195
+ log.info("Sent:");
196
+ log.info(msg);
197
+ return msg;
193
198
  }
194
199
  const response = await fetchWithTimeout(api, {}, ctx.config.timeout, log);
195
200
  if (response.ok) {
@@ -396,7 +401,7 @@ async function getRW(ctx, session) {
396
401
  __name(getRW, "getRW");
397
402
 
398
403
  // package.json
399
- var version = "2.3.0";
404
+ var version = "2.4.0";
400
405
 
401
406
  // src/index.ts
402
407
  var inject = ["database"];
@@ -407,8 +412,8 @@ var Config = import_koishi2.Schema.intersect([
407
412
  timeout: import_koishi2.Schema.number().default(8e3).description("超时时间(毫秒)")
408
413
  }).description("基础"),
409
414
  import_koishi2.Schema.object({
410
- cxAPI: import_koishi2.Schema.string().default("https://api.tasaed.top/get/minecraftServer/").description("查询 API"),
411
- cxAPI2: import_koishi2.Schema.string().default("https://api.tasaed.top/get/minecraftServer/bas.php").description("查询 API 2")
415
+ cxV2Group: import_koishi2.Schema.array(String).description("查询 群,对应 API"),
416
+ cxV2API: import_koishi2.Schema.array(String).description("查询 API,对应 ")
412
417
  }).description("查询"),
413
418
  import_koishi2.Schema.object({
414
419
  rwAPI: import_koishi2.Schema.string().default("https://api.tasaed.top/rw/").description("随机文本 API")
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.3.0",
4
+ "version": "2.4.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [