feat: 在 actionManager 中添加等待机制,确保在发送消息前 bot 已启动;新增初始化处理程序以发送初始化完成消息

This commit is contained in:
lixiangwuxian
2025-03-24 23:29:14 +08:00
parent c72817aee6
commit 6715d8324c
2 changed files with 22 additions and 0 deletions

View File

@@ -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
}