chatMemberFilter
ref / chat-members / chatMemberFilter
Filter context to only find updates of type ‘chat_member’ where the status transitions from oldStatus to newStatus.
Example:
typescript
// listen for updates where a user leaves a channel
bot.chatType('channel').filter(
chatMemberFilter('in', 'out'),
(ctx) => {
const { old_chat_member: oldChatMember, new_chat_member: newChatMember } =
ctx.chatMember;
// ...
},
);
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Note: To receive these updates the bot must be admin in the chat and you must add ‘chat_member’ to the list of allowed updates.
Type Parameters
C
ts
C extends Context
Q1
ts
Q1 extends ChatMemberQuery
Q2
ts
Q2 extends ChatMemberQuery
Parameters
oldStatus
ts
oldStatus: MaybeArray<Q1>
newStatus
ts
newStatus: MaybeArray<Q2>