Skip to content

Commit

Permalink
beta117
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko committed May 14, 2024
1 parent 3c24828 commit d17b87e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion applogic/gensokyo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
21 changes: 21 additions & 0 deletions utils/blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
// 获取黑名单响应消息
Expand All @@ -113,5 +133,6 @@ func BlacklistIntercept(message structs.OnebotGroupMessage, selfid string) bool
fmt.Printf("userid:[%v]这位用户在黑名单中,被拦截\n", message.UserID)
return true // 拦截
}

return false // 用户ID不在黑名单中,不拦截
}

0 comments on commit d17b87e

Please sign in to comment.