From a69ee661fac1b557982b7faff055a62e5cf16371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=89=E9=A3=8E=E6=9D=A5?= <3139373986@qq.com> Date: Fri, 7 Jun 2024 11:52:30 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E6=8A=95?= =?UTF-8?q?=E7=A5=A8=E7=A6=81=E8=A8=80=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #122 --- apps/groupAdmin/groupVote.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/apps/groupAdmin/groupVote.js b/apps/groupAdmin/groupVote.js index 35b0d88..aeb0485 100644 --- a/apps/groupAdmin/groupVote.js +++ b/apps/groupAdmin/groupVote.js @@ -1,10 +1,10 @@ -import { Config } from "../../components/index.js" -import { common } from "../../model/index.js" -import fs from "node:fs/promises" -import path from "path" import url from "url" -import v8 from "node:v8" import md5 from "md5" +import path from "path" +import v8 from "node:v8" +import fs from "node:fs/promises" +import { common } from "../../model/index.js" +import { Config } from "../../components/index.js" let Vote = {} const SettingReg = /^#?投票设置(超时时间|最低票数|禁言时间)?(\d*)$/ @@ -43,8 +43,8 @@ export class GroupVote extends plugin { async Switch() { if (!common.checkPermission(this.e, "master")) return - const type = !!/启用/.test(this.e.msg) - const isBan = !!/禁言/.test(this.e.msg) + const type = /启用/.test(this.e.msg) + const isBan = /禁言/.test(this.e.msg) const name = isBan ? "禁言" : "踢人" const key = isBan ? "VoteBan" : "VoteKick" @@ -124,9 +124,9 @@ export class GroupVote extends plugin { "发起人:", segment.at(e.user_id), `(${e.user_id})\n`, "请支持者发送:\n", `「#支持投票${targetQQ}」\n`, "不支持者请发送:\n", `「#反对投票${targetQQ}」\n`, - `超时时间:${outTime}秒\n`, isBan ? `禁言时间:${BanTime}秒\n` : "投票成功将会被移出群聊\n", - `规则:支持票大于反对票且参与人高于${minNum}人即可成功投票`, - veto ? "\n管理员拥有一票权" : "" + `超时时间:${outTime}秒\n`, isBan ? `禁言时间:${BanTime}秒\n` : "投票成功将会被移出群聊\n", + `规则:支持票大于反对票且参与人高于${minNum}人即可成功投票`, + veto ? "\n管理员拥有一票权" : "" ] if (!await e.reply(voteMsg, true)) return false @@ -168,6 +168,7 @@ export class GroupVote extends plugin { async Follow(e) { if (!common.checkPermission(e, "all", "admin")) return + const support = /支持/.test(e.msg) const { BanTime, veto } = Config.groupAdmin let targetQQ = e.at || (e.msg.match(/\d+/)?.[0] || "") @@ -179,27 +180,27 @@ export class GroupVote extends plugin { if (e.user_id === targetQQ) return e.reply("❎ 您不能对自己进行投票") if (!Vote[key]) return e.reply("❎ 未找到对应投票") - const { List, type, supportCount, opposeCount } = Vote[key] + const { List, type } = Vote[key] if (veto && (e.member.is_admin || e.member.is_owner)) { - const msg = /支持/.test(e.msg) + const msg = support ? "投票结束,管理员介入,执行操作。" : "投票取消,管理员介入。" await e.reply(msg, true) - if (/支持/.test(e.msg)) { + if (support) { type === "Ban" ? await e.group.muteMember(targetQQ, BanTime) : await e.group.kickMember(targetQQ) } delete Vote[key] return true } - if (List.includes(e.user_id)) return e.reply("❎ 你已参与过投票,请勿重复参与"); + if (List.includes(e.user_id)) return e.reply("❎ 你已参与过投票,请勿重复参与") - /支持/.test(e.msg) ? Vote[key].supportCount++ : Vote[key].opposeCount++ + support ? Vote[key].supportCount++ : Vote[key].opposeCount++ List.push(e.user_id) - return e.reply(`投票成功,当前票数\n支持:${supportCount} 反对:${opposeCount}`, true) + return e.reply(`投票成功,当前票数\n支持:${Vote[key].supportCount} 反对:${Vote[key].opposeCount}`, true) } }