fix(telegram): keep a failed promo-bot construction non-fatal
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 17s
CI / ui (pull_request) Successful in 57s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m17s
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 17s
CI / ui (pull_request) Successful in 57s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m17s
tgbot.New validates the token with getMe, so a bad or unreachable promo token would otherwise return an error from run() and crash-loop the whole bot process — taking the main game bot down with it, since they share the container. Log it and skip the promo bot instead; the main bot and bot-link are unaffected.
This commit is contained in:
@@ -103,6 +103,10 @@ func run(ctx context.Context, cfg config.BotConfig, logger *zap.Logger) error {
|
||||
// bot-link, no gateway — so onboarding works even when the game is down.
|
||||
var promo *promobot.Bot
|
||||
if cfg.PromoBotToken != "" {
|
||||
// The promo bot is auxiliary and shares this process with the main bot, so its
|
||||
// construction failure (a bad or unreachable promo token — tgbot.New validates it
|
||||
// with getMe) is logged and the promo bot is skipped, never fatal: it must not
|
||||
// take the main game bot down with it.
|
||||
promo, err = promobot.New(promobot.Config{
|
||||
Token: cfg.PromoBotToken,
|
||||
APIBaseURL: cfg.APIBaseURL,
|
||||
@@ -112,7 +116,8 @@ func run(ctx context.Context, cfg config.BotConfig, logger *zap.Logger) error {
|
||||
SendRatePerSecond: cfg.SendRatePerSecond,
|
||||
}, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
logger.Error("promo bot disabled: construction failed (the main bot is unaffected)", zap.Error(err))
|
||||
promo = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user