fix: support private chats (DM) for Telegram notifications #261
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When sending Telegram notifications to a private chat (direct messages to a user), the script fails with:
This happens because the script unconditionally adds a
-100prefix to all chat IDs. While this works for channels and supergroups, it breaks private chats where the user ID should be used as-is.For example, a user ID
37560172becomes-10037560172, which does not exist.Solution
Added new optional configuration parameters
PF_TELEGRAM_CHAT_TYPEandPA_TELEGRAM_CHAT_TYPE. When set toprivate, the chat ID is used without modification.Changes
rootfs/scripts/post2telegram.sh: Added logic to detect chat type and skip the-100prefix for private chatsrootfs/usr/share/planefence/stage/planefence.config: Added new parameters with documentationREADME-telegram.md: Added section describing private chat setupBackward Compatibility
Existing configurations continue to work without changes. The new parameters are optional and default to the previous behavior (channel mode with
-100prefix).Usage
For private chats, users need to add: