diff --git a/.gitignore b/.gitignore index e538900..625331e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ runtime/ .env dist/ config.*.toml -config.toml db/geecaptcha.db captcha-bot dict/dec_* diff --git a/telegram/root.go b/telegram/root.go index a4264e6..86f4570 100644 --- a/telegram/root.go +++ b/telegram/root.go @@ -35,7 +35,7 @@ func BotStart() { ulog.Sugar.Error(err) }, } - // 反向代理 + // 代理 if config.TelegramC.ApiProxy != "" { trans := &http.Transport{ Proxy: func(_ *http.Request) (*url.URL, error) { diff --git a/util/config/config.go b/util/config/config.go index 002d7af..367e549 100644 --- a/util/config/config.go +++ b/util/config/config.go @@ -59,6 +59,21 @@ type Message struct { var MessageC Message +func (msg *Message) FromEnv() { + if joinHint := os.Getenv("msg__join_hint"); len(joinHint) > 0 { + msg.JoinHint = joinHint + } + if captchaImage := os.Getenv("msg__captcha_image"); len(captchaImage) > 0 { + msg.CaptchaImage = captchaImage + } + if verificationComplete := os.Getenv("msg__verification_complete"); len(verificationComplete) > 0 { + msg.VerificationComplete = verificationComplete + } + if blockHint := os.Getenv("msg__block_hint"); len(blockHint) > 0 { + msg.BlockHint = blockHint + } +} + type AdBlock struct { NumberOfForbiddenWords int `mapstructure:"number_of_forbidden_words"` BlockTime int64 `mapstructure:"block_time"` @@ -97,6 +112,8 @@ func InitConfig() { err = viper.UnmarshalKey("message", &MessageC) if err != nil { log.Fatal("load config message err:", err) + } else { + MessageC.FromEnv() } err = viper.UnmarshalKey("adblock", &AdBlockC) if err != nil {