MHSanaei/3x-ui · warning
telegram bot disabled
Error message
telegram bot disabled
What it means
testTgBot first consults settingService.GetTgbotEnabled; if that errors or returns disabled, it returns this synthetic error under the i18n key pages.settings.tgBotNotEnabled. The Telegram bot feature is opt-in via the settings table (tgbotEnabled), and the test endpoint refuses to run while it is off — you must enable and configure (bot token) the bot before testing it.
Source
Thrown at internal/web/controller/setting.go:299
c.JSON(200, gin.H{
"success": false,
"stage": result.Stage,
"msg": result.Message,
})
return
}
logger.Info("SMTP test: success")
c.JSON(200, gin.H{
"success": true,
"stage": result.Stage,
"msg": result.Message,
})
}
func (a *SettingController) testTgBot(c *gin.Context) {
enabled, err := a.settingService.GetTgbotEnabled()
if err != nil || !enabled {
jsonMsg(c, I18nWeb(c, "pages.settings.tgBotNotEnabled"), errors.New("telegram bot disabled"))
return
}
// Import tgbot package would create a circular dependency, so we call
// the test through the global function registered at startup.
if testTgFunc != nil {
if err := testTgFunc(); err != nil {
jsonMsg(c, I18nWeb(c, "pages.settings.tgTestFailed")+": "+err.Error(), err)
return
}
jsonMsg(c, I18nWeb(c, "pages.settings.tgTestSuccess"), nil)
return
}
jsonMsg(c, I18nWeb(c, "pages.settings.tgBotNotRunning"), errors.New("bot not started"))
}
// testTgFunc is set from web layer to test Telegram sending without circular imports.
var testTgFunc func() error
View on GitHub (pinned to ad32144c42)
Solutions
- Enable the Telegram bot in panel settings (tgbotEnabled=true) and set the bot token, then retry
- If it was already enabled, check panel logs for the GetTgbotEnabled DB error and inspect the settings table
- Confirm the bot token is valid before testing, otherwise the next stage will fail
Defensive patterns
Strategy: validation
Validate before calling
enabled, err := settingService.GetTgbotEnabled()
if err == nil && enabled { /* safe to call test endpoint */ } Prevention
- Enable tgbotEnabled and save a valid bot token before testing
- Hide the test action in the UI while the bot toggle is off
When it happens
Trigger: POST to the tgbot-test endpoint with tgbotEnabled=false in settings; DB read error on the settings row (e.g. table locked/corrupt) also lands here because err != nil short-circuits.
Common situations: Admins testing the bot before flipping the enable toggle; settings row missing after partial restore.
Related errors
- bot not started
- The current username or password is invalid
- The new username and password are empty
- ❌ Failed to get inbounds.
- tg_id must be a positive integer
AI-assisted analysis of MHSanaei/3x-ui@ad32144c42 (2026-08-15).
Data as JSON: /api/errors/140844cc44e95d48.
Report an issue: GitHub.