koishi-plugin-808ps-qunmax 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/lib/index.js +21 -24
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -309,8 +309,8 @@ var Config = import_koishi.Schema.object({
309
309
  外群监控配置: import_koishi.Schema.object({
310
310
  主动入群: import_koishi.Schema.boolean().default(true),
311
311
  被邀请入群: import_koishi.Schema.boolean().default(true),
312
- 被踢出群: import_koishi.Schema.boolean().default(false),
313
- 主动退群: import_koishi.Schema.boolean().default(false)
312
+ 被踢出群: import_koishi.Schema.boolean().default(true),
313
+ 主动退群: import_koishi.Schema.boolean().default(true)
314
314
  }).description("【所有未绑定到任何渠道的外群】仅执行此处配置的进退群监控,自动推送给值班人员")
315
315
  });
316
316
  async function initDatabase(config) {
@@ -986,30 +986,27 @@ async function apply(ctx, config) {
986
986
  const channelConfig = getChannelConfigByGroupId(groupId, config);
987
987
  if (channelConfig) return;
988
988
  if (!groupId || !userId) return;
989
- const botList = config.机器人QQ号.map(String).sort();
990
- const mainBot = botList[0];
991
- const isPushBot = session.bot.selfId === mainBot;
992
989
  if (await checkRepeatPushLimit(mainPool, userId, config.重复推送限制小时)) {
993
990
  logger.info(`[外群监控-入群] ${userId} 在限制期内,跳过推送`);
994
991
  return;
995
992
  }
996
993
  let subType = eventExtractor.determineAction(session, "enter");
994
+ if (!subType) subType = "approve";
997
995
  const monitorConfig = config.外群监控配置;
998
996
  const isApprove = subType === "approve";
999
997
  const isInvite = subType === "invite";
1000
- if (isApprove && !monitorConfig.主动入群 || isInvite && !monitorConfig.被邀请入群) return;
998
+ if (isApprove && !monitorConfig.主动入群 || isInvite && !monitorConfig.被邀请入群) {
999
+ logger.debug(`[外群入群] ${userId} 事件类型${subType}未开启监控,跳过`);
1000
+ return;
1001
+ }
1001
1002
  const [memberRows] = await mainPool.execute(`SELECT COUNT(*) AS count FROM our_group_members WHERE qq = ?`, [userId]);
1002
1003
  if (memberRows[0].count > 0) {
1003
1004
  logger.info(`[外群监控] 群${groupId} 用户${userId} 是自有群成员,跳过`);
1004
1005
  return;
1005
1006
  }
1006
1007
  const eventText = eventExtractor.getActionText(subType);
1007
- if (isPushBot) {
1008
- await pushDrainData(mainPool, ctx, userId, groupId, subType, eventText, config);
1009
- logger.info(`[外群入群推送完成] QQ:${userId} 群:${groupId} 事件:${eventText}`);
1010
- } else {
1011
- logger.debug(`[副机采集外群入群] 机器人${session.bot.selfId} 群${groupId} 用户${userId}`);
1012
- }
1008
+ await pushDrainData(mainPool, ctx, userId, groupId, subType, eventText, config);
1009
+ logger.info(`[外群入群推送完成] QQ:${userId} 群:${groupId} 事件:${eventText}`);
1013
1010
  });
1014
1011
  ctx.on("guild-member-removed", async (session) => {
1015
1012
  const groupId = eventExtractor.extractGroupId(session);
@@ -1017,30 +1014,30 @@ async function apply(ctx, config) {
1017
1014
  const channelConfig = getChannelConfigByGroupId(groupId, config);
1018
1015
  if (channelConfig) return;
1019
1016
  if (!groupId || !userId) return;
1020
- const botList = config.机器人QQ号.map(String).sort();
1021
- const mainBot = botList[0];
1022
- const isPushBot = session.bot.selfId === mainBot;
1023
1017
  if (await checkRepeatPushLimit(mainPool, userId, config.重复推送限制小时)) {
1024
1018
  logger.info(`[外群监控-退群] ${userId} 在限制期内,跳过推送`);
1025
1019
  return;
1026
1020
  }
1027
1021
  let subType = eventExtractor.determineAction(session, "leave");
1022
+ if (!subType) subType = "leave";
1028
1023
  const monitorConfig = config.外群监控配置;
1029
1024
  let eventText = "";
1030
- if (subType === "kick" && monitorConfig.被踢出群) eventText = "被踢出群";
1031
- else if (subType === "leave" && monitorConfig.主动退群) eventText = "主动退群";
1032
- if (!eventText) return;
1025
+ if (subType === "kick" && monitorConfig.被踢出群) {
1026
+ eventText = "被踢出群";
1027
+ } else if (subType === "leave" && monitorConfig.主动退群) {
1028
+ eventText = "主动退群";
1029
+ }
1030
+ if (!eventText) {
1031
+ logger.debug(`[外群退群] ${userId} 事件类型${subType}未开启监控,跳过`);
1032
+ return;
1033
+ }
1033
1034
  const [memberRows] = await mainPool.execute(`SELECT COUNT(*) AS count FROM our_group_members WHERE qq = ?`, [userId]);
1034
1035
  if (memberRows[0].count > 0) {
1035
1036
  logger.info(`[外群监控] 群${groupId} 用户${userId} 是自有群成员,跳过`);
1036
1037
  return;
1037
1038
  }
1038
- if (isPushBot) {
1039
- await pushDrainData(mainPool, ctx, userId, groupId, subType, eventText, config);
1040
- logger.info(`[外群退群推送完成] QQ:${userId} 群:${groupId} 事件:${eventText}`);
1041
- } else {
1042
- logger.debug(`[副机采集外群退群] 机器人${session.bot.selfId} 群${groupId} 用户${userId}`);
1043
- }
1039
+ await pushDrainData(mainPool, ctx, userId, groupId, subType, eventText, config);
1040
+ logger.info(`[外群退群推送完成] QQ:${userId} 群:${groupId} 事件:${eventText}`);
1044
1041
  });
1045
1042
  ctx.setInterval(async () => {
1046
1043
  if (!mainPool) return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-808ps-qunmax",
3
3
  "description": "",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [