| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Expose telegram.User.is_bot through a ready-to-use filter, so that handlers can be registered for, or excluded from, messages authored by a bot without inspecting the sender inside the callback. The filter is an UpdateFilter based on Update.effective_user, matching the existing PREMIUM_USER and USER_ATTACHMENT filters, and returns False when the update has no user, e.g. for channel posts. Closes python-telegram-bot#5315
| Back | FazBrowse Home | New Git URL |
Adds filters.IS_BOT, a ready to use filter that matches updates whose telegram.Update.effective_user is a bot. Until now nothing in the filters module exposed telegram.User.is_bot, so telling bot authored messages apart from human ones had to happen inside the callback. With this filter the decision can be made at handler registration time, and ~filters.IS_BOT covers the human only case.
The filter is implemented as an UpdateFilter over Update.effective_user, which is the same approach the existing PREMIUM_USER and USER_ATTACHMENT filters take for other telegram.User attributes. It returns False when the update carries no user at all, for example for channel posts.
The docstring also points out that in groups a bot only receives messages from other bots when privacy mode is disabled, since that is the setting that decides whether the filter can ever match in a multi bot chat.
Fixes #5315.
Check-list for PRs