diff --git a/action/action.go b/action/action.go index c692d29..89f08df 100644 --- a/action/action.go +++ b/action/action.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "sync" + "time" "git.lxtend.com/qqbot/message" "git.lxtend.com/qqbot/model" @@ -49,6 +50,9 @@ func (am *actionManager) SendMsg(reply model.Reply) error { if err != nil { return err } + for !am.Started() { + time.Sleep(100 * time.Millisecond) + } if err = am.botConn.WriteMessage(websocket.TextMessage, sendPkgJson); err != nil { return err } diff --git a/handler/init/init.go b/handler/init/init.go new file mode 100644 index 0000000..684a20c --- /dev/null +++ b/handler/init/init.go @@ -0,0 +1,18 @@ +package init + +import ( + "git.lxtend.com/qqbot/action" + "git.lxtend.com/qqbot/config" + "git.lxtend.com/qqbot/model" +) + +func init() { + action.ActionManager.SendMsg(model.Reply{ + ReplyMsg: "初始化完成", + FromMsg: model.Message{ + GroupInfo: model.GroupInfo{ + GroupId: config.ConfigManager.GetConfig().Management.ReportGroup, + }, + }, + }) +}