Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
go-cqhttp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
go-cqhttp
Commits
a6bcd964
Commit
a6bcd964
authored
Aug 20, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix event push error.
parent
08694f5a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
coolq/cqcode.go
coolq/cqcode.go
+1
-1
global/fs.go
global/fs.go
+2
-1
server/websocket.go
server/websocket.go
+2
-2
No files found.
coolq/cqcode.go
View file @
a6bcd964
...
...
@@ -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
.
IsAMR
orSILK
(
data
)
{
return
nil
,
errors
.
New
(
"unsupported voice file format (please use AMR file for now)"
)
}
return
&
message
.
VoiceElement
{
Data
:
data
},
nil
...
...
global/fs.go
View file @
a6bcd964
...
...
@@ -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
IsAMR
orSILK
(
b
[]
byte
)
bool
{
return
bytes
.
HasPrefix
(
b
,
HEADER_AMR
)
||
bytes
.
HasPrefix
(
b
,
HEADER_SILK
)
}
server/websocket.go
View file @
a6bcd964
...
...
@@ -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
.
connect
Api
()
c
.
connect
Event
()
}
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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment