banChatMember
将用户从聊天中踢出。
请求
POST /:token/banchatmember
参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| chat_id | Integer/String | 是 | 目标聊天的唯一标识符或用户名 |
| user_id | Integer | 是 | 要封禁的用户的唯一标识符 |
| until_date | Integer | 否 | 封禁截止时间的 Unix 时间戳。若为 0 或不设置,则永久封禁。封禁时间少于 30 秒或多于 366 天将被视为永久封禁 |
响应
成功时返回 Boolean 值 true。
json
{
"ok": true,
"result": true
}错误码
| 错误码 | 描述 |
|---|---|
| 400 | 请求参数错误,如缺少 chat_id 或 user_id |
| 401 | Token 无效或已过期 |
| 403 | Bot 没有管理员权限或没有封禁用户的权限 |
| 404 | 聊天或用户不存在 |
| 500 | 服务器内部错误 |
示例
cURL
永久封禁用户
bash
curl -X POST "https://api.example.com/<token>/banchatmember" \
-H "Content-Type: application/json" \
-d '{
"chat_id": -1001234567890,
"user_id": 987654321
}'临时封禁用户(24 小时)
bash
curl -X POST "https://api.example.com/<token>/banchatmember" \
-H "Content-Type: application/json" \
-d '{
"chat_id": -1001234567890,
"user_id": 987654321,
"until_date": 1700086400
}'