Skip to content

NewChatMembers method dont work for big groups #501

@vbatalov

Description

@vbatalov

Problem:

We have Update and Message Instance.

If chat group very small, we can get all new members by method getNewChatMembers(): User[]

But for example, my chat have 6000 members and method getNewChatMembers return always null.

How to smart fix:

Attention: You need set updates for Webhook.

For example:

$allowedUpdates = [
            'message',
            'callback_query',
            'chat_member',
            'my_chat_member',
        ];

$this->bot->setWebhook($page_url, allowedUpdates: $allowedUpdates)

Without allowed updates like a chat_member, Update will not send you required keys.

Smart fix for example

  1. Get all request (ex. Laravel: $request->all();
  2. Request has key [chat_member]['new_chat_member']
  3. Do anything

Need to update package
Please add method for get ChatMember (not NewChatMembers());

Request

{
    "update_id": 450268762,
    "chat_member": {
        "chat": {
            "id": -100.....,
            "title": "********",
            "username": "*******",
            "type": "supergroup"
        },
        "from": {
            "id": 7150985510,
            "is_bot": false,
            "first_name": "Лилия",
            "is_premium": true
        },
        "date": 1745486964,
        "old_chat_member": {
            "user": {
                "id": 7150985510,
                "is_bot": false,
                "first_name": "Лилия",
                "is_premium": true
            },
            "status": "left"
        },
        "new_chat_member": {
            "user": {
                "id": 7150985510,
                "is_bot": false,
                "first_name": "Лилия",
                "is_premium": true
            },
            "status": "member"
        },
        "via_chat_folder_invite_link": true
    }
}

Note that this request does not contain the message key, so getting an Message Instance impossible

$client->on(function (Update $update) use ($bot) {
            $message = $update->getMessage();
}

//$message = null;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions