From 4b1aa8dde3f827618f8f67d27250b0228876574d Mon Sep 17 00:00:00 2001 From: SanaeFox <36219542+Hoshinonyaruko@users.noreply.github.com> Date: Tue, 14 May 2024 20:22:07 +0800 Subject: [PATCH] Beta117 (#115) * beta1 * beta2 * beta3 * beta4 * beta5 * beta6 * beta7 * beta8 * beta9 * beta10 * beta11 * beta12 * beta13 * beta14 * beta15 * beta16 * beta16 * beta19 * beta20 * beta21 * beta22 * beta23 * beta24 * beta25 * beta27 * beta28 * beta29 * beta30 * beta31 * beta33 * beta34 * beta35 * beta36 * beta37 * beta38 * beta39 * beta40 * beta41 * beta42 * beta43 * beta44 * beta45 * beta45 * beta46 * beat48 * beta49 * beta50 * beta51 * beta52 * beta53 * beta54 * beta55 * beta57 * beta58 * beta59 * beta61 * beta62 * beta63 * beta63 * beta64 * beta65 * beta66 * beta67 * beta70 * beta71 * beta72 * beta72 * beta74 * beta75 * beta76 * beta77 * beta78 * beta79 * beta80 * beta81 * beta82 * beta83 * beta85 * beta86 * beta87 * beta88 * beta89 * beta90 * beta91 * beta92 * beta93 * beta94 * beta94 * beta96 * beta97 * beta98 * beta99 * beta100 * beta101 * beta102 * beta104 * beta105 * beta106 * beta107 * beta108 * beta109 * beta110 * beta111 * beta112 * beta113 * beta115 * beta116 * beta117 --- applogic/gensokyo.go | 2 +- utils/blacklist.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/applogic/gensokyo.go b/applogic/gensokyo.go index 71369e8..60d5a94 100644 --- a/applogic/gensokyo.go +++ b/applogic/gensokyo.go @@ -264,7 +264,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) { } if utils.BlacklistIntercept(message, selfid) { - fmtf.Printf("userid:[%v]这位用户在黑名单中,被拦截", message.UserID) + fmtf.Printf("userid:[%v]groupid:[%v]这位用户或群在黑名单中,被拦截", message.UserID, message.GroupID) return } diff --git a/utils/blacklist.go b/utils/blacklist.go index 6d3b1f2..77b1aea 100644 --- a/utils/blacklist.go +++ b/utils/blacklist.go @@ -94,6 +94,26 @@ func WatchBlacklist(filePath string) { // BlacklistIntercept 检查用户ID是否在黑名单中,如果在,则发送预设消息 func BlacklistIntercept(message structs.OnebotGroupMessage, selfid string) bool { + // 检查群ID是否在黑名单中 + if IsInBlacklist(strconv.FormatInt(message.GroupID, 10)) { + // 获取黑名单响应消息 + responseMessage := config.GetBlacklistResponseMessages() + + // 根据消息类型发送响应 + if message.RealMessageType == "group_private" || message.MessageType == "private" { + if !config.GetUsePrivateSSE() { + SendPrivateMessage(message.UserID, responseMessage, selfid) + } else { + SendSSEPrivateMessage(message.UserID, responseMessage) + } + } else { + SendGroupMessage(message.GroupID, message.UserID, responseMessage, selfid) + } + + fmt.Printf("groupid:[%v]这个群在黑名单中,被拦截\n", message.GroupID) + return true // 拦截 + } + // 检查用户ID是否在黑名单中 if IsInBlacklist(strconv.FormatInt(message.UserID, 10)) { // 获取黑名单响应消息 @@ -113,5 +133,6 @@ func BlacklistIntercept(message structs.OnebotGroupMessage, selfid string) bool fmt.Printf("userid:[%v]这位用户在黑名单中,被拦截\n", message.UserID) return true // 拦截 } + return false // 用户ID不在黑名单中,不拦截 }