fix: Update configuration structure to include Management section for WebSocket and HTTP server addresses
This commit is contained in:
parent
a13eaaf5a4
commit
f87922883e
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func GetGroupMemberList(groupID int64) ([]model.GroupMember, error) {
|
||||
fullURL := fmt.Sprintf("http://%s%s?group_id=%d", config.ConfigManager.GetConfig().NapcatHttpSrv, constants.GET_GROUP_MEMBER_LIST, groupID)
|
||||
fullURL := fmt.Sprintf("http://%s%s?group_id=%d", config.ConfigManager.GetConfig().Management.NapcatHttpSrv, constants.GET_GROUP_MEMBER_LIST, groupID)
|
||||
|
||||
response, err := http.Get(fullURL)
|
||||
if err != nil {
|
||||
@ -35,7 +35,7 @@ func GetGroupMemberList(groupID int64) ([]model.GroupMember, error) {
|
||||
}
|
||||
|
||||
func GetGroupList() ([]model.Group, error) {
|
||||
fullURL := fmt.Sprintf("http://%s%s", config.ConfigManager.GetConfig().NapcatHttpSrv, constants.GET_GROUP_LIST)
|
||||
fullURL := fmt.Sprintf("http://%s%s", config.ConfigManager.GetConfig().Management.NapcatHttpSrv, constants.GET_GROUP_LIST)
|
||||
|
||||
response, err := http.Get(fullURL)
|
||||
if err != nil {
|
||||
|
@ -9,15 +9,18 @@ import (
|
||||
var ConfigManager = &configManager{}
|
||||
|
||||
type Config struct {
|
||||
Admin int64 `yaml:"admin"`
|
||||
SteamApiKey string `yaml:"steam_api_key"`
|
||||
ProxyAddr string `yaml:"proxy_addr"`
|
||||
NapcatWsSrv string `yaml:"napcat_ws_srv"`
|
||||
NapcatHttpSrv string `yaml:"napcat_http_srv"`
|
||||
OpenaiApiKey string `yaml:"openai_api_key"`
|
||||
OpenaiApiBaseUrl string `yaml:"openai_api_base_url"`
|
||||
OpenaiModelName string `yaml:"openai_model_name"`
|
||||
OpenaiPrompt string `yaml:"openai_prompt"`
|
||||
Management struct {
|
||||
Admin int64 `yaml:"admin"`
|
||||
ReportGroup int64 `yaml:"report_group"`
|
||||
ProxyAddr string `yaml:"proxy_addr"`
|
||||
NapcatWsSrv string `yaml:"napcat_ws_srv"`
|
||||
NapcatHttpSrv string `yaml:"napcat_http_srv"`
|
||||
} `yaml:"management"`
|
||||
WebServer struct {
|
||||
Token string `yaml:"token"`
|
||||
} `yaml:"web_server"`
|
||||
|
@ -20,7 +20,7 @@ var ProxyAddr = ""
|
||||
|
||||
func init() {
|
||||
SteamAPIKey = config.ConfigManager.GetConfig().SteamApiKey
|
||||
ProxyAddr = config.ConfigManager.GetConfig().ProxyAddr
|
||||
ProxyAddr = config.ConfigManager.GetConfig().Management.ProxyAddr
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
2
main.go
2
main.go
@ -51,7 +51,7 @@ func main() {
|
||||
go func() {
|
||||
const reconnectDelay = 5 * time.Second
|
||||
for {
|
||||
client, err := wsclient.NewWebSocketClient("ws", config.ConfigManager.GetConfig().NapcatWsSrv, "")
|
||||
client, err := wsclient.NewWebSocketClient("ws", config.ConfigManager.GetConfig().Management.NapcatWsSrv, "")
|
||||
if err != nil {
|
||||
log.Printf("WebSocket连接失败: %v, %v 后重试", err, reconnectDelay)
|
||||
time.Sleep(reconnectDelay)
|
||||
|
Loading…
x
Reference in New Issue
Block a user