Skip to content

Commit

Permalink
fix: support message type that can not @anyone
Browse files Browse the repository at this point in the history
  • Loading branch information
RicheyJang committed Feb 25, 2022
1 parent 276125c commit 98c5f05
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion plugins/chat/deal.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,21 @@ func dealChat(ctx *zero.Ctx) {
}
}

var singleCQTypeSet = map[string]struct{}{
"record": {}, "video": {}, "rps": {}, "dice": {}, "shake": {}, "poke": {}, "share": {},
"contact": {}, "location": {}, "music": {}, "reply": {}, "forward": {}, "node": {},
}

func sendChatMessage(ctx *zero.Ctx, msg message.Message) {
if utils.IsMessagePrimary(ctx) || !proxy.GetConfigBool("at") { // 私聊或无需@
doNotAt := false
// 检查是否包含不能@的消息类型
for _, seg := range msg {
if _, ok := singleCQTypeSet[seg.Type]; ok {
doNotAt = true
break
}
}
if doNotAt || utils.IsMessagePrimary(ctx) || !proxy.GetConfigBool("at") { // 私聊或无需@
ctx.Send(msg)
} else {
ctx.SendChain(append(message.Message{message.At(ctx.Event.UserID)}, msg...)...)
Expand Down

0 comments on commit 98c5f05

Please sign in to comment.