Skip to content

Instantly share code, notes, and snippets.

@Olegt0rr
Last active January 22, 2022 14:33
Show Gist options
  • Save Olegt0rr/7c916ccfe9f9494c6cd495546bb086f7 to your computer and use it in GitHub Desktop.
Save Olegt0rr/7c916ccfe9f9494c6cd495546bb086f7 to your computer and use it in GitHub Desktop.
USER_BANNED_IN_CHANNEL

Description

Can't understand the meaning of returned exception USER_BANNED_IN_CHANNEL on sending chatAction to the supergroup while @TrueMafiaBot (id: 468253535) is a member of that supergroup (e.g. -1001639443192) and has all required permissions.

Looks like a #bug. I know about 3000 groups with similar bot behaviour.

Workaroud

I tell my users to give admin permissions to the bot - it helps to avoid described behaviour.

How to reproduce

All described below JSONs are not modified, just masked token in URLs and chat join link.

Chat action

Let's try to send chat action...

Request

https://api.telegram.org/bot{{token}}/sendChatAction

{
    "action": "typing",
    "chat_id": -1001639443192
}

Response

{
    "ok": false,
    "error_code": 400,
    "description": "Bad Request: USER_BANNED_IN_CHANNEL"
}

ChatMember

May be bot is really banned? Let's look...

Request:

https://api.telegram.org/bot{{token}}/getChatMember

{
    "chat_id": -1001639443192,
    "user_id": 468253535
}

Result:

{
    "ok": true,
    "result": {
        "user": {
            "id": 468253535,
            "is_bot": true,
            "first_name": "True Mafia",
            "username": "TrueMafiaBot"
        },
        "status": "member"
    }
}

Chat

May be Chat has restricted permissions by default?
May be Chat has a wrong type (e.g. channel)?
Let's check...

Request

https://api.telegram.org/bot{{token}}/getChat

{
    "chat_id": -1001422827258
}

Response

{
    "ok": true,
    "result": {
        "id": -1001422827258,
        "title": "fams lia💘",
        "username": "famsslia",
        "type": "supergroup",
        "invite_link": "https://t.me/...",
        "permissions": {
            "can_send_messages": true,
            "can_send_media_messages": true,
            "can_send_polls": true,
            "can_send_other_messages": true,
            "can_add_web_page_previews": true,
            "can_change_info": false,
            "can_invite_users": true,
            "can_pin_messages": false
        },
        "photo": {
            "small_file_id": "AQADBQAD264xG8FbCVcACAIAAwZRjNYW____fLGIVCxHb2MjBA",
            "small_file_unique_id": "AQAD264xG8FbCVcAAQ",
            "big_file_id": "AQADBQAD264xG8FbCVcACAMAAwZRjNYW____fLGIVCxHb2MjBA",
            "big_file_unique_id": "AQAD264xG8FbCVcB"
        },
        "pinned_message": {
            "message_id": 244,
            "from": {
                "id": 2110231490,
                "is_bot": false,
                "first_name": "lia🎸",
                "username": "grblia",
                "language_code": "id"
            },
            "chat": {
                "id": -1001422827258,
                "title": "fams lia💘",
                "username": "famsslia",
                "type": "supergroup"
            },
            "date": 1642136416,
            "edit_date": 1642138077,
            "text": "Bkin fams yk \n\nDdy : \nBuna : sy (Lia)\n\nAbng 1 : Alvino ( not id )\nAbng 2 :  Ardory\nAbng 3 :\nAbng 4 : jidan\n\nTth 1 :\nTth 2 : \nTth 3 : Yoonsa Alexander\nTth 4 : vya\n\nBontot 1: Lyara \nBontot 2: alexxa aldebagong\nBontot 3: ellena\nBontot 4:\n\nAunty 1 :  KEY!\nAunty 2 :  \nAunty 3 :  zeiy\nAunty 4 :\n\nUncle 1 : Jacky\nuncle 2 :\nUncle 3 :\nuncle 4 :\n\nYng Minat bae\nhttps://t.me/famsslia",
            "entities": [
                {
                    "offset": 352,
                    "length": 21,
                    "type": "url"
                }
            ]
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment