koishi-plugin-test-sm-nextmap 0.0.4 → 0.0.6

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
@@ -2,7 +2,7 @@ import { Context, Schema } from 'koishi';
2
2
  export declare const name = "source-http-notify";
3
3
  export declare const inject: string[];
4
4
  export interface Config {
5
- targetChannelId: string;
5
+ targetChannelIds: string[];
6
6
  targetPlatform: string;
7
7
  }
8
8
  export declare const Config: Schema<Config>;
package/lib/index.js CHANGED
@@ -31,7 +31,8 @@ var name = "source-http-notify";
31
31
  var inject = ["server"];
32
32
  var Config = import_koishi.Schema.object({
33
33
  targetPlatform: import_koishi.Schema.string().default("onebot").description("发送消息的平台"),
34
- targetChannelId: import_koishi.Schema.string().required().description("接收通知的群号或频道 ID")
34
+ // 使用 Schema.array 允许在配置界面添加多个群号
35
+ targetChannelIds: import_koishi.Schema.array(import_koishi.Schema.string()).required().description("接收通知的群号或频道 ID 列表")
35
36
  });
36
37
  function apply(ctx, config) {
37
38
  ctx.server.get("/mapchange", async (report) => {
@@ -41,12 +42,14 @@ function apply(ctx, config) {
41
42
  return "Missing map name";
42
43
  }
43
44
  ctx.logger.info(`收到服务器通知: [${type}] 地图: ${map}`);
44
- const message = type === "Test" ? `🎮 [测试] 服务器连接成功!当前地图: ${map}` : `🎮 [换图] 服务器即将更换地图,下一张图是: ${map}`;
45
+ const message = type === "Test" ? `🎮 [测试] 服务器连接成功!地图: ${map}` : `更换地图: ${map}`;
45
46
  const bot = ctx.bots.find((b) => b.platform === config.targetPlatform);
46
47
  if (bot) {
47
- bot.sendMessage(config.targetChannelId, message).catch((err) => {
48
- ctx.logger.error("消息推送失败:", err);
49
- });
48
+ for (const channelId of config.targetChannelIds) {
49
+ bot.sendMessage(channelId, message).catch((err) => {
50
+ ctx.logger.error(`向群组 ${channelId} 推送消息失败:`, err);
51
+ });
52
+ }
50
53
  } else {
51
54
  ctx.logger.warn(`未找到平台为 ${config.targetPlatform} 的可用 Bot`);
52
55
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-test-sm-nextmap",
3
3
  "description": "",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [