Skip to content

Commit

Permalink
refactor: configurable wsrv server and fix output format in inline query
Browse files Browse the repository at this point in the history
  • Loading branch information
krau committed Nov 16, 2024
1 parent 558ddde commit 278208b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config/viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

type Config struct {
Debug bool `toml:"debug" mapstructure:"debug" json:"debug" yaml:"debug"`
WSRVURL string `toml:"wsrv_url" mapstructure:"wsrv_url" json:"wsrv_url" yaml:"wsrv_url"`
API apiConfig `toml:"api" mapstructure:"api" json:"api" yaml:"api"`
Auth authConfig `toml:"auth" mapstructure:"auth" json:"auth" yaml:"auth"`
Fetcher fetcherConfig `toml:"fetcher" mapstructure:"fetcher" json:"fetcher" yaml:"fetcher"`
Expand All @@ -32,6 +33,8 @@ func InitConfig() {
viper.AddConfigPath(".")
viper.SetConfigType("toml")

viper.SetDefault("wsrv_url", "https://wsrv.nl")

viper.SetDefault("api.address", "0.0.0.0:39080")
viper.SetDefault("api.site_name", "ManyACG")
viper.SetDefault("api.site_title", "ManyACG - ACG Picture Collection")
Expand Down
3 changes: 2 additions & 1 deletion telegram/handlers/inline_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/krau/ManyACG/adapter"
"github.com/krau/ManyACG/common"
"github.com/krau/ManyACG/config"
"github.com/krau/ManyACG/service"
"github.com/krau/ManyACG/sources"
"github.com/krau/ManyACG/telegram/utils"
Expand Down Expand Up @@ -36,7 +37,7 @@ func InlineQuery(ctx context.Context, bot *telego.Bot, query telego.InlineQuery)
continue
}
result := telegoutil.ResultPhoto(uuid.NewString(),
fmt.Sprintf("https://wsrv.nl/?url=%s&w=2560&h=2560&we",
fmt.Sprintf("%s/?url=%s&w=2560&h=2560&we&output=jpg", config.Cfg.WSRVURL,
picture.Original), picture.Thumbnail).WithCaption(caption).WithParseMode(telego.ModeHTML)
results = append(results, result)
}
Expand Down

0 comments on commit 278208b

Please sign in to comment.