P9(5): restore upstream Telegram bot (settings, backup, notifications)

Per user decision 2026-10-21 (reverses the 2026-10-20 drop-Telegram
call): port the upstream 3x-ui v3.7.0-generation Telegram bot wholesale
instead of rewriting a minimal set, adapted to this fork.

- new internal/web/service/tgbot package (telego): bot lifecycle,
  commands, reports, callback router, send helpers; token validation via
  telego; custom API server URL passes the fork's SSRF sanitizer
  (loopback/private bases fall back to the default endpoint, logged)
- settings: full upstream key set (tgBotEnable/Token/Proxy/APIServer/
  ChatId, tgRunTime, tgBotBackup, tgCpu/tgMemory, tgLang,
  tgEnabledEvents) with getters/setters; settings page gains a Telegram
  tab + sidebar entry; token shown masked, clearTgBotToken honored
- wiring (web.go): stats-notify cron registered from tgRunTime when the
  bot is enabled; CheckHashStorage job; CPU/memory alarm jobs gated on
  tgEnabledEvents + thresholds; login notifications via event bus;
  POST /panel/api/setting/testTgBot and /panel/api/backuptotgbot
- lite adaptation: StatsNotifyJob no longer gates on a local Xray core
  (this panel never runs one) so the periodic report and the scheduled
  DB backup (sendDocument) can actually fire
- translations: upstream TG keys restored across all locales

End-to-end smoke (real binary + fake Telegram API over HTTPS at a
public-looking address, browser form wire format): bot starts on
settings change (getMe), testTgBot delivers, panel restart re-arms the
bot, tgRunTime='@every 1m' cron really fires sendDocument carrying the
panel SQLite DB (magic verified) plus the report sendMessage, login
notification delivered, dead-endpoint failure is logged not silent.
13/13 PASS — see P9-REPORT.md.
This commit is contained in:
Muse
2026-10-21 17:16:32 +00:00
parent 5031a70ccb
commit ceca96571d
49 changed files with 8351 additions and 50 deletions
+216 -3
View File
@@ -88,7 +88,8 @@
"noExpiry": "期限なし",
"copyAllConfigs": "すべての設定をコピー",
"copyAllConfigsCopied": "すべての設定をコピーしました",
"email": "メール"
"email": "メール",
"individualLinks": "個別リンク"
},
"menu": {
"theme": "テーマ",
@@ -1168,7 +1169,44 @@
"httpMethodDesc": "プローブ要求に使う HTTP メソッド。",
"note": "leastPing/leastLoad バランサーは常に burstObservatory を持ちます。このスイッチはプローブパラメータをカスタマイズします — オフにすると組み込みのデフォルトを使います。変更はパネルの再起動後に反映されます。"
}
}
},
"TGBotSettings": "Telegram Bot",
"notifications": "通知",
"notifyTime": {
"custom": "カスタム (crontab)",
"daily": "@daily — 毎日 00:00",
"every": "@every — 一定間隔で繰り返す",
"hourly": "@hourly — 1時間ごと",
"hours": "時間",
"interval": "間隔",
"minutes": "分",
"monthly": "@monthly — 毎月",
"seconds": "秒",
"unit": "単位",
"weekly": "@weekly — 毎週"
},
"telegramAPIServer": "Telegram API サーバー",
"telegramAPIServerDesc": "使用するTelegram APIサーバー。空白の場合はデフォルトサーバーを使用する",
"telegramBotEnable": "Telegramボットを有効にする",
"telegramBotEnableDesc": "Telegramボット機能を有効にする",
"telegramBotLanguage": "Telegram Botの言語",
"telegramChatId": "管理者チャットID",
"telegramChatIdDesc": "Telegram管理者チャットID(複数の場合はカンマで区切る){'@'}userinfobotで取得するか、ボットで'/id'コマンドを使用して取得する",
"telegramNotifyTime": "通知時間",
"telegramNotifyTimeDesc": "Telegram ボットが定期レポートを送信する頻度です。プリセットの間隔を選ぶか、「カスタム」を選んで crontab 式を入力します。",
"telegramToken": "Telegram トークン",
"telegramTokenConfigured": "設定済み。現在のトークンを維持する場合は空欄のままにしてください。",
"telegramTokenDesc": "'{'@'}BotFather'から取得したTelegramボットトークン",
"telegramTokenPlaceholder": "設定済み - 置き換えるには新しいトークンを入力してください",
"testTgBot": "テストメッセージを送信",
"tgBotNotEnabled": "Telegramボットが有効になっていません",
"tgBotNotRunning": "Telegramボットが実行されていません",
"tgEventBusNotify": "Telegramイベント通知",
"tgEventBusNotifyDesc": "Telegram通知をトリガーするイベントを選択してください",
"tgNotifyBackup": "データベースバックアップ",
"tgNotifyBackupDesc": "レポート付きのデータベースバックアップファイルを送信",
"tgTestFailed": "Telegramのテストに失敗しました",
"tgTestSuccess": "Telegramにテストメッセージを送信しました"
},
"xray": {
"importRules": "ルールをインポート",
@@ -1657,7 +1695,182 @@
}
},
"tgbot": {
"noIpRecord": "❗ IPレコードがありません!"
"noIpRecord": "❗ IPレコードがありません!",
"keyboardClosed": "❌ キーボードを閉じました!",
"noResult": "❗ 結果がありません!",
"noQuery": "❌ クエリが見つかりません!コマンドを再利用してください!",
"wentWrong": "❌ 何かがうまくいかなかった!",
"noInbounds": "❗ インバウンドが見つかりません!",
"unlimited": "♾ 無制限(リセット)",
"add": "追加",
"month": "月",
"months": "ヶ月",
"days": "日間",
"hours": "時間",
"minutes": "分",
"unknown": "不明",
"inbounds": "インバウンド",
"clients": "クライアント",
"offline": "🔴 オフライン",
"online": "🟢 オンライン",
"commands": {
"unknown": "❗ 不明なコマンド",
"pleaseChoose": "👇 選択してください:\r\n",
"help": "🤖 このボットをご利用いただきありがとうございます!サーバーから特定のデータを提供し、必要な変更を行うことができます。\r\n\r\n",
"start": "👋 こんにちは、<i>{{ .Firstname }}</i>。\r\n",
"welcome": "🤖 <b>{{ .Hostname }}</b> 管理ボットへようこそ。\r\n",
"status": "✅ ボットは正常に動作しています!",
"usage": "❗ 検索するテキストを入力してください!",
"getID": "🆔 あなたのIDは:<code>{{ .ID }}</code>",
"helpAdminCommands": "Xray Coreを再起動するには:\r\n<code>/restart</code>\r\n\r\nクライアントの電子メールを検索するには:\r\n<code>/usage [電子メール]</code>\r\n\r\nインバウンド(クライアントの統計情報を含む)を検索するには:\r\n<code>/inbound [備考]</code>\r\n\r\nTelegramチャットID:\r\n<code>/id</code>",
"helpClientCommands": "統計情報を検索するには、次のコマンドを使用してください:\r\n<code>/usage [電子メール]</code>\r\n\r\nTelegramチャットID:\r\n<code>/id</code>",
"restartUsage": "\r\n\r\n<code>/restart</code>",
"restartSuccess": "✅ 操作成功!",
"restartFailed": "❗ 操作エラー。\r\n\r\n<code>エラー: {{ .Error }}</code>",
"xrayNotRunning": "❗ Xray Core は動作していません。",
"startDesc": "メインメニューを表示",
"helpDesc": "ボットのヘルプ",
"statusDesc": "ボットの状態を確認",
"idDesc": "Telegram IDを表示",
"usageDesc": "クライアント使用量を表示: /usage メール",
"inboundDesc": "インバウンド検索: /inbound 備考(管理者)",
"restartDesc": "Xray コアを再起動(管理者)",
"clearallDesc": "全クライアントのトラフィックをリセット(管理者)"
},
"messages": {
"cpuThreshold": "CPU使用率は{{ .Percent }}%、しきい値{{ .Threshold }}%を超えました",
"selectUserFailed": "❌ ユーザーの選択に失敗しました!",
"userSaved": "✅ Telegramユーザーが保存されました。",
"loginSuccess": "✅ パネルに正常にログインしました。\r\n",
"loginFailed": "❗️ パネルのログインに失敗しました。\r\n",
"report": "🕰 定期報告:{{ .RunTime }}\r\n",
"datetime": "⏰ 日時:{{ .DateTime }}\r\n",
"hostname": "💻 ホスト: {{ .Hostname }}\r\n",
"version": "🚀 X-UI バージョン:{{ .Version }}\r\n",
"xrayVersion": "📡 Xray バージョン: {{ .XrayVersion }}\r\n",
"ipv6": "🌐 IPv6: {{ .IPv6 }}\r\n",
"ipv4": "🌐 IPv4: {{ .IPv4 }}\r\n",
"ip": "🌐 IP: {{ .IP }}\r\n",
"ips": "🔢 IP:\r\n{{ .IPs }}\r\n",
"serverUpTime": "⏳ サーバー稼働時間:{{ .UpTime }} {{ .Unit }}\r\n",
"serverLoad": "📈 サーバー負荷:{{ .Load1 }}, {{ .Load2 }}, {{ .Load3 }}\r\n",
"serverMemory": "📋 RAM: {{ .Current }}/{{ .Total }}\r\n",
"tcpCount": "🔹 TCP: {{ .Count }}\r\n",
"udpCount": "🔸 UDP: {{ .Count }}\r\n",
"traffic": "🚦 トラフィック:{{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n",
"xrayStatus": "ℹ️ ステータス: {{ .State }}\r\n",
"username": "👤 ユーザー名:{{ .Username }}\r\n",
"reason": "❗️ 理由:{{ .Reason }}\r\n",
"time": "⏰ 時間:{{ .Time }}\r\n",
"inbound": "📍 インバウンド: {{ .Remark }}\r\n",
"port": "🔌 ポート: {{ .Port }}\r\n",
"expire": "📅 有効期限:{{ .Time }}\r\n",
"expireIn": "📅 残り時間:{{ .Time }}\r\n",
"active": "💡 有効:{{ .Enable }}\r\n",
"enabled": "🚨 有効化済み:{{ .Enable }}\r\n",
"online": "🌐 接続ステータス:{{ .Status }}\r\n",
"lastOnline": "🔙 最終オンライン: {{ .Time }}\r\n",
"email": "📧 メール: {{ .Email }}\r\n",
"upload": "🔼 アップロード: ↑{{ .Upload }}\r\n",
"download": "🔽 ダウンロード: ↓{{ .Download }}\r\n",
"total": "📊 合計: ↑↓{{ .UpDown }} / {{ .Total }}\r\n",
"TGUser": "👤 Telegramユーザー:{{ .TelegramID }}\r\n",
"exhaustedCount": "🚨 消耗済みの {{ .Type }} 数量:\r\n",
"onlinesCount": "🌐 オンラインクライアント:{{ .Count }}\r\n",
"disabled": "🛑 無効化:{{ .Disabled }}\r\n",
"depleteSoon": "🔜 間もなく消耗:{{ .Deplete }}\r\n\r\n",
"backupTime": "🗄 バックアップ時間:{{ .Time }}\r\n",
"refreshedOn": "\r\n📋🔄 更新時間:{{ .Time }}\r\n\r\n",
"yes": "✅ はい",
"no": "❌ いいえ",
"received_email": "📧📥 メールが更新されました。",
"received_comment": "💬📥 コメントが更新されました。",
"email_prompt": "📧 デフォルトメール: {{ .ClientEmail }}\n\nメールを入力してください。",
"comment_prompt": "💬 デフォルトコメント: {{ .ClientComment }}\n\nコメントを入力してください。",
"cancel": "❌ プロセスがキャンセルされました!\n\nいつでも /start で再開できます。 🔄",
"error_add_client": "⚠️ エラー:\n\n {{ .error }}",
"using_default_value": "わかりました、デフォルト値を使用します。 😊",
"incorrect_input": "入力が無効です。\nフレーズはスペースなしで続けて入力してください。\n正しい例: aaaaaa\n間違った例: aaa aaa 🚫",
"AreYouSure": "本当にいいですか?🤔",
"SuccessResetTraffic": "📧 メール: {{ .ClientEmail }}\n🏁 結果: ✅ 成功",
"FailedResetTraffic": "📧 メール: {{ .ClientEmail }}\n🏁 結果: ❌ 失敗 \n\n🛠️ エラー: [ {{ .ErrorMessage }} ]",
"FinishProcess": "🔚 すべてのクライアントのトラフィックリセットが完了しました。",
"eventOutboundDown": "アウトバウンド {{ .Tag }} がダウンしています",
"eventOutboundUp": "アウトバウンド {{ .Tag }} が復旧しました",
"eventErrorDetail": "エラー: {{ .Error }}",
"eventDelayDetail": "遅延: {{ .Delay }}ms",
"eventXrayCrash": "Xrayがクラッシュしました",
"eventXrayCrashError": "エラー: {{ .Error }}",
"eventNodeDown": "ノード {{ .Name }} がダウンしています",
"eventNodeUp": "ノード {{ .Name }} が復旧しました",
"eventLoginFallback": "{{ .Source }} からのログインに失敗しました",
"memoryThreshold": "メモリ使用率 {{ .Percent }}% がしきい値 {{ .Threshold }}% を超えました"
},
"buttons": {
"closeKeyboard": "❌ キーボードを閉じる",
"cancel": "❌ キャンセル",
"cancelReset": "❌ リセットをキャンセル",
"cancelIpLimit": "❌ IP制限をキャンセル",
"confirmResetTraffic": "✅ トラフィックをリセットしますか?",
"confirmClearIps": "✅ IPをクリアしますか?",
"confirmRemoveTGUser": "✅ Telegramユーザーを削除しますか?",
"confirmToggle": "✅ ユーザーを有効/無効にしますか?",
"dbBackup": "データベースバックアップを取得",
"serverUsage": "サーバーの使用状況",
"getInbounds": "インバウンド情報を取得",
"depleteSoon": "間もなく消耗",
"clientUsage": "使用状況を取得",
"onlines": "オンラインクライアント",
"commands": "コマンド",
"refresh": "🔄 更新",
"clearIPs": "❌ IPをクリア",
"removeTGUser": "❌ Telegramユーザーを削除",
"selectTGUser": "👤 Telegramユーザーを選択",
"selectOneTGUser": "👤 1人のTelegramユーザーを選択:",
"resetTraffic": "📈 トラフィックをリセット",
"resetExpire": "📅 有効期限を変更",
"ipLog": "🔢 IPログ",
"ipLimit": "🔢 IP制限",
"setTGUser": "👤 Telegramユーザーを設定",
"toggle": "🔘 有効/無効",
"custom": "🔢 カスタム",
"confirmNumber": "✅ 確認: {{ .Num }}",
"confirmNumberAdd": "✅ 追加を確認:{{ .Num }}",
"limitTraffic": "🚧 トラフィック制限",
"getBanLogs": "禁止ログ",
"allClients": "すべてのクライアント",
"addClient": "クライアントを追加",
"submitDisable": "無効として送信 ☑️",
"submitEnable": "有効として送信 ✅",
"use_default": "🏷️ デフォルトを使用",
"change_email": "⚙️📧 メール",
"change_comment": "⚙️💬 コメント",
"ResetAllTraffics": "すべてのトラフィックをリセット",
"SortedTrafficUsageReport": "ソートされたトラフィック使用レポート"
},
"answers": {
"successfulOperation": "✅ 成功!",
"errorOperation": "❗ 操作エラー。",
"getInboundsFailed": "❌ インバウンド情報の取得に失敗しました。",
"getClientsFailed": "❌ クライアントの取得に失敗しました。",
"canceled": "❌ {{ .Email }}:操作がキャンセルされました。",
"clientRefreshSuccess": "✅ {{ .Email }}:クライアントが正常に更新されました。",
"IpRefreshSuccess": "✅ {{ .Email }}:IPが正常に更新されました。",
"TGIdRefreshSuccess": "✅ {{ .Email }}:クライアントのTelegramユーザーが正常に更新されました。",
"resetTrafficSuccess": "✅ {{ .Email }}:トラフィックが正常にリセットされました。",
"setTrafficLimitSuccess": "✅ {{ .Email }}:トラフィック制限が正常に保存されました。",
"expireResetSuccess": "✅ {{ .Email }}:有効期限の日数が正常にリセットされました。",
"resetIpSuccess": "✅ {{ .Email }}:IP制限数が正常に保存されました:{{ .Count }}。",
"clearIpSuccess": "✅ {{ .Email }}:IPが正常にクリアされました。",
"getIpLog": "✅ {{ .Email }}:IPログの取得。",
"getUserInfo": "✅ {{ .Email }}:Telegramユーザー情報の取得。",
"removedTGUserSuccess": "✅ {{ .Email }}:Telegramユーザーが正常に削除されました。",
"enableSuccess": "✅ {{ .Email }}:正常に有効化されました。",
"disableSuccess": "✅ {{ .Email }}:正常に無効化されました。",
"askToAddUserId": "設定が見つかりませんでした!\r\n管理者に問い合わせて、設定にTelegramユーザーのChatIDを使用してください。\r\n\r\nあなたのユーザーChatID:<code>{{ .TgUserID }}</code>",
"chooseClient": "インバウンド {{ .Inbound }} のクライアントを選択",
"chooseInbound": "インバウンドを選択"
}
},
"email": {}
}