koishi-plugin-test-sm-nextmap 0.0.5 → 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 +1 -1
- package/lib/index.js +7 -4
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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) => {
|
|
@@ -44,9 +45,11 @@ function apply(ctx, config) {
|
|
|
44
45
|
const message = type === "Test" ? `🎮 [测试] 服务器连接成功!地图: ${map}` : `更换地图: ${map}`;
|
|
45
46
|
const bot = ctx.bots.find((b) => b.platform === config.targetPlatform);
|
|
46
47
|
if (bot) {
|
|
47
|
-
|
|
48
|
-
|
|
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
|
}
|