~torresjrjr/linkchanbot

950e8b3ac667e870e03ca0e82d957fe411edc904 — Byron Torres 2 years ago 0551f36 master
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.
1 files changed, 9 insertions(+), 2 deletions(-)

M linkchanbot
M linkchanbot => linkchanbot +9 -2
@@ 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
    ))