koishi-plugin-group-verification 1.0.23 → 1.0.24
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.js +10 -1
- package/package.json +1 -1
- package/src/index.ts +12 -2
package/lib/index.js
CHANGED
|
@@ -326,7 +326,16 @@ async function handleFailedVerification(ctx, session, config, matchedCount, requ
|
|
|
326
326
|
const channel = rawChannel || guildId;
|
|
327
327
|
const target = rawChannel ? [channel, guildId] : guildId;
|
|
328
328
|
logger.debug("broadcast target", { channel, guildId, target });
|
|
329
|
-
|
|
329
|
+
if (session.bot && typeof session.bot.broadcast === "function") {
|
|
330
|
+
try {
|
|
331
|
+
await session.bot.broadcast([target], reminderMsg);
|
|
332
|
+
} catch (err) {
|
|
333
|
+
logger.warn("bot.broadcast failed, fallback to ctx.broadcast", err);
|
|
334
|
+
await ctx.broadcast([target], reminderMsg);
|
|
335
|
+
}
|
|
336
|
+
} else {
|
|
337
|
+
await ctx.broadcast([target], reminderMsg);
|
|
338
|
+
}
|
|
330
339
|
}
|
|
331
340
|
__name(handleFailedVerification, "handleFailedVerification");
|
|
332
341
|
function apply(ctx, config) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -471,8 +471,18 @@ export async function handleFailedVerification(
|
|
|
471
471
|
const channel = rawChannel || guildId
|
|
472
472
|
const target: string | [string, string] = rawChannel ? [channel, guildId] : guildId
|
|
473
473
|
logger.debug('broadcast target', { channel, guildId, target })
|
|
474
|
-
//
|
|
475
|
-
|
|
474
|
+
// prefer using bot.broadcast since ctx.broadcast may not support tuple
|
|
475
|
+
if (session.bot && typeof session.bot.broadcast === 'function') {
|
|
476
|
+
try {
|
|
477
|
+
await session.bot.broadcast([target], reminderMsg as any)
|
|
478
|
+
} catch (err) {
|
|
479
|
+
// fallback to ctx.broadcast if bot.broadcast fails for some reason
|
|
480
|
+
logger.warn('bot.broadcast failed, fallback to ctx.broadcast', err)
|
|
481
|
+
await (ctx.broadcast as any)([target], reminderMsg)
|
|
482
|
+
}
|
|
483
|
+
} else {
|
|
484
|
+
await (ctx.broadcast as any)([target], reminderMsg)
|
|
485
|
+
}
|
|
476
486
|
}
|
|
477
487
|
|
|
478
488
|
export function apply(ctx: Context, config: Config) {
|