mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-07 04:23:49 +08:00
fix #89.
This commit is contained in:
parent
5e49820319
commit
3c04573e82
@ -85,7 +85,7 @@ func (bot *CQBot) GetGroupMessage(mid int32) MSG {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
log.Warnf("获取信息时出现错误: %v", err)
|
log.Warnf("获取信息时出现错误: %v id: %v", err, mid)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ type JsonConfig struct {
|
|||||||
HttpConfig *GoCQHttpConfig `json:"http_config"`
|
HttpConfig *GoCQHttpConfig `json:"http_config"`
|
||||||
WSConfig *GoCQWebsocketConfig `json:"ws_config"`
|
WSConfig *GoCQWebsocketConfig `json:"ws_config"`
|
||||||
ReverseServers []*GoCQReverseWebsocketConfig `json:"ws_reverse_servers"`
|
ReverseServers []*GoCQReverseWebsocketConfig `json:"ws_reverse_servers"`
|
||||||
|
PostMessageFormat string `json:"post_message_format"`
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,12 +41,11 @@ type CQHttpApiConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GoCQHttpConfig struct {
|
type GoCQHttpConfig struct {
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
Port uint16 `json:"port"`
|
Port uint16 `json:"port"`
|
||||||
Timeout int32 `json:"timeout"`
|
Timeout int32 `json:"timeout"`
|
||||||
PostUrls map[string]string `json:"post_urls"`
|
PostUrls map[string]string `json:"post_urls"`
|
||||||
PostMessageFormat string `json:"post_message_format"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GoCQWebsocketConfig struct {
|
type GoCQWebsocketConfig struct {
|
||||||
|
16
main.go
16
main.go
@ -96,18 +96,18 @@ func main() {
|
|||||||
Uin: uin,
|
Uin: uin,
|
||||||
Password: pwd,
|
Password: pwd,
|
||||||
HttpConfig: &global.GoCQHttpConfig{
|
HttpConfig: &global.GoCQHttpConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Host: "0.0.0.0",
|
Host: "0.0.0.0",
|
||||||
Port: 5700,
|
Port: 5700,
|
||||||
PostUrls: map[string]string{},
|
PostUrls: map[string]string{},
|
||||||
PostMessageFormat: "string",
|
|
||||||
},
|
},
|
||||||
WSConfig: &global.GoCQWebsocketConfig{
|
WSConfig: &global.GoCQWebsocketConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Host: "0.0.0.0",
|
Host: "0.0.0.0",
|
||||||
Port: 6700,
|
Port: 6700,
|
||||||
},
|
},
|
||||||
Debug: os.Getenv("DEBUG") == "true",
|
PostMessageFormat: "string",
|
||||||
|
Debug: os.Getenv("DEBUG") == "true",
|
||||||
}
|
}
|
||||||
if post != "" {
|
if post != "" {
|
||||||
conf.HttpConfig.PostUrls[post] = os.Getenv("HTTP_SECRET")
|
conf.HttpConfig.PostUrls[post] = os.Getenv("HTTP_SECRET")
|
||||||
@ -200,11 +200,11 @@ func main() {
|
|||||||
b := coolq.NewQQBot(cli, conf)
|
b := coolq.NewQQBot(cli, conf)
|
||||||
if conf.HttpConfig != nil && conf.HttpConfig.Enabled {
|
if conf.HttpConfig != nil && conf.HttpConfig.Enabled {
|
||||||
server.HttpServer.Run(fmt.Sprintf("%s:%d", conf.HttpConfig.Host, conf.HttpConfig.Port), conf.AccessToken, b)
|
server.HttpServer.Run(fmt.Sprintf("%s:%d", conf.HttpConfig.Host, conf.HttpConfig.Port), conf.AccessToken, b)
|
||||||
if conf.HttpConfig.PostMessageFormat != "string" && conf.HttpConfig.PostMessageFormat != "array" {
|
if conf.PostMessageFormat != "string" && conf.PostMessageFormat != "array" {
|
||||||
log.Warnf("http_config.post_message_format 配置错误, 将自动使用 string")
|
log.Warnf("http_config.post_message_format 配置错误, 将自动使用 string")
|
||||||
coolq.SetMessageFormat("string")
|
coolq.SetMessageFormat("string")
|
||||||
} else {
|
} else {
|
||||||
coolq.SetMessageFormat(conf.HttpConfig.PostMessageFormat)
|
coolq.SetMessageFormat(conf.PostMessageFormat)
|
||||||
}
|
}
|
||||||
for k, v := range conf.HttpConfig.PostUrls {
|
for k, v := range conf.HttpConfig.PostUrls {
|
||||||
server.NewHttpClient().Run(k, v, conf.HttpConfig.Timeout, b)
|
server.NewHttpClient().Run(k, v, conf.HttpConfig.Timeout, b)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user