feat(tg-bot): unpin auto-forwarded channel posts #257
Reference in New Issue
Block a user
Delete Branch "feature/tg-unpin-linked-channel-post"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Telegram non-disableably auto-pins each channel post it auto-forwards into the linked discussion group (
TELEGRAM_CHAT_ID). The bot now detects that message byMessage.is_automatic_forwardin the moderated chat and unpins it by id (unpinChatMessage), so a pin set by a human admin — or by the bot for another message — is never touched (neverunpinAllChatMessages).Detection is reliable: the flag is set only by Telegram and only for the linked-channel auto-forward. Privacy mode is not a factor — an admin bot (which it must be to unpin) receives all messages.
Owner-side prerequisite: grant the bot the pin-messages right (
can_pin_messages) in the discussion group; without it the unpin no-ops and the startup self-check now logs a warning.Bot-only; no wire/schema/DB change. Tests: filter (only auto-forward), point unpin by id, foreign-chat ignored.