From 730aea3e3baf7644fe7d7b4c8803607ac219aa97 Mon Sep 17 00:00:00 2001 From: Vaala Cat <-e> Date: Thu, 8 Jun 2023 22:28:41 +0800 Subject: [PATCH] feat: support other api endpoint --- conf/env.go | 5 ++++- services/tgbot/bot.go | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/conf/env.go b/conf/env.go index cab31e3..55ba2b3 100644 --- a/conf/env.go +++ b/conf/env.go @@ -14,6 +14,7 @@ type botSettings struct { MCServer string MCBotName string GroupID int64 + TGBotApi string } var ( @@ -27,8 +28,9 @@ func init() { mc_server := os.Getenv("MC_SERVER") mc_bot_name := os.Getenv("MC_BOT_NAME") group_id_str := os.Getenv("GROUP_ID") + tg_bot_api := os.Getenv("TG_BOT_API") - if http_proxy == "" || bot_token == "" || mc_server == "" || mc_bot_name == "" || group_id_str == "" { + if http_proxy == "" || bot_token == "" || mc_server == "" || mc_bot_name == "" || group_id_str == "" || tg_bot_api == "" { logrus.Panic("请检查环境变量是否设置正确") } @@ -43,6 +45,7 @@ func init() { MCServer: mc_server, MCBotName: mc_bot_name, GroupID: group_id, + TGBotApi: tg_bot_api, } } diff --git a/services/tgbot/bot.go b/services/tgbot/bot.go index f134f60..75dc075 100644 --- a/services/tgbot/bot.go +++ b/services/tgbot/bot.go @@ -24,7 +24,8 @@ func Run(sendFunc func(string) error) { client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}} conf.Bot, err = tgbotapi.NewBotAPIWithClient( conf.GetBotSettings().BotToken, - tgbotapi.APIEndpoint, + // tgbotapi.APIEndpoint, + conf.GetBotSettings().TGBotApi, client) if err != nil {