diff --git a/busi/core.go b/busi/core.go index 3c8139a..9bf377f 100644 --- a/busi/core.go +++ b/busi/core.go @@ -5,6 +5,11 @@ import ( "time" ) +const ( + USER_LOGIN = "user.login" + SOCIATY_MINE = "sociaty.mine" +) + func Sleep(min, max time.Duration) { ulit := int64(max - min) t := time.Duration(rand.Int63n(ulit)) + min diff --git a/busi/sociaty.go b/busi/sociaty.go index fd71af8..a2c2eaf 100644 --- a/busi/sociaty.go +++ b/busi/sociaty.go @@ -1,9 +1,21 @@ package busi -import "legu.airobot/lib" +import ( + "fmt" + "time" + + "github.com/Pallinder/go-randomdata" + "github.com/sirupsen/logrus" + "legu.airobot/lib" + "legu.airobot/pb" +) var _ lib.IScene = (*SociatyScene)(nil) +const ( + SociatyMainType = "sociaty" +) + type SociatyScene struct { lib.Action } @@ -17,6 +29,34 @@ func (s *SociatyScene) Info() lib.SceneInfo { func (s *SociatyScene) Run(robot lib.IRobot) error { - + createSociaty(robot) + Sleep(time.Second, time.Second*3) + mine(robot) return nil } + +// 创建公会 +func createSociaty(robot lib.IRobot) { + req := &pb.SociatyCreateReq{} + rsp := &pb.SociatyCreateResp{} + + req.Name = fmt.Sprintf("%s_%s", randomdata.SillyName(), randomdata.City()) + req.IsApplyCheck = false + req.ApplyLv = 1 + if code := robot.SendMsg(SociatyMainType, "create", req, rsp); code != pb.ErrorCode_Success { + logrus.Debugf("公会创建:%v", code) + return + } + +} + +func mine(robot lib.IRobot) { + req := &pb.SociatyMineReq{} + rsp := &pb.SociatyMineResp{} + + if code := robot.SendMsg(SociatyMainType, "mine", req, rsp); code != pb.ErrorCode_Success { + logrus.Debugf("我的公会:%v", code) + } + + robot.Store(SOCIATY_MINE, rsp) +}