Skip to content

Commit

Permalink
Beta93 (#246)
Browse files Browse the repository at this point in the history
* beta88

* beta89

* bugfix

* beta90

* beta91

* beta92

* beta93
  • Loading branch information
Hoshinonyaruko authored Dec 16, 2023
1 parent b0ac7a8 commit 98e3201
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type Settings struct {
NativeOb11 bool `yaml:"native_ob11"`
RamDomSeq bool `yaml:"ramdom_seq"`
UrlToQrimage bool `yaml:"url_to_qrimage"`
QrSize int `yaml:"qr_size"`
}

// LoadConfig 从文件中加载配置并初始化单例配置
Expand Down Expand Up @@ -1260,3 +1261,15 @@ func GetUrlToQrimage() bool {
}
return instance.Settings.UrlToQrimage
}

// 获取GetQrSize的值
func GetQrSize() int {
mu.Lock()
defer mu.Unlock()

if instance == nil {
mylog.Println("Warning: instance is nil when trying to QrSize value.")
return 200
}
return instance.Settings.QrSize
}
3 changes: 2 additions & 1 deletion handlers/message_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ func transformMessageTextUrl(messageText string, message callapi.ActionMessage,
// 将URL转换为QR码的字节形式
qrCodeGenerator, _ := qrcode.New(originalURL, qrcode.High)
qrCodeGenerator.DisableBorder = true
pngBytes, _ := qrCodeGenerator.PNG(37)
qrSize := config.GetQrSize()
pngBytes, _ := qrCodeGenerator.PNG(qrSize)
//pngBytes 二维码图片的字节数据
base64Image := base64.StdEncoding.EncodeToString(pngBytes)
picmsg := processActionMessageWithBase64PicReplace(base64Image, message)
Expand Down
1 change: 1 addition & 0 deletions template/config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ settings:
native_ob11 : false #如果你的机器人收到事件报错,请开启此选项增加兼容性
ramdom_seq : false #当多开gensokyo时,如果遇到群信息只能发出一条,请开启每个gsk的此项.(建议使用一个gsk连接多个应用)
url_to_qrimage : false #将信息中的url转换为二维码单独作为图片发出,需要同时设置 #SSL配置类 机器人发送URL设置 的 transfer_url 为 true
qr_size : 200 #二维码尺寸,单位像素
#正向ws设置
ws_server_path : "ws" #默认监听0.0.0.0:port/ws_server_path 若有安全需求,可不放通port到公网,或设置ws_server_token 若想监听/ 可改为"",若想监听到不带/地址请写nil
Expand Down
1 change: 1 addition & 0 deletions template/config_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ settings:
native_ob11 : false #如果你的机器人收到事件报错,请开启此选项增加兼容性
ramdom_seq : false #当多开gensokyo时,如果遇到群信息只能发出一条,请开启每个gsk的此项.(建议使用一个gsk连接多个应用)
url_to_qrimage : false #将信息中的url转换为二维码单独作为图片发出,需要同时设置 #SSL配置类 机器人发送URL设置 的 transfer_url 为 true
qr_size : 200 #二维码尺寸,单位像素

0 comments on commit 98e3201

Please sign in to comment.