From 922fb55f56ec51b3e2b54c992009dc9127ba0682 Mon Sep 17 00:00:00 2001 From: NorthLan <6995syu@163.com> Date: Mon, 25 Apr 2022 01:23:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=97=B4=E9=9A=94=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98,=E5=90=8C=E6=AD=A5cmd=5Fparser=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gift/rpc/msg_transfer/gift/msg_to_db.go | 4 ++-- .../rpc/internal/logic/retrieve_platform_user_logic.go | 2 +- app/user_center/rpc/msg_transfer/danmaku/cmd_parser.go | 9 ++++++--- app/user_center/rpc/msg_transfer/danmaku/msg_to_db.go | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/gift/rpc/msg_transfer/gift/msg_to_db.go b/app/gift/rpc/msg_transfer/gift/msg_to_db.go index 060ee35..55f2d3a 100644 --- a/app/gift/rpc/msg_transfer/gift/msg_to_db.go +++ b/app/gift/rpc/msg_transfer/gift/msg_to_db.go @@ -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 { diff --git a/app/user_center/rpc/internal/logic/retrieve_platform_user_logic.go b/app/user_center/rpc/internal/logic/retrieve_platform_user_logic.go index c494e08..7eec9a3 100644 --- a/app/user_center/rpc/internal/logic/retrieve_platform_user_logic.go +++ b/app/user_center/rpc/internal/logic/retrieve_platform_user_logic.go @@ -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 diff --git a/app/user_center/rpc/msg_transfer/danmaku/cmd_parser.go b/app/user_center/rpc/msg_transfer/danmaku/cmd_parser.go index 14be103..6382dbf 100644 --- a/app/user_center/rpc/msg_transfer/danmaku/cmd_parser.go +++ b/app/user_center/rpc/msg_transfer/danmaku/cmd_parser.go @@ -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, } } diff --git a/app/user_center/rpc/msg_transfer/danmaku/msg_to_db.go b/app/user_center/rpc/msg_transfer/danmaku/msg_to_db.go index 1fa001e..fd5b51a 100644 --- a/app/user_center/rpc/msg_transfer/danmaku/msg_to_db.go +++ b/app/user_center/rpc/msg_transfer/danmaku/msg_to_db.go @@ -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 {