linkchanbot

Telegram bot frontend proxy link substituter
git clone https://git.torresjrjr.com/linkchanbot.git
Log | Files | Refs | README | LICENSE

commit 950e8b3ac667e870e03ca0e82d957fe411edc904
parent 0551f36bdea7415c2f1869477d40c3d9bbafec19
Author: Byron Torres <b@torresjrjr.com>
Date:   Tue, 29 Mar 2022 01:56:13 +0000

Ignore messaged forwarded from self

Messages from the bot which have been forwarded to group chats are
ignored. This avoids duplicate substitution messages.

Messages from the bot which have been forwarded to the bot as a private
message are not ignored. This continues to allow for intentional
duplication or replacement of old faulty proxy links for newer ones.

Diffstat:
Mlinkchanbot | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/linkchanbot b/linkchanbot @@ -673,8 +673,7 @@ def main(): dp.add_handler(ChosenInlineResultHandler(cb_chosen_inline_result)) dp.add_handler(MessageHandler( - # (not) messages from this bot - ~Filters.via_bot(username=BOT_USERNAME) & ( + ( # non-edited messages Filters.update.message | Filters.update.channel_post ) & ( @@ -683,6 +682,14 @@ def main(): Filters.entity(MessageEntity.TEXT_LINK) | Filters.caption_entity(MessageEntity.URL) | Filters.caption_entity(MessageEntity.TEXT_LINK) + ) & ( + # not messages created via this bot (inline queries, etc.) + ~Filters.via_bot(username=BOT_USERNAME) + ) & ~( + # not messages from bot forwarded to group chats + # (forwarded to bot's private chat is OK) + Filters.forwarded_from(username=BOT_USERNAME) + & ~Filters.chat_type.private ), cb_link_handler ))