{"record":{"id":"140844cc44e95d48","repo":"MHSanaei/3x-ui","slug":"telegram-bot-disabled","errorCode":null,"errorMessage":"telegram bot disabled","messagePattern":"telegram bot disabled","errorType":"http","errorClass":null,"httpStatus":200,"severity":"warning","filePath":"internal/web/controller/setting.go","lineNumber":299,"sourceCode":"\t\tc.JSON(200, gin.H{\n\t\t\t\"success\": false,\n\t\t\t\"stage\":   result.Stage,\n\t\t\t\"msg\":     result.Message,\n\t\t})\n\t\treturn\n\t}\n\tlogger.Info(\"SMTP test: success\")\n\tc.JSON(200, gin.H{\n\t\t\"success\": true,\n\t\t\"stage\":   result.Stage,\n\t\t\"msg\":     result.Message,\n\t})\n}\n\nfunc (a *SettingController) testTgBot(c *gin.Context) {\n\tenabled, err := a.settingService.GetTgbotEnabled()\n\tif err != nil || !enabled {\n\t\tjsonMsg(c, I18nWeb(c, \"pages.settings.tgBotNotEnabled\"), errors.New(\"telegram bot disabled\"))\n\t\treturn\n\t}\n\t// Import tgbot package would create a circular dependency, so we call\n\t// the test through the global function registered at startup.\n\tif testTgFunc != nil {\n\t\tif err := testTgFunc(); err != nil {\n\t\t\tjsonMsg(c, I18nWeb(c, \"pages.settings.tgTestFailed\")+\": \"+err.Error(), err)\n\t\t\treturn\n\t\t}\n\t\tjsonMsg(c, I18nWeb(c, \"pages.settings.tgTestSuccess\"), nil)\n\t\treturn\n\t}\n\tjsonMsg(c, I18nWeb(c, \"pages.settings.tgBotNotRunning\"), errors.New(\"bot not started\"))\n}\n\n// testTgFunc is set from web layer to test Telegram sending without circular imports.\nvar testTgFunc func() error\n","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/MHSanaei/3x-ui/blob/ad32144c42455696ea9f14e12168beac3e25f5d2/internal/web/controller/setting.go#L281-L317","documentation":"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.","triggerScenarios":"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.","commonSituations":"Admins testing the bot before flipping the enable toggle; settings row missing after partial restore.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"enabled, err := settingService.GetTgbotEnabled()\nif err == nil && enabled { /* safe to call test endpoint */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable tgbotEnabled and save a valid bot token before testing","Hide the test action in the UI while the bot toggle is off"],"tags":["telegram","settings","bot","api"],"backgroundTag":null,"analyzedSha":"ad32144c42455696ea9f14e12168beac3e25f5d2","analyzedAt":"2026-08-15T11:13:23.905Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}