Skip to content

Conversation

@smkrv
Copy link

@smkrv smkrv commented Dec 22, 2025

Problem

When sending Telegram notifications to a private chat (direct messages to a user), the script fails with:

Error sending photo to Telegram: {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}

This happens because the script unconditionally adds a -100 prefix 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 37560172 becomes -10037560172, which does not exist.

Solution

Added new optional configuration parameters PF_TELEGRAM_CHAT_TYPE and PA_TELEGRAM_CHAT_TYPE. When set to private, the chat ID is used without modification.

Changes

  • rootfs/scripts/post2telegram.sh: Added logic to detect chat type and skip the -100 prefix for private chats
  • rootfs/usr/share/planefence/stage/planefence.config: Added new parameters with documentation
  • README-telegram.md: Added section describing private chat setup

Backward Compatibility

Existing configurations continue to work without changes. The new parameters are optional and default to the previous behavior (channel mode with -100 prefix).

Usage

For private chats, users need to add:

PF_TELEGRAM_CHAT_TYPE=private
PA_TELEGRAM_CHAT_TYPE=private

Previously, the script always added -100 prefix to chat IDs, which only
works for channels/supergroups. This broke notifications to private chats
(direct messages to users).

Changes:
- Add PF_TELEGRAM_CHAT_TYPE and PA_TELEGRAM_CHAT_TYPE config options
- When set to 'private', chat ID is used as-is without -100 prefix
- Backward compatible: existing channel configs work without changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant