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
a075f41a
Commit
a075f41a
authored
Aug 11, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http post timeout setting supported. close #77
parent
cdbf9033
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
global/config.go
global/config.go
+1
-0
main.go
main.go
+1
-1
server/http.go
server/http.go
+10
-5
No files found.
global/config.go
View file @
a075f41a
...
...
@@ -43,6 +43,7 @@ type GoCQHttpConfig struct {
Enabled
bool
`json:"enabled"`
Host
string
`json:"host"`
Port
uint16
`json:"port"`
Timeout
int32
`json:"timeout"`
PostUrls
map
[
string
]
string
`json:"post_urls"`
PostMessageFormat
string
`json:"post_message_format"`
}
...
...
main.go
View file @
a075f41a
...
...
@@ -201,7 +201,7 @@ func main() {
coolq
.
SetMessageFormat
(
conf
.
HttpConfig
.
PostMessageFormat
)
}
for
k
,
v
:=
range
conf
.
HttpConfig
.
PostUrls
{
server
.
NewHttpClient
()
.
Run
(
k
,
v
,
b
)
server
.
NewHttpClient
()
.
Run
(
k
,
v
,
conf
.
HttpConfig
.
Timeout
,
b
)
}
}
if
conf
.
WSConfig
!=
nil
&&
conf
.
WSConfig
.
Enabled
{
...
...
server/http.go
View file @
a075f41a
...
...
@@ -21,9 +21,10 @@ type httpServer struct {
}
type
httpClient
struct
{
bot
*
coolq
.
CQBot
secret
string
addr
string
bot
*
coolq
.
CQBot
secret
string
addr
string
timeout
int32
}
var
HttpServer
=
&
httpServer
{}
...
...
@@ -163,10 +164,14 @@ func NewHttpClient() *httpClient {
return
&
httpClient
{}
}
func
(
c
*
httpClient
)
Run
(
addr
,
secret
string
,
bot
*
coolq
.
CQBot
)
{
func
(
c
*
httpClient
)
Run
(
addr
,
secret
string
,
timeout
int32
,
bot
*
coolq
.
CQBot
)
{
c
.
bot
=
bot
c
.
secret
=
secret
c
.
addr
=
addr
c
.
timeout
=
timeout
if
c
.
timeout
<
5
{
c
.
timeout
=
5
}
bot
.
OnEventPush
(
c
.
onBotPushEvent
)
log
.
Infof
(
"HTTP POST上报器已启动: %v"
,
addr
)
}
...
...
@@ -184,7 +189,7 @@ func (c *httpClient) onBotPushEvent(m coolq.MSG) {
h
[
"X-Signature"
]
=
"sha1="
+
hex
.
EncodeToString
(
mac
.
Sum
(
nil
))
}
return
h
}())
.
SetTimeout
(
time
.
Second
*
5
)
.
Do
()
}())
.
SetTimeout
(
time
.
Second
*
time
.
Duration
(
c
.
timeout
)
)
.
Do
()
if
err
!=
nil
{
log
.
Warnf
(
"上报Event数据到 %v 失败: %v"
,
c
.
addr
,
err
)
return
...
...
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