Skip to content

Commit

Permalink
Merge 2db3c5e into 886e797
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko authored Jun 28, 2024
2 parents 886e797 + 2db3c5e commit e3ad8d0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Processor/Processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,9 +1104,11 @@ func generateMdByConfig() (md *dto.Markdown, kb *keyboard.MessageKeyboard) {
linkBots := config.GetLinkBots()
imgURL := config.GetLinkPic()

//超过16个时候随机显示
if len(linkBots) > 16 {
linkBots = getRandomSelection(linkBots, 16)
linknum := config.GetLinkNum()

//超过n个时候随机显示
if len(linkBots) > linknum {
linkBots = getRandomSelection(linkBots, linknum)
}

var mdParams []*dto.MarkdownParams
Expand Down
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2327,3 +2327,16 @@ func GetLinkLines() int {

return instance.Settings.LinkLines
}

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

if instance == nil {
mylog.Println("Warning: instance is nil when trying to LinkNum value.")
return 6 //默认6个
}

return instance.Settings.LinkNum
}
1 change: 1 addition & 0 deletions structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ type Settings struct {
LinkText string `yaml:"link_text"`
LinkPic string `yaml:"link_pic"`
LinkLines int `yaml:"link_lines"`
LinkNum int `yaml:"link_num"`
//HTTP API配置
HttpAddress string `yaml:"http_address"`
AccessToken string `yaml:"http_access_token"`
Expand Down
1 change: 1 addition & 0 deletions template/config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ settings:
link_text : "" #友情链接文本 不可为空!
link_pic : "" #友情链接图片 可为空 需url图片 可带端口 不填可能会有显示错误
link_lines : 2 #内置的/link指令按钮列数(默认一行2个按钮)
link_num : 6 #在link_bots随机选n个bot上友情链接,在link_bots中随机n个,避免用户选择困难,少即是多
#HTTP API配置-正向http
http_address: "" #http监听地址 与websocket独立 示例:0.0.0.0:5700 为空代表不开启
Expand Down

0 comments on commit e3ad8d0

Please sign in to comment.