mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-20 22:16:09 +05:00
update
This commit is contained in:
36
server/tgbot/config/config.go
Normal file
36
server/tgbot/config/config.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"server/log"
|
||||
"server/settings"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
HostTG string
|
||||
WhiteIds []int64
|
||||
BlackIds []int64
|
||||
}
|
||||
|
||||
var Cfg *Config
|
||||
|
||||
func LoadConfig() {
|
||||
Cfg = &Config{}
|
||||
fn := filepath.Join(settings.Path, "tg.cfg")
|
||||
buf, err := os.ReadFile(fn)
|
||||
if err != nil {
|
||||
Cfg.WhiteIds = []int64{}
|
||||
Cfg.BlackIds = []int64{}
|
||||
buf, _ = json.MarshalIndent(Cfg, "", " ")
|
||||
if buf != nil {
|
||||
os.WriteFile(fn, buf, 0666)
|
||||
}
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(buf, &Cfg)
|
||||
if err != nil {
|
||||
log.TLogln("Error read tg config:", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user