package robot import ( "errors" "fmt" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "google.golang.org/protobuf/proto" ) //用户模块 机器人 type ModuleRobot_Mail struct { mails []*pb.DBMailData } func (this *ModuleRobot_Mail) Init() (err error) { return } //接收到消息 func (this *ModuleRobot_Mail) Receive(robot IRobot, stype string, message proto.Message) (err error) { switch stype { case "getlist": resp := message.(*pb.MailGetListResp) this.mails = resp.Mails break case "getusermailattachment": resp := message.(*pb.MailGetUserMailAttachmentResp) for _, v := range this.mails { if v.ObjId == resp.Mail.ObjId { v.Reward = resp.Mail.Reward break } } break } return } func (this *ModuleRobot_Mail) OncePipeline(robot IRobot) (err error) { var ( errdata *pb.ErrorData ) if _, errdata = robot.SendMessage("mail", "getlist", &pb.MailGetListReq{}); errdata != nil { err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) return } return } //机器人执行流 func (this *ModuleRobot_Mail) DoPipeline(robot IRobot) (err error) { var ( errdata *pb.ErrorData ) for _, v := range this.mails { if !v.Reward { if _, errdata = robot.SendMessage("mail", "getusermailattachment", &pb.MailGetUserMailAttachmentReq{ ObjID: v.ObjId, }); errdata != nil { err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) return } break } } return } //做任务 func (this *ModuleRobot_Mail) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) { return }