[GH-ISSUE #5387] [Feature]: Add optional fields for Telegram push notifications #3774

Closed
opened 2026-10-31 20:34:51 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @lidalong50226 on GitHub (Jun 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5387

It is suggested that the optional fields for Telegram push notifications be optimized to accurately identify the information source when there are multiple VPSs.

It is also suggested that Telegram push notifications for backup and log, CPU anomaly alerts, and other functions be optimized.

I have created a template for x-ui.db and uploaded it to the server. Each time a new server is deployed, it automatically downloads the version from the remote server, replaces it, and then restarts 3x-ui. This provides the necessary Telegram push notification configuration by default.

Describe the solution you'd like

However, it is suggested that the push notifications allow users to customize which fields to select, such as hostname, IP address, time, etc., to avoid single messages like "Backup time: 2026-06-16 00:00:11," as it's impossible to know which VPS the message originated from.

Thank you.

Alternatives you've considered

No response

Concrete use case

No response

Mockups, screenshots, or examples

Image Image

Which parts of the panel would this affect?

No response

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @lidalong50226 on GitHub (Jun 16, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5387 ### Is your feature request related to a problem? It is suggested that the optional fields for Telegram push notifications be optimized to accurately identify the information source when there are multiple VPSs. It is also suggested that Telegram push notifications for backup and log, CPU anomaly alerts, and other functions be optimized. I have created a template for x-ui.db and uploaded it to the server. Each time a new server is deployed, it automatically downloads the version from the remote server, replaces it, and then restarts 3x-ui. This provides the necessary Telegram push notification configuration by default. ### Describe the solution you'd like However, it is suggested that the push notifications allow users to customize which fields to select, such as hostname, IP address, time, etc., to avoid single messages like "Backup time: 2026-06-16 00:00:11," as it's impossible to know which VPS the message originated from. Thank you. ### Alternatives you've considered _No response_ ### Concrete use case _No response_ ### Mockups, screenshots, or examples <img width="398" height="627" alt="Image" src="https://github.com/user-attachments/assets/7c346b2f-f33a-455f-946d-3b876a230f0b" /> <img width="433" height="362" alt="Image" src="https://github.com/user-attachments/assets/6d65cb3f-3522-4486-a93f-b09dc8d847d9" /> ### Which parts of the panel would this affect? _No response_ ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [ ] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
bsakaguchi 2026-10-31 20:34:51 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 16, 2026):

The request is partially already implemented, and partially a genuine gap — the exact picture depends on which notification type you are looking at.

What already includes server identity

  • All event-driven notifications (CPU high alert, outbound up/down, Xray crash, node up/down, login success/failure): tgbot_event.go prepends a bold hostname header — <b>📡 hostname</b> — to every message via the formatEventMessage function (lines 61–62). The CPU threshold alert you mentioned is covered here.
  • The periodic scheduled report (SendReport): the server-usage block built in prepareServerUsageInfo (tgbot_report.go:94) already emits 💻 Host: <hostname>, 🌐 IPv4: <ip>, and 🌐 IPv6: <ip> lines using the tgbot.messages.hostname/ipv4/ipv6 i18n keys (en-US.json, lines 1740, 1743–1744).

Confirmed gap

The sendBackup function (tgbot_report.go:394–439) sends only this before attaching the files:

output := t.I18nBot("tgbot.messages.backupTime", "Time=="+time.Now().Format("2006-01-02 15:04:05"))

That maps to 🗄 Backup Time: <time> with no server identity, which is exactly the scenario you described. Similarly, sendBanLogs (tgbot_report.go:442) only emits a timestamp line.

What a fix would look like

Prepending the same hostname/IP block that prepareServerUsageInfo already generates — or even just using the hostname package-level variable that SetHostname() populates — would resolve the ambiguity for backup and ban-log messages. No new settings field is required for this minimal case.

A richer opt-in (letting each admin choose which fields appear) would require a new settings entry, additional UI, and i18n work across all 13 locale files — that is a larger scope, closer to what #5303 is requesting for the periodic report format.

If you are willing to open a PR, the minimal change is in tgbot_report.go:sendBackup and tgbot_report.go:sendBanLogs. The existing hostname variable (set at bot startup via SetHostname) and the tgbot.messages.hostname i18n key are available in the same package with no additional wiring needed.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4718890771 --> @github-actions[bot] commented on GitHub (Jun 16, 2026): The request is partially already implemented, and partially a genuine gap — the exact picture depends on which notification type you are looking at. **What already includes server identity** - All event-driven notifications (CPU high alert, outbound up/down, Xray crash, node up/down, login success/failure): `tgbot_event.go` prepends a bold hostname header — `<b>📡 hostname</b>` — to every message via the `formatEventMessage` function (lines 61–62). The CPU threshold alert you mentioned is covered here. - The periodic scheduled report (`SendReport`): the server-usage block built in `prepareServerUsageInfo` (`tgbot_report.go:94`) already emits `💻 Host: <hostname>`, `🌐 IPv4: <ip>`, and `🌐 IPv6: <ip>` lines using the `tgbot.messages.hostname/ipv4/ipv6` i18n keys (`en-US.json`, lines 1740, 1743–1744). **Confirmed gap** The `sendBackup` function (`tgbot_report.go:394–439`) sends only this before attaching the files: ```go output := t.I18nBot("tgbot.messages.backupTime", "Time=="+time.Now().Format("2006-01-02 15:04:05")) ``` That maps to `🗄 Backup Time: <time>` with no server identity, which is exactly the scenario you described. Similarly, `sendBanLogs` (`tgbot_report.go:442`) only emits a timestamp line. **What a fix would look like** Prepending the same hostname/IP block that `prepareServerUsageInfo` already generates — or even just using the `hostname` package-level variable that `SetHostname()` populates — would resolve the ambiguity for backup and ban-log messages. No new settings field is required for this minimal case. A richer opt-in (letting each admin choose which fields appear) would require a new settings entry, additional UI, and i18n work across all 13 locale files — that is a larger scope, closer to what #5303 is requesting for the periodic report format. If you are willing to open a PR, the minimal change is in `tgbot_report.go:sendBackup` and `tgbot_report.go:sendBanLogs`. The existing `hostname` variable (set at bot startup via `SetHostname`) and the `tgbot.messages.hostname` i18n key are available in the same package with no additional wiring needed. *This reply was generated automatically; a maintainer may follow up.*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3774
No description provided.