Skip to content

Add filters.IS_BOT - #5366

Open
kurupdevs wants to merge 1 commit into
python-telegram-bot:masterfrom
kurupdevs:add-filters-is-bot
Open

kurupdevs wants to merge 1 commit into
python-telegram-bot:masterfrom
kurupdevs:add-filters-is-bot

Conversation

@kurupdevs

Copy link
Copy Markdown

Closes #5315.

Adds filters.IS_BOT, a MessageFilter matching messages whose sender is a bot (telegram.User.is_bot), following the existing IS_AUTOMATIC_FORWARD pattern. Negation works via ~filters.IS_BOT, so no separate IS_NOT_BOT is needed. The from_user is None guard (channel posts, anonymous-admin messages) is handled inside the filter and covered by a test, since a naive message.from_user.is_bot would raise AttributeError. Tests added in tests/ext/test_filters.py (bot matches, human doesn't, from_user=None doesn't).

New MessageFilter matching messages whose sender is a bot
(telegram.User.is_bot). Channel posts and anonymous-admin
messages have no Message.from_user and do not match.

Closes python-telegram-bot#5315.
@harshil21

Copy link
Copy Markdown
Member

Please see my review on the other prs which tried this and do those changes

This branch has not been deployed

No deployments
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.

Add filters.IS_BOT — no filter exposes User.is_bot (needed for multi-bot group chats)

2 participants