feat: 在 actionManager 中添加等待机制,确保在发送消息前 bot 已启动;新增初始化处理程序以发送初始化完成消息
This commit is contained in:
parent
c72817aee6
commit
6715d8324c
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.lxtend.com/qqbot/message"
|
"git.lxtend.com/qqbot/message"
|
||||||
"git.lxtend.com/qqbot/model"
|
"git.lxtend.com/qqbot/model"
|
||||||
@ -49,6 +50,9 @@ func (am *actionManager) SendMsg(reply model.Reply) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
for !am.Started() {
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
}
|
||||||
if err = am.botConn.WriteMessage(websocket.TextMessage, sendPkgJson); err != nil {
|
if err = am.botConn.WriteMessage(websocket.TextMessage, sendPkgJson); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
18
handler/init/init.go
Normal file
18
handler/init/init.go
Normal file
@ -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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user