ChatMemberHandler¶
- class telegram.ext.ChatMemberHandler(callback, chat_member_types=-1, block=True, chat_id=None)[source]¶
Bases:
telegram.ext.BaseHandlerHandler class to handle Telegram updates that contain a chat member update.
Warning
When setting
blocktoFalse, you cannot rely on adding custom attributes totelegram.ext.CallbackContext. See its docs for more info.Examples
Use In
Available In
Added in version 13.4.
- Parameters:
callback (coroutine function) –
The callback function for this handler. Will be called when
check_update()has determined that an update should be processed by this handler. Callback signature:async def callback(update: Update, context: CallbackContext)
The return value of the callback is usually ignored except for the special case of
telegram.ext.ConversationHandler.chat_member_types (
int, optional) – Pass one ofMY_CHAT_MEMBER,CHAT_MEMBERorANY_CHAT_MEMBERto specify if this handler should handle only updates withtelegram.Update.my_chat_member,telegram.Update.chat_memberor both. Defaults toMY_CHAT_MEMBER.block (
bool, optional) –Determines whether the return value of the callback should be awaited before processing the next handler in
telegram.ext.Application.process_update(). Defaults toTrue.See also
chat_id (
int| Collection[int], optional) – Filters chat member updates from specified chat ID(s) only. .. versionadded:: 21.3
- chat_member_types[source]¶
Optional. Specifies if this handler should handle only updates with
telegram.Update.my_chat_member,telegram.Update.chat_memberor both.- Type:
int
- block[source]¶
Determines whether the return value of the callback should be awaited before processing the next handler in
telegram.ext.Application.process_update().- Type:
bool
- ANY_CHAT_MEMBER = 1[source]¶
Used as a constant to handle both
telegram.Update.my_chat_memberandtelegram.Update.chat_member.- Type:
int
- CHAT_MEMBER = 0[source]¶
Used as a constant to handle only
telegram.Update.chat_member.- Type:
int
- MY_CHAT_MEMBER = -1[source]¶
Used as a constant to handle only
telegram.Update.my_chat_member.- Type:
int
- check_update(update)[source]¶
Determines whether an update should be passed to this handler’s
callback.- Parameters:
update (
telegram.Update|object) – Incoming update.- Returns:
bool