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
847711cd
Commit
847711cd
authored
Jul 25, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reconnect supported.
parent
82e2ea84
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
9 deletions
+28
-9
global/config.go
global/config.go
+8
-8
main.go
main.go
+20
-1
No files found.
global/config.go
View file @
847711cd
...
@@ -6,14 +6,14 @@ import (
...
@@ -6,14 +6,14 @@ import (
)
)
type
JsonConfig
struct
{
type
JsonConfig
struct
{
Uin
int64
`json:"uin"`
Uin
int64
`json:"uin"`
Password
string
`json:"password"`
Password
string
`json:"password"`
EnableDB
bool
`json:"enable_db"`
EnableDB
bool
`json:"enable_db"`
AccessToken
string
`json:"access_token"`
AccessToken
string
`json:"access_token"`
//Reconnect bool
`json:"reconnect"`
Reconnect
bool
`json:"reconnect"`
//ReconnectDelay int
`json:"reconnect_delay"`
ReconnectDelay
int
`json:"reconnect_delay"`
HttpConfig
*
GoCQHttpConfig
`json:"http_config"`
HttpConfig
*
GoCQHttpConfig
`json:"http_config"`
WSConfig
*
GoCQWebsocketConfig
`json:"ws_config"`
WSConfig
*
GoCQWebsocketConfig
`json:"ws_config"`
}
}
type
CQHttpApiConfig
struct
{
type
CQHttpApiConfig
struct
{
...
...
main.go
View file @
847711cd
...
@@ -140,8 +140,27 @@ func main() {
...
@@ -140,8 +140,27 @@ func main() {
log
.
Info
(
"资源初始化完成, 开始处理信息."
)
log
.
Info
(
"资源初始化完成, 开始处理信息."
)
log
.
Info
(
"アトリは、高性能ですから!"
)
log
.
Info
(
"アトリは、高性能ですから!"
)
cli
.
OnDisconnected
(
func
(
bot
*
client
.
QQClient
,
e
*
client
.
ClientDisconnectedEvent
)
{
cli
.
OnDisconnected
(
func
(
bot
*
client
.
QQClient
,
e
*
client
.
ClientDisconnectedEvent
)
{
if
conf
.
Reconnect
{
log
.
Warnf
(
"Bot已离线,将在 %v 秒后尝试重连."
,
conf
.
ReconnectDelay
)
time
.
Sleep
(
time
.
Second
*
time
.
Duration
(
conf
.
ReconnectDelay
))
rsp
,
err
:=
cli
.
Login
()
if
err
!=
nil
{
log
.
Fatalf
(
"重连失败: %v"
,
err
)
}
if
!
rsp
.
Success
{
switch
rsp
.
Error
{
case
client
.
NeedCaptcha
:
log
.
Fatalf
(
"重连失败: 需要验证码. (验证码处理正在开发中)"
)
case
client
.
UnsafeDeviceError
:
log
.
Fatalf
(
"重连失败: 设备锁"
)
default
:
log
.
Fatalf
(
"重连失败: %v"
,
rsp
.
ErrorMessage
)
}
}
return
}
b
.
Release
()
b
.
Release
()
log
.
Fatalf
(
"Bot已
断线:
"
,
e
.
Message
)
log
.
Fatalf
(
"Bot已
离线:%v
"
,
e
.
Message
)
})
})
c
:=
make
(
chan
os
.
Signal
,
1
)
c
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
c
,
os
.
Interrupt
,
os
.
Kill
)
signal
.
Notify
(
c
,
os
.
Interrupt
,
os
.
Kill
)
...
...
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