Skip to content

Commit

Permalink
feat: 支持直接艾特机器人的方式呼唤
Browse files Browse the repository at this point in the history
  • Loading branch information
Clov614 committed Jul 16, 2024
1 parent 5969519 commit 703cd95
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions rikkabot/processor/cache/checkrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package cache

import (
"wechat-demo/rikkabot/common"
"wechat-demo/rikkabot/message"
"wechat-demo/rikkabot/processor/control"
"wechat-demo/rikkabot/utils/msgutil"
Expand Down Expand Up @@ -58,9 +59,17 @@ func (c *Cache) IsHandle(rules *control.ProcessRules, msg message.Message) (mess
}
}
if rules.IsCallMe {
me := c.config.Symbol + c.config.Botname
calledMeFlag = msgutil.IsCallMe(me, msg.Content)
msg.Content = msgutil.TrimCallMe(me, msg.Content)
if msgutil.HasPrefix(msg.Content, "@", true) { // 处理艾特
nickname := msgutil.GetNicknameByAt(msg.Content)
if nickname == common.GetSelf().GetNickname() {
calledMeFlag = true
msg.Content = msgutil.TrimPrefix(msg.Content, "@"+nickname+" ", false, true)
}
} else { // 处理机器人名方式
me := c.config.Symbol + c.config.Botname
calledMeFlag = msgutil.IsCallMe(me, msg.Content)
msg.Content = msgutil.TrimCallMe(me, msg.Content)
}
}
// 必须先等前缀判定完 判断是否符合命令
if rules.ExecOrder != nil && len(rules.ExecOrder) > 0 {
Expand Down

0 comments on commit 703cd95

Please sign in to comment.