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 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
- await ctx.broadcast([target], reminderMsg);
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-group-verification",
3
3
  "description": "[WIP] Koishi 群组加群验证插件,支持多关键词匹配审核、多种审核方式和详细统计功能(开发中)",
4
- "version": "1.0.23",
4
+ "version": "1.0.24",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
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
- // cast to any to satisfy overloaded typings on ctx.broadcast
475
- await (ctx.broadcast as any)([target], reminderMsg)
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) {