Skip to content

promoteChatMember

提升或降级聊天成员为管理员。

请求

POST /:token/promotechatmember

参数

参数类型必填描述
chat_idInteger/String目标聊天的唯一标识符或用户名
user_idInteger目标用户的唯一标识符
is_anonymousBoolean是否允许管理员匿名操作
can_manage_chatBoolean是否可以管理聊天(访问聊天统计数据、查看频道成员列表等)
can_post_messagesBoolean是否可以在频道中发布消息(仅频道)
can_edit_messagesBoolean是否可以编辑频道中的消息(仅频道)
can_delete_messagesBoolean是否可以删除消息
can_manage_video_chatsBoolean是否可以管理视频聊天
can_restrict_membersBoolean是否可以限制、封禁或解封成员
can_promote_membersBoolean是否可以添加新的管理员
can_change_infoBoolean是否可以修改聊天标题、照片和其他设置
can_invite_usersBoolean是否可以邀请新用户加入聊天
can_pin_messagesBoolean是否可以置顶消息

所有可选的权限参数默认值为 false。传入 true 表示授予该权限,传入 false 表示撤销该权限。若需将管理员降级为普通成员,可将所有权限参数设为 false

响应

成功时返回 Boolean 值 true

json
{
  "ok": true,
  "result": true
}

错误码

错误码描述
400请求参数错误,如缺少 chat_id 或 user_id
401Token 无效或已过期
403Bot 没有足够的管理员权限来执行此操作
404聊天或用户不存在
500服务器内部错误

示例

cURL

提升为管理员(授予部分权限)

bash
curl -X POST "https://api.example.com/<token>/promotechatmember" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": -1001234567890,
    "user_id": 987654321,
    "can_manage_chat": true,
    "can_delete_messages": true,
    "can_restrict_members": true,
    "can_invite_users": true,
    "can_pin_messages": true
  }'

降级为普通成员

bash
curl -X POST "https://api.example.com/<token>/promotechatmember" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": -1001234567890,
    "user_id": 987654321,
    "can_manage_chat": false,
    "can_delete_messages": false,
    "can_restrict_members": false,
    "can_invite_users": false,
    "can_pin_messages": false
  }'