uniquetrij · GitHub

What kind of feature are you missing? Where do you notice a shortcoming of PTB?

ChatMemberHandler can include a chat_id param to filter only on specified chat(s).

Describe the solution you'd like

It would be convenient to be able to do something like this:

application.add_handler(
    ChatMemberHandler(member_callback_1, ChatMemberHandler.CHAT_MEMBER, chat_id=<chat_id_1>)
)
application.add_handler(
    ChatMemberHandler(member_callback_2, ChatMemberHandler.CHAT_MEMBER, chat_id=<chat_id_2>)
)

Describe alternatives you've considered

async def member_callback_1(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
    if update.chat_member.chat.id != <chat_id_1>:
        return
    ...
async def member_callback_2(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
    if update.chat_member.chat.id != <chat_id_2>:
        return
    ...

Additional context

Let me know if there is an alternate / better way to achieve this.

Read the original on github.com ↗