Telegram Bot API
🌐 中文

promoteChatMember

分类: 管理 · Bot API 10.3 · 官方文档

将聊天成员任命为管理员。

返回值: 调用成功时返回 True。

参数

参数类型必填说明
chat_idInteger or String是聊天 ID
user_idInteger是用户 ID
is_anonymousBoolean可选匿名管理员
can_manage_chatBoolean可选可管理聊天
can_delete_messagesBoolean可选可删除消息
can_manage_video_chatsBoolean可选可管理视频聊天
can_restrict_membersBoolean可选可限制成员
can_promote_membersBoolean可选可任命管理员
can_change_infoBoolean可选可修改聊天信息
can_invite_usersBoolean可选可邀请用户
can_post_storiesBoolean可选可发布动态
can_edit_storiesBoolean可选可编辑动态
can_delete_storiesBoolean可选可删除动态
can_post_messagesBoolean可选可发布消息(频道)
can_edit_messagesBoolean可选可编辑消息(频道)
can_pin_messagesBoolean可选可置顶消息
can_manage_topicsBoolean可选可管理话题
can_manage_direct_messagesBoolean可选可管理私信 (Bot API 10.0)
can_manage_tagsBoolean可选可管理标签 (Bot API 9.5)
can_send_welcome_messagesBoolean可选可管理聊天欢迎消息 (Bot API 10.3)

参数说明为简要概括,完整内容请参阅官方文档。

请求示例

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/promoteChatMember" \
  -H "Content-Type: application/json" \
  -d '{"chat_id":123456789,"user_id":123456789}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/promoteChatMember",
    json={
        "chat_id": 123456789,
        "user_id": 123456789
    },
    timeout=30,
)
print(resp.json())

JavaScript

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/promoteChatMember`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "chat_id": 123456789,
    "user_id": 123456789
  }),
});
console.log(await res.json());

分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息