Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta54 #167

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type Settings struct {
AddAtGroup bool `yaml:"add_at_group"`
UrlPicTransfer bool `yaml:"url_pic_transfer"`
LotusPassword string `yaml:"lotus_password"`
WsServerPath string `yaml:"ws_server_path"`
}

// LoadConfig 从文件中加载配置并初始化单例配置
Expand Down Expand Up @@ -963,3 +964,15 @@ func GetLotusPassword() string {
}
return instance.Settings.LotusPassword
}

// 获取GetWsServerPath的值
func GetWsServerPath() string {
mu.Lock()
defer mu.Unlock()

if instance == nil {
mylog.Println("Warning: instance is nil when trying to GetWsServerPath value.")
return ""
}
return instance.Settings.WsServerPath
}
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ func main() {
//正向ws
if conf.Settings.AppID != 12345 {
if conf.Settings.EnableWsServer {
r.GET("/ws", server.WsHandlerWithDependencies(api, apiV2, p))
log.Println("正向ws启动成功,监听0.0.0.0:" + serverPort + " 请注意设置ws_server_token,并对外放通端口...")
wspath := config.GetWsServerPath()
r.GET("/"+wspath, server.WsHandlerWithDependencies(api, apiV2, p))
log.Println("正向ws启动成功,监听0.0.0.0:" + serverPort + "/" + wspath + "请注意设置ws_server_token,并对外放通端口...")
}
}
r.POST("/url", url.CreateShortURLHandler)
Expand Down
6 changes: 3 additions & 3 deletions template/config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ settings:
record_bitRate : 24000 #语音文件的比特率 默认25000 代表 25 kbps 最高无限 请根据带宽 您发送的实际码率调整

#正向ws设置

enable_ws_server: true #是否启用正向ws服务器 监听server_dir:port/ws
ws_server_token : "12345" #正向ws的token 不启动正向ws可忽略
ws_server_path : "ws" #默认监听0.0.0.0:port/ws_server_path 若有安全需求,可不放通port到公网,或设置ws_server_token 若想监听/ 可改为""
enable_ws_server: true #是否启用正向ws服务器 监听server_dir:port/ws_server_path
ws_server_token : "12345" #正向ws的token 不启动正向ws可忽略 可为空

#SSL配置类 机器人发送URL设置

Expand Down
8 changes: 4 additions & 4 deletions template/config_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ settings:
# 使用它提供的图床和idmaps服务(场景:同一个机器人在不同服务器运行,或内网需要发送base64图)。
# 如果需要发送base64图片,需要设置正确的公网server_dir和开放对应的port
master_id : ["1","2"] #群场景尚未开放获取管理员和列表能力,手动从日志中获取需要设置为管理,的user_id并填入(适用插件有权限判断场景)
enable_ws_server: true #是否启用正向ws服务器 监听server_dir:port/ws
ws_server_token : "12345" #正向ws的token 不启动正向ws可忽略
ws_server_token : "12345" #正向ws的token 不启动正向ws可忽略
enable_ws_server: true #是否启用正向ws服务器 监听server_dir:port/ws_server_path
ws_server_token : "12345" #正向ws的token 不启动正向ws可忽略 可为""
identify_file: true #自动生成域名校验文件,在q.qq.com配置信息URL,在server_dir填入自己已备案域名,正确解析到机器人所在服务器ip地址,机器人即可发送链接
crt: "" #证书路径 从你的域名服务商或云服务商申请签发SSL证书(qq要求SSL)
key: "" #密钥路径 Apache(crt文件、key文件)示例: "C:\\123.key" \需要双写成\\
Expand Down Expand Up @@ -72,4 +71,5 @@ settings:
send_error : true #将报错用文本发出,避免机器人被审核报无响应
add_at_group : false #自动在群聊指令前加上at,某些机器人写法特别,必须有at才反应时,请打开,默认请关闭(如果需要at,不需要at指令混杂,请优化代码适配群场景,群场景目前没有at概念
url_pic_transfer : false #把图片url(任意来源图链)变成你备案的白名单url 需要较高上下行+ssl+自备案域名+设置白名单域名(暂时不需要)
lotus_password : "" # lotus鉴权 设置后,从gsk需要保持相同密码来访问主gsk
lotus_password : "" # lotus鉴权 设置后,从gsk需要保持相同密码来访问主gsk
ws_server_path : "ws" #默认监听0.0.0.0:port/ws_server_path 若有安全需求,可不放通port到公网,或设置ws_server_token 若想监听/ 可改为""
Loading