1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

feature sso address control.

This commit is contained in:
Mrs4s 2020-11-12 23:07:34 +08:00
parent 0ed6522535
commit 535b4ee641
6 changed files with 18 additions and 5 deletions

View File

@ -36,6 +36,7 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
"ignore_invalid_cqcode": false,
"force_fragmented": true,
"heartbeat_interval": 5,
"use_sso_address": false,
"http_config": {
"enabled": true,
"host": "0.0.0.0",
@ -77,6 +78,7 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
| post_message_format | string | 上报信息类型 |
| ignore_invalid_cqcode| bool | 是否忽略错误的CQ码 |
| force_fragmented | bool | 是否强制分片发送群长消息 |
| use_sso_address | bool | 是否使用服务器下发的地址 |
| heartbeat_interval | int64 | 心跳间隔时间单位秒。小于0则关闭心跳等于0使用默认值(5秒) |
| http_config | object | HTTP API配置 |
| ws_config | object | Websocket API 配置 |

View File

@ -33,6 +33,7 @@ type JsonConfig struct {
WSConfig *GoCQWebsocketConfig `json:"ws_config"`
ReverseServers []*GoCQReverseWebsocketConfig `json:"ws_reverse_servers"`
PostMessageFormat string `json:"post_message_format"`
UseSSOAddress bool `json:"use_sso_address"`
Debug bool `json:"debug"`
LogLevel string `json:"log_level"`
WebUi *GoCqWebUi `json:"web_ui"`

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-20201112125100-c41a3dbb0f4a
github.com/Mrs4s/MiraiGo v0.0.0-20201112150130-58e7c82fd2dd
github.com/dustin/go-humanize v1.0.0
github.com/getlantern/go-update v0.0.0-20190510022740-79c495ab728c
github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9 // indirect

4
go.sum
View File

@ -1,7 +1,7 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mrs4s/MiraiGo v0.0.0-20201112125100-c41a3dbb0f4a h1:6AESfMoGUVTMsgbs4tCE68fXOQq6PUyPTEy6JBX46So=
github.com/Mrs4s/MiraiGo v0.0.0-20201112125100-c41a3dbb0f4a/go.mod h1:pAsWtMIwqkBXr5DkUpTIHoWQJNduVnX9WSBPmPvkuCs=
github.com/Mrs4s/MiraiGo v0.0.0-20201112150130-58e7c82fd2dd h1:n1llMhWgT5s/dBWtbg0NwDzXFAKWfwr1ZXxaErZkLfc=
github.com/Mrs4s/MiraiGo v0.0.0-20201112150130-58e7c82fd2dd/go.mod h1:pAsWtMIwqkBXr5DkUpTIHoWQJNduVnX9WSBPmPvkuCs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

View File

@ -246,8 +246,13 @@ func main() {
log.Debug("Protocol -> " + e.Message)
}
})
cli.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) {
cli.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) bool {
if !conf.UseSSOAddress {
log.Infof("收到服务器地址更新通知, 根据配置文件已忽略.")
return false
}
log.Infof("收到服务器地址更新通知, 将在下一次重连时应用. ")
return true
})
if conf.WebUi == nil {
conf.WebUi = &global.GoCqWebUi{

View File

@ -358,8 +358,13 @@ func (s *webServer) DoReLogin() { // TODO: 协议层的 ReLogin
log.Debug("Protocol -> " + e.Message)
}
})
cli.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) {
cli.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) bool {
if !conf.UseSSOAddress {
log.Infof("收到服务器地址更新通知, 根据配置文件已忽略.")
return false
}
log.Infof("收到服务器地址更新通知, 将在下一次重连时应用. ")
return true
})
s.Cli = cli
s.Dologin()