feat: 在 actionManager 中添加等待机制,确保在发送消息前 bot 已启动;新增初始化处理程序以发送初始化完成消息
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user