setChatAdministratorCustomTitle
为管理员设置自定义头衔。
返回值: 调用成功时返回 True。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
chat_id | Integer or String | 是 | 聊天 ID |
user_id | Integer | 是 | 用户 ID |
custom_title | String | 是 | 新头衔(0-16 个字符) |
请求示例
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/setChatAdministratorCustomTitle" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789,"user_id":123456789,"custom_title":"Moderator"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/setChatAdministratorCustomTitle",
json={
"chat_id": 123456789,
"user_id": 123456789,
"custom_title": "Moderator"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/setChatAdministratorCustomTitle`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"user_id": 123456789,
"custom_title": "Moderator"
}),
});
console.log(await res.json());
分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息
相关方法
banChatMember封禁聊天成员。unbanChatMember解封聊天成员。restrictChatMember限制聊天成员。promoteChatMember将聊天成员任命为管理员。banChatSenderChat在群组/超级群组中封禁频道。unbanChatSenderChat在群组/超级群组中解封频道。pinChatMessage在聊天中置顶消息。unpinChatMessage在聊天中取消置顶消息。unpinAllChatMessages取消聊天中所有消息的置顶。setChatMemberTag设置聊天成员标签 (Bot API 9.5)。