diff --git a/action/action.go b/action/action.go index 6fc3e8e..c692d29 100644 --- a/action/action.go +++ b/action/action.go @@ -3,6 +3,7 @@ package action import ( "encoding/json" "fmt" + "sync" "git.lxtend.com/qqbot/message" "git.lxtend.com/qqbot/model" @@ -16,6 +17,7 @@ var ActionManager = actionManager{} type actionManager struct { botConn *websocket.Conn + sendMtx sync.Mutex } func (am *actionManager) Started() bool { @@ -31,6 +33,8 @@ func (am *actionManager) SendAction(action string) error { } func (am *actionManager) SendMsg(reply model.Reply) error { + am.sendMtx.Lock() + defer am.sendMtx.Unlock() if reply.ReferOriginMsg { replyMsg := message.ReplyMessage{ Type: "reply",