From a71ac3440207c7c041e375b09f15c4f4da85ab0c Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 8 Sep 2023 20:40:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=AB=9E=E6=8A=80=E5=9C=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/api_info.go | 2 +- modules/robot/modulerobot_horoscope.go | 6 ++-- modules/robot/robot.go | 39 ++++++++++++++++++-------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/modules/arena/api_info.go b/modules/arena/api_info.go index e03094bf0..c66bdaccb 100644 --- a/modules/arena/api_info.go +++ b/modules/arena/api_info.go @@ -33,7 +33,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (errd errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), - Message: err.Error(), + Message: "no fund user!", } return } diff --git a/modules/robot/modulerobot_horoscope.go b/modules/robot/modulerobot_horoscope.go index 599b889df..2a8ccf67d 100644 --- a/modules/robot/modulerobot_horoscope.go +++ b/modules/robot/modulerobot_horoscope.go @@ -76,8 +76,10 @@ func (this *ModuleRobot_Horoscope) findcanupnode() (conf *cfg.GameHoroscopeData, for _, v := range v.(*cfg.GameHoroscope).GetDataList() { ok = true for _, v := range v.Front { - if _, ok = this.Info.Nodes[v]; !ok { - break + if v != 0 { + if _, ok = this.Info.Nodes[v]; !ok { + break + } } } if ok { diff --git a/modules/robot/robot.go b/modules/robot/robot.go index b849169c6..bca2116be 100644 --- a/modules/robot/robot.go +++ b/modules/robot/robot.go @@ -142,25 +142,40 @@ func (this *Robot) SendMessage(mtype, stype string, msg proto.Message) (resp pro SubType: stype, Data: data, } - if err = this.WriteMsg(message); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ClientError, - Title: pb.ErrorCode_ClientError.String(), - Message: err.Error(), - } - return - } + if mtype != "gateway" { this.curreq = fmt.Sprintf("%s.%s", mtype, stype) + if err = this.WriteMsg(message); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ClientError, + Title: pb.ErrorCode_ClientError.String(), + Message: err.Error(), + } + return + } messageresp = <-this.await //等待回应 resp = messageresp.resp errdata = messageresp.errdata + if this.debug { + if errdata == nil { + log.Debug("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "errdata", Value: errdata == nil}) + } else { + log.Error("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "errdata", Value: errdata.String()}) + } + } + this.statistics = append(this.statistics, &RobotStatistics{ message: fmt.Sprintf("%s.%s", mtype, stype), time: time.Since(stime).Milliseconds(), }) - if this.debug { - log.Debug("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "resp", Value: errdata == nil}) + } else { + if err = this.WriteMsg(message); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ClientError, + Title: pb.ErrorCode_ClientError.String(), + Message: err.Error(), + } + return } } return @@ -255,7 +270,7 @@ func (this *Robot) run() { log.Error("[机器人 初始执行错误]", log.Field{Key: "Account", Value: this.account}, log.Field{Key: "module", Value: v}, log.Field{Key: "err", Value: err.Error()}) break } - time.Sleep(time.Millisecond * time.Duration(2000+rand.Int31n(3000))) + time.Sleep(time.Millisecond * time.Duration(2000+rand.Int31n(2000))) } for this.cycle { @@ -277,7 +292,7 @@ func (this *Robot) run() { this.cycle = true } } - time.Sleep(time.Millisecond * time.Duration(2000+rand.Int31n(3000))) + time.Sleep(time.Millisecond * time.Duration(2000+rand.Int31n(2000))) } } this.Close()