feat: support other api endpoint

This commit is contained in:
Vaala Cat 2023-06-08 22:28:41 +08:00
parent e516a51ebe
commit 730aea3e3b
2 changed files with 6 additions and 2 deletions

View File

@ -14,6 +14,7 @@ type botSettings struct {
MCServer string MCServer string
MCBotName string MCBotName string
GroupID int64 GroupID int64
TGBotApi string
} }
var ( var (
@ -27,8 +28,9 @@ func init() {
mc_server := os.Getenv("MC_SERVER") mc_server := os.Getenv("MC_SERVER")
mc_bot_name := os.Getenv("MC_BOT_NAME") mc_bot_name := os.Getenv("MC_BOT_NAME")
group_id_str := os.Getenv("GROUP_ID") 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("请检查环境变量是否设置正确") logrus.Panic("请检查环境变量是否设置正确")
} }
@ -43,6 +45,7 @@ func init() {
MCServer: mc_server, MCServer: mc_server,
MCBotName: mc_bot_name, MCBotName: mc_bot_name,
GroupID: group_id, GroupID: group_id,
TGBotApi: tg_bot_api,
} }
} }

View File

@ -24,7 +24,8 @@ func Run(sendFunc func(string) error) {
client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}} client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}}
conf.Bot, err = tgbotapi.NewBotAPIWithClient( conf.Bot, err = tgbotapi.NewBotAPIWithClient(
conf.GetBotSettings().BotToken, conf.GetBotSettings().BotToken,
tgbotapi.APIEndpoint, // tgbotapi.APIEndpoint,
conf.GetBotSettings().TGBotApi,
client) client)
if err != nil { if err != nil {