fix: 修复更新间隔判断错误的问题,同步cmd_parser代码

main
NorthLan 3 years ago
parent 99e4167c96
commit 922fb55f56

@ -72,8 +72,8 @@ func (h *MsgToDBHandler) handleGift(data []byte, msgKey string) {
}
}
func (MsgToDBHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (MsgToDBHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
func (*MsgToDBHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (*MsgToDBHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
func (h *MsgToDBHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error {
for msg := range claim.Messages() {
if hFunc, ok := h.msgHandle[msg.Topic]; ok {

@ -41,7 +41,7 @@ func (l *RetrievePlatformUserLogic) RetrievePlatformUser(in *pb.PlatformUserReq)
}
}
// 根据 updateTime 判断是否需要更新
if dbPlatformUser != nil && time.Now().Add(time.Duration(l.svcCtx.Config.User.UpdateDuration)*time.Hour).Before(dbPlatformUser.UpdateTime) {
if dbPlatformUser != nil && time.Now().Add(time.Duration(l.svcCtx.Config.User.UpdateDuration)*time.Hour).After(dbPlatformUser.UpdateTime) {
var username *string
if one, err := l.svcCtx.UserModel.FindOne(l.ctx, dbPlatformUser.UserId); err != nil {
username = &one.Username

@ -2,6 +2,7 @@ package danmaku
import (
"git.noahlan.cn/northlan/ntools-go/stringn/ac"
"strings"
)
type (
@ -36,7 +37,9 @@ func (p *Parser) ParseTest(content string) {
}
func (p *Parser) Parse(content string) *CMD {
matches := p.trie.MatchString(content)
// 移除多余空格,小写
tmpContent := strings.ToLower(strings.TrimSpace(content))
matches := p.trie.MatchString(tmpContent)
allKeyLen := 0
matchedKeyMap := make(map[string]struct{})
@ -45,7 +48,7 @@ func (p *Parser) Parse(content string) *CMD {
matchedKeyMap[tmp] = struct{}{}
allKeyLen += len(tmp)
}
isCMD := len(content) <= allKeyLen
isCMD := len(tmpContent) <= allKeyLen
// 避免同类型指令重复
arrMap := make(map[rune]struct{})
@ -61,7 +64,7 @@ func (p *Parser) Parse(content string) *CMD {
}
}
return &CMD{
IsCMD: len(content) <= allKeyLen,
IsCMD: len(tmpContent) <= allKeyLen,
Arr: matchedCmdArr,
}
}

@ -90,8 +90,8 @@ func (h *MsgToDBHandler) handleDanmaku(data []byte, msgKey string) {
}
}
func (MsgToDBHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (MsgToDBHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
func (*MsgToDBHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (*MsgToDBHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
func (h *MsgToDBHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error {
for msg := range claim.Messages() {
if hFunc, ok := h.msgHandle[msg.Topic]; ok {

Loading…
Cancel
Save