Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Update::getChat() for cases when a User banned and/or unbanned a bot #977

Merged

Conversation

alies-dev
Copy link
Contributor

Fix Update::getChat() for cases when a User banned and/or unbanned a bot

This is a special case when chat_id exist in a payload, but message object doesn't. Example of payload when a User banned a bot:

{
    "update_id": 276740005,
    "my_chat_member": {
        "chat": {
            "id": 2000000,
            "first_name": "Firstname",
            "last_name": "Lastname",
            "type": "private"
        },
        "from": {
            "id": 2000000,
            "is_bot": false,
            "first_name": "Firstname",
            "last_name": "Lastname",
            "language_code": "en"
        },
        "date": 1656768003,
        "old_chat_member": {
            "user": {
                "id": 2000001,
                "is_bot": true,
                "first_name": "My Bot",
                "username": "MyBot"
            },
            "status": "member"
        },
        "new_chat_member": {
            "user": {
                "id": 2000001,
                "is_bot": true,
                "first_name": "My Bot",
                "username": "MyBot"
            },
            "status": "kicked",
            "until_date": 0
        }
    }
}

Example of bot unbanned event:

{
    "update_id": 276740005,
    "my_chat_member": {
        "chat": {
            "id": 2000000,
            "first_name": "Firstname",
            "last_name": "Lastname",
            "type": "private"
        },
        "from": {
            "id": 2000000,
            "is_bot": false,
            "first_name": "Firstname",
            "last_name": "Lastname",
            "language_code": "en"
        },
        "date": 1656768003,
        "old_chat_member": {
            "user": {
                "id": 2000001,
                "is_bot": true,
                "first_name": "My Bot",
                "username": "MyBot"
            },
            "status": "kicked",
            "until_date": 0
        },
        "new_chat_member": {
            "user": {
                "id": 2000001,
                "is_bot": true,
                "first_name": "My Bot",
                "username": "MyBot"
            },
            "status": "member"
        }
    }
}

@irazasyed irazasyed merged commit 1932088 into irazasyed:develop Jul 10, 2022
@irazasyed
Copy link
Owner

This is a very good improvement. Appreciated. Thanks 👍🏻😊

@alies-dev alies-dev deleted the fix-getChat-for-bans-and-unbans branch August 9, 2022 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants