mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-12 06:45:46 +08:00
fix event push error.
This commit is contained in:
parent
08694f5ae8
commit
a6bcd96415
@ -385,7 +385,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
|
||||
}
|
||||
data = b
|
||||
}
|
||||
if !global.IsAMR(data) {
|
||||
if !global.IsAMRorSILK(data) {
|
||||
return nil, errors.New("unsupported voice file format (please use AMR file for now)")
|
||||
}
|
||||
return &message.VoiceElement{Data: data}, nil
|
||||
|
@ -13,6 +13,7 @@ var (
|
||||
IMAGE_PATH = path.Join("data", "images")
|
||||
VOICE_PATH = path.Join("data", "voices")
|
||||
VIDEO_PATH = path.Join("data", "videos")
|
||||
CACHE_PATH = path.Join("data", "cache")
|
||||
|
||||
HEADER_AMR = []byte("#!AMR")
|
||||
HEADER_SILK = []byte("\x02#!SILK_V3")
|
||||
@ -41,6 +42,6 @@ func Check(err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func IsAMR(b []byte) bool {
|
||||
func IsAMRorSILK(b []byte) bool {
|
||||
return bytes.HasPrefix(b, HEADER_AMR) || bytes.HasPrefix(b, HEADER_SILK)
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func (c *websocketClient) connectEvent() {
|
||||
log.Warnf("连接到反向Websocket Event服务器 %v 时出现错误: %v", c.conf.ReverseEventUrl, err)
|
||||
if c.conf.ReverseReconnectInterval != 0 {
|
||||
time.Sleep(time.Millisecond * time.Duration(c.conf.ReverseReconnectInterval))
|
||||
c.connectApi()
|
||||
c.connectEvent()
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -180,7 +180,7 @@ func (c *websocketClient) onBotPushEvent(m coolq.MSG) {
|
||||
defer c.pushLock.Unlock()
|
||||
if c.eventConn != nil {
|
||||
log.Debugf("向WS服务器 %v 推送Event: %v", c.eventConn.RemoteAddr().String(), m.ToJson())
|
||||
if err := c.eventConn.WriteJSON(m.ToJson()); err != nil {
|
||||
if err := c.eventConn.WriteJSON(m); err != nil {
|
||||
log.Warnf("向WS服务器 %v 推送Event时出现错误: %v", c.eventConn.RemoteAddr().String(), err)
|
||||
_ = c.eventConn.Close()
|
||||
if c.conf.ReverseReconnectInterval != 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user