Skip to content

setChatMemberStatus

Sahri Riza Umami edited this page Jun 22, 2018 · 1 revision

Changes the status of a chat member, needs appropriate privileges.
This function is currently not suitable for adding new members to the chat; instead, use addChatMember.
The chat member status will not be changed until it has been synchronized with the server.

setChatMemberStatus(chat_id, user_id, status, right, callback, data)
Field Type Description
chat_id int53 Chat identifier.
user_id int32 User identifier.
status string The new status of the member in the chat.

Status

  1. Creator

    The user is the creator of a chat and has all the administrator privileges.

  2. Administrator

    The user is a member of a chat and has some additional privileges. In basic groups, administrators can edit and delete messages sent by others, add new members, and ban unprivileged members. In supergroups and channels, there are more detailed options for administrator privileges.

    Administrator rights is written in these following form:

    {can_be_edited, can_change_info, can_post_messages, can_edit_messages, can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages, can_promote_members}
    
    Right Type Description
    can_be_edited Bool True, if the current user can edit the administrator privileges for the called user.
    can_change_info Bool True, if the administrator can change the chat title, photo, and other settings.
    can_post_messages Bool True, if the administrator can create channel posts; applicable to channels only.
    can_edit_messages Bool True, if the administrator can edit messages of other users and pin messages; applicable to channels only.
    can_delete_messages Bool True, if the administrator can delete messages of other users.
    can_invite_users Bool True, if the administrator can invite new users to the chat.
    can_restrict_members Bool True, if the administrator can restrict, ban, or unban chat members.
    can_pin_messages Bool True, if the administrator can pin messages; applicable to supergroups only.
    can_promote_members Bool True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that were directly or indirectly promoted by him.
  3. Member

    The user is a member of a chat, without any additional privileges or restrictions.

  4. Restricted

    The user is under certain restrictions in the chat. Not supported in basic groups and channels.

    Restricted user restriction is written in these following form:

    {is_member, restricted_until_date, can_send_messages, can_send_media_messages, can_send_other_messages, can_add_web_page_previews}
    
    Restriction Type Description
    is_member Bool True, if the user is a member of the chat.
    restricted_until_date int32 Point in time (Unix timestamp) when restrictions will be lifted from the user; 0 if never. If the user is restricted for more than 366 days or for less than 30 seconds from the current time, the user is considered to be restricted forever.
    can_send_messages Bool True, if the user can send text messages, contacts, locations, and venues.
    can_send_media_messages Bool True, if the user can send audio files, documents, photos, videos, video notes, and voice notes. Implies can_send_messages permissions.
    can_send_other_messages Bool True, if the user can send animations, games, and stickers and use inline bots. Implies can_send_media_messages permissions.
    can_add_web_page_previews Bool True, if the user may add a web page preview to his messages. Implies can_send_messages permissions.
  5. Left

    The user is not a chat member.

  6. Banned

    The user was banned (and hence is not a member of the chat). Implies the user can't return to the chat or view messages.

    Banned user restriction is written in these following form:

    {banned_until_date}
    
    Restriction Type Description
    banned_until_date int32 Point in time (Unix timestamp) when the user will be unbanned; 0 if never. If the user is banned for more than 366 days or for less than 30 seconds from the current time, the user is considered to be banned forever

Example

  • 133780085 is creator of the chat 1234567890.

    setChatMemberStatus(1234567890, 133780085, 'Creator', '{1}')
  • Promote user 133780085 as an administrator of chat 1234567890 and given all administrator rights, except promoting another member to be an administrator.

    setChatMemberStatus(1234567890, 133780085, 'Administrator', '{1,1,1,1,1,1,1,1,0}')
  • User 133780085 join a chat by chat's id.

    setChatMemberStatus(1234567890, 133780085, 'Member')
  • User 133780085 is leaving chat 1234567890.

    setChatMemberStatus(1234567890, 133780085, 'Left')
  • Kick and banned user 133780085 from chat 1234567890.

    setChatMemberStatus(1234567890, 133780085, 'Kicked', '{0}')

Frequently Asked Questions
The Functions

Clone this wiki locally