Skip to content

Commit

Permalink
feat: add Telegram storage integration and configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
krau committed Feb 27, 2025
1 parent 87e5ff7 commit 40ac57c
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 51 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ cache/
downloads/
tmp/
.air.toml
.vscode/
.vscode/
*session.db
30 changes: 19 additions & 11 deletions config/storage.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package config

type storageConfigs struct {
OriginalType string `toml:"original_type" mapstructure:"original_type" json:"original_type" yaml:"original_type"`
RegularType string `toml:"regular_type" mapstructure:"regular_type" json:"regular_type" yaml:"regular_type"`
RegularFormat string `toml:"regular_format" mapstructure:"regular_format" json:"regular_format" yaml:"regular_format"`
ThumbType string `toml:"thumb_type" mapstructure:"thumb_type" json:"thumb_type" yaml:"thumb_type"`
ThumbFormat string `toml:"thumb_format" mapstructure:"thumb_format" json:"thumb_format" yaml:"thumb_format"`
CacheDir string `toml:"cache_dir" mapstructure:"cache_dir" json:"cache_dir" yaml:"cache_dir"`
CacheTTL uint `toml:"cache_ttl" mapstructure:"cache_ttl" json:"cache_ttl" yaml:"cache_ttl"`
Rules []storageRuleConfig `toml:"rules" mapstructure:"rules" json:"rules" yaml:"rules"`
Webdav StorageWebdavConfig `toml:"webdav" mapstructure:"webdav" json:"webdav" yaml:"webdav"`
Local StorageLocalConfig `toml:"local" mapstructure:"local" json:"local" yaml:"local"`
Alist StorageAlistConfig `toml:"alist" mapstructure:"alist" json:"alist" yaml:"alist"`
OriginalType string `toml:"original_type" mapstructure:"original_type" json:"original_type" yaml:"original_type"`
RegularType string `toml:"regular_type" mapstructure:"regular_type" json:"regular_type" yaml:"regular_type"`
RegularFormat string `toml:"regular_format" mapstructure:"regular_format" json:"regular_format" yaml:"regular_format"`
ThumbType string `toml:"thumb_type" mapstructure:"thumb_type" json:"thumb_type" yaml:"thumb_type"`
ThumbFormat string `toml:"thumb_format" mapstructure:"thumb_format" json:"thumb_format" yaml:"thumb_format"`
CacheDir string `toml:"cache_dir" mapstructure:"cache_dir" json:"cache_dir" yaml:"cache_dir"`
CacheTTL uint `toml:"cache_ttl" mapstructure:"cache_ttl" json:"cache_ttl" yaml:"cache_ttl"`
Rules []storageRuleConfig `toml:"rules" mapstructure:"rules" json:"rules" yaml:"rules"`
Webdav StorageWebdavConfig `toml:"webdav" mapstructure:"webdav" json:"webdav" yaml:"webdav"`
Local StorageLocalConfig `toml:"local" mapstructure:"local" json:"local" yaml:"local"`
Alist StorageAlistConfig `toml:"alist" mapstructure:"alist" json:"alist" yaml:"alist"`
Telegram StorageTelegramConfig `toml:"telegram" mapstructure:"telegram" json:"telegram" yaml:"telegram"`
}

type storageRuleConfig struct {
Expand Down Expand Up @@ -56,3 +57,10 @@ type StorageAlistConfig struct {
PathPassword string `toml:"path_password" mapstructure:"path_password" json:"path_password" yaml:"path_password"`
TokenExpire int `toml:"token_expire" mapstructure:"token_expire" json:"token_expire" yaml:"token_expire"`
}

type StorageTelegramConfig struct {
Enable bool `toml:"enable" mapstructure:"enable" json:"enable" yaml:"enable"`
Token string `toml:"token" mapstructure:"token" json:"token" yaml:"token"`
ChatID int64 `toml:"chat_id" mapstructure:"chat_id" json:"chat_id" yaml:"chat_id"`
ApiUrl string `toml:"api_url" mapstructure:"api_url" json:"api_url" yaml:"api_url"`
}
1 change: 1 addition & 0 deletions config/viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func InitConfig() {
viper.SetDefault("storage.alist.token_expire", 86400)
viper.SetDefault("storage.regular_format", "webp")
viper.SetDefault("storage.thumb_format", "webp")
viper.SetDefault("storage.telegram.api_url", "https://api.telegram.org")

viper.SetDefault("telegram.sleep", 3)
viper.SetDefault("telegram.api_url", "https://api.telegram.org")
Expand Down
27 changes: 16 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module github.com/krau/ManyACG

go 1.23
go 1.23.3

toolchain go1.24.0

require (
github.com/PuerkitoBio/goquery v1.10.0
github.com/PuerkitoBio/goquery v1.10.1
github.com/appleboy/gin-jwt/v2 v2.10.0
github.com/blang/semver v3.5.1+incompatible
github.com/bytedance/sonic v1.12.6
Expand All @@ -27,13 +29,13 @@ require (
github.com/studio-b12/gowebdav v0.10.0
github.com/u2takey/ffmpeg-go v0.5.0
go.mongodb.org/mongo-driver v1.17.1
golang.org/x/crypto v0.31.0
golang.org/x/crypto v0.33.0
golang.org/x/image v0.23.0
)

require (
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/aws/aws-sdk-go v1.55.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.20.0 // indirect
Expand Down Expand Up @@ -84,6 +86,7 @@ require (
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.48.2 // indirect
github.com/refraction-networking/utls v1.6.7 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/savsgio/gotils v0.0.0-20240704082632-aef3928b8a38 // indirect
github.com/tcnksm/go-gitconfig v0.1.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
Expand All @@ -96,12 +99,14 @@ require (
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.uber.org/goleak v1.3.0 // indirect
go.uber.org/mock v0.5.0 // indirect
golang.org/x/arch v0.12.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/mod v0.23.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/tools v0.28.0 // indirect
golang.org/x/time v0.8.0 // indirect
golang.org/x/tools v0.30.0 // indirect
google.golang.org/protobuf v1.36.0 // indirect
)

Expand All @@ -126,10 +131,10 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 40ac57c

Please sign in to comment.