telegram

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Telegram Bot API Skill

Telegram Bot API 技能

You have full access to the Telegram Bot API. Use CLI commands for common operations, and direct API calls for everything else.
您拥有Telegram Bot API的完整访问权限。常用操作可使用CLI命令,其他操作可直接调用API。

Getting the Bot Token

获取Bot Token

bash
BOT_TOKEN=$(curl -s http://localhost:23001/api/settings | jq -r '.telegram.botToken')
bash
BOT_TOKEN=$(curl -s http://localhost:23001/api/settings | jq -r '.telegram.botToken')

API Call Pattern

API调用模式

bash
undefined
bash
undefined

JSON body (most methods)

JSON请求体(大多数方法)

curl -s "https://api.telegram.org/bot${BOT_TOKEN}/<METHOD>"
-H "Content-Type: application/json"
-d '{ ... }'
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/<METHOD>"
-H "Content-Type: application/json"
-d '{ ... }'

Multipart form (file uploads)

多部分表单(文件上传)

curl -s "https://api.telegram.org/bot${BOT_TOKEN}/<METHOD>"
-F "chat_id=<CHAT_ID>"
-F "photo=@/path/to/file.jpg"
-F "caption=optional caption"

Full API docs: https://core.telegram.org/bots/api

---
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/<METHOD>"
-F "chat_id=<CHAT_ID>"
-F "photo=@/path/to/file.jpg"
-F "caption=optional caption"

完整API文档:https://core.telegram.org/bots/api

---

CLI Quick Commands

CLI快速命令

bash
undefined
bash
undefined

Current chat (ALMA_CHAT_ID auto-set)

当前聊天(ALMA_CHAT_ID会自动设置)

alma send photo /path/to/img.jpg "caption" alma send file /path/to/doc.pdf "caption" alma send audio /path/to/song.mp3 alma send video /path/to/vid.mp4
alma send photo /path/to/img.jpg "caption" alma send file /path/to/doc.pdf "caption" alma send audio /path/to/song.mp3 alma send video /path/to/vid.mp4

Group operations

群组操作

alma group list alma group send <chatId> "text" alma group send-photo <chatId> /path "caption" alma group send-document <chatId> /path "caption" alma group send-video <chatId> /path "caption" alma group history <chatId> [limit] alma group search <chatId> "query" alma group context <chatId> alma group pin <chatId> <msgId> alma group unpin <chatId> [msgId] alma group leave <chatId> alma group patrol
alma group list alma group send <chatId> "text" alma group send-photo <chatId> /path "caption" alma group send-document <chatId> /path "caption" alma group send-video <chatId> /path "caption" alma group history <chatId> [limit] alma group search <chatId> "query" alma group context <chatId> alma group pin <chatId> <msgId> alma group unpin <chatId> [msgId] alma group leave <chatId> alma group patrol

Direct message & message mgmt

私信与消息管理

alma dm <userId> "message" alma msg delete <chatId> <msgId> alma msg react <chatId> <msgId> <emoji> # Add reaction to a message (e.g. ❤️ 😂 👍) alma msg sticker <chatId> <sticker_file_id> # Send a sticker (use file_id from received stickers) alma msg sticker-search [set_name] # List sticker sets (no args) or index a specific set alma msg sticker-find <emoji> # Find stickers by emoji across all indexed sets

---
alma dm <userId> "message" alma msg delete <chatId> <msgId> alma msg react <chatId> <msgId> <emoji> # 给消息添加反应(例如 ❤️ 😂 👍) alma msg sticker <chatId> <sticker_file_id> # 发送贴纸(使用收到贴纸的file_id) alma msg sticker-search [set_name] # 列出贴纸套装(无参数)或索引特定套装 alma msg sticker-find <emoji> # 在所有已索引的套装中按表情查找贴纸

---

All Telegram Bot API Methods

所有Telegram Bot API方法

Sending Messages

发送消息

MethodDescription
sendMessage
Send text message. Params:
chat_id
,
text
,
parse_mode
(HTML/Markdown),
reply_parameters
,
reply_markup
,
message_thread_id
,
link_preview_options
sendPhoto
Send photo.
chat_id
,
photo
(file_id/URL/upload),
caption
,
has_spoiler
sendDocument
Send file.
chat_id
,
document
,
caption
,
thumbnail
sendVideo
Send video.
chat_id
,
video
,
caption
,
duration
,
width
,
height
,
has_spoiler
sendAnimation
Send GIF.
chat_id
,
animation
,
caption
,
has_spoiler
sendAudio
Send audio.
chat_id
,
audio
,
caption
,
duration
,
performer
,
title
sendVoice
Send voice message.
chat_id
,
voice
,
caption
,
duration
sendVideoNote
Send round video.
chat_id
,
video_note
,
duration
,
length
sendSticker
Send sticker.
chat_id
,
sticker
(file_id/URL/upload)
sendLocation
Send location.
chat_id
,
latitude
,
longitude
,
live_period
sendVenue
Send venue.
chat_id
,
latitude
,
longitude
,
title
,
address
sendContact
Send contact.
chat_id
,
phone_number
,
first_name
,
last_name
sendPoll
Send poll.
chat_id
,
question
,
options
([{text:...}]),
is_anonymous
,
type
(quiz/regular),
allows_multiple_answers
sendDice
Send dice/slot.
chat_id
,
emoji
(🎲🎯🏀⚽🎳🎰)
sendMediaGroup
Send album (2-10 items).
chat_id
,
media
([{type,media,caption}])
sendChatAction
Show typing/uploading status.
chat_id
,
action
(typing/upload_photo/upload_video/upload_document/record_voice/record_video/etc)
sendMessageDraft
Stream partial message.
chat_id
,
text
,
business_connection_id
方法描述
sendMessage
发送文本消息。参数:
chat_id
text
parse_mode
(HTML/Markdown)、
reply_parameters
reply_markup
message_thread_id
link_preview_options
sendPhoto
发送照片。参数:
chat_id
photo
(file_id/URL/上传文件)、
caption
has_spoiler
sendDocument
发送文件。参数:
chat_id
document
caption
thumbnail
sendVideo
发送视频。参数:
chat_id
video
caption
duration
width
height
has_spoiler
sendAnimation
发送GIF。参数:
chat_id
animation
caption
has_spoiler
sendAudio
发送音频。参数:
chat_id
audio
caption
duration
performer
title
sendVoice
发送语音消息。参数:
chat_id
voice
caption
duration
sendVideoNote
发送圆形视频。参数:
chat_id
video_note
duration
length
sendSticker
发送贴纸。参数:
chat_id
sticker
(file_id/URL/上传文件)
sendLocation
发送位置。参数:
chat_id
latitude
longitude
live_period
sendVenue
发送地点信息。参数:
chat_id
latitude
longitude
title
address
sendContact
发送联系人。参数:
chat_id
phone_number
first_name
last_name
sendPoll
发送投票。参数:
chat_id
question
options
([{text:...}])、
is_anonymous
type
(quiz/regular)、
allows_multiple_answers
sendDice
发送骰子/老虎机。参数:
chat_id
emoji
(🎲🎯🏀⚽🎳🎰)
sendMediaGroup
发送相册(2-10个项目)。参数:
chat_id
media
([{type,media,caption}])
sendChatAction
显示输入/上传状态。参数:
chat_id
action
(typing/upload_photo/upload_video/upload_document/record_voice/record_video等)
sendMessageDraft
发送消息草稿。参数:
chat_id
text
business_connection_id

Forwarding & Copying

转发与复制

MethodDescription
forwardMessage
Forward message.
chat_id
(target),
from_chat_id
,
message_id
forwardMessages
Forward multiple.
chat_id
,
from_chat_id
,
message_ids
([array])
copyMessage
Copy without "Forwarded" header.
chat_id
,
from_chat_id
,
message_id
,
caption
copyMessages
Copy multiple.
chat_id
,
from_chat_id
,
message_ids
方法描述
forwardMessage
转发消息。参数:
chat_id
(目标)、
from_chat_id
message_id
forwardMessages
转发多条消息。参数:
chat_id
from_chat_id
message_ids
(数组)
copyMessage
复制消息(无"转发"标识)。参数:
chat_id
from_chat_id
message_id
caption
copyMessages
复制多条消息。参数:
chat_id
from_chat_id
message_ids

Editing Messages

编辑消息

MethodDescription
editMessageText
Edit text.
chat_id
,
message_id
,
text
,
parse_mode
,
reply_markup
editMessageCaption
Edit caption.
chat_id
,
message_id
,
caption
editMessageMedia
Edit media.
chat_id
,
message_id
,
media
editMessageReplyMarkup
Edit inline keyboard.
chat_id
,
message_id
,
reply_markup
editMessageLiveLocation
Update live location.
chat_id
,
message_id
,
latitude
,
longitude
stopMessageLiveLocation
Stop live location.
chat_id
,
message_id
deleteMessage
Delete message.
chat_id
,
message_id
deleteMessages
Delete multiple.
chat_id
,
message_ids
([array])
方法描述
editMessageText
编辑文本。参数:
chat_id
message_id
text
parse_mode
reply_markup
editMessageCaption
编辑说明文字。参数:
chat_id
message_id
caption
editMessageMedia
编辑媒体内容。参数:
chat_id
message_id
media
editMessageReplyMarkup
编辑内联键盘。参数:
chat_id
message_id
reply_markup
editMessageLiveLocation
更新实时位置。参数:
chat_id
message_id
latitude
longitude
stopMessageLiveLocation
停止实时位置更新。参数:
chat_id
message_id
deleteMessage
删除消息。参数:
chat_id
message_id
deleteMessages
删除多条消息。参数:
chat_id
message_ids
(数组)

Reactions

消息反应

MethodDescription
setMessageReaction
React to message.
chat_id
,
message_id
,
reaction
([{"type":"emoji","emoji":"👍"}]),
is_big
方法描述
setMessageReaction
给消息添加反应。参数:
chat_id
message_id
reaction
([{"type":"emoji","emoji":"👍"}])、
is_big

Chat Management

聊天管理

MethodDescription
getChat
Get chat info.
chat_id
getChatMemberCount
Member count.
chat_id
getChatMember
Get one member's info.
chat_id
,
user_id
getChatAdministrators
List admins.
chat_id
setChatTitle
Set title.
chat_id
,
title
setChatDescription
Set description.
chat_id
,
description
setChatPhoto
Set photo.
chat_id
,
photo
(upload)
deleteChatPhoto
Delete photo.
chat_id
setChatPermissions
Set default permissions.
chat_id
,
permissions
({can_send_messages, can_send_photos, ...})
setChatStickerSet
Set sticker set.
chat_id
,
sticker_set_name
deleteChatStickerSet
Remove sticker set.
chat_id
leaveChat
Leave chat.
chat_id
pinChatMessage
Pin message.
chat_id
,
message_id
,
disable_notification
unpinChatMessage
Unpin message.
chat_id
,
message_id
unpinAllChatMessages
Unpin all.
chat_id
方法描述
getChat
获取聊天信息。参数:
chat_id
getChatMemberCount
获取成员数量。参数:
chat_id
getChatMember
获取单个成员信息。参数:
chat_id
user_id
getChatAdministrators
列出管理员。参数:
chat_id
setChatTitle
设置标题。参数:
chat_id
title
setChatDescription
设置描述。参数:
chat_id
description
setChatPhoto
设置头像。参数:
chat_id
photo
(上传文件)
deleteChatPhoto
删除头像。参数:
chat_id
setChatPermissions
设置默认权限。参数:
chat_id
permissions
({can_send_messages, can_send_photos, ...})
setChatStickerSet
设置贴纸套装。参数:
chat_id
sticker_set_name
deleteChatStickerSet
移除贴纸套装。参数:
chat_id
leaveChat
离开聊天。参数:
chat_id
pinChatMessage
置顶消息。参数:
chat_id
message_id
disable_notification
unpinChatMessage
取消置顶消息。参数:
chat_id
message_id
unpinAllChatMessages
取消所有置顶消息。参数:
chat_id

Member Management

成员管理

MethodDescription
banChatMember
Ban user.
chat_id
,
user_id
,
until_date
,
revoke_messages
unbanChatMember
Unban user.
chat_id
,
user_id
,
only_if_banned
restrictChatMember
Restrict user.
chat_id
,
user_id
,
permissions
,
until_date
promoteChatMember
Promote to admin.
chat_id
,
user_id
,
can_change_info
,
can_post_messages
,
can_edit_messages
,
can_delete_messages
,
can_invite_users
,
can_restrict_members
,
can_pin_messages
,
can_promote_members
,
can_manage_video_chats
,
can_manage_chat
setChatAdministratorCustomTitle
Set admin title.
chat_id
,
user_id
,
custom_title
approveChatJoinRequest
Approve join request.
chat_id
,
user_id
declineChatJoinRequest
Decline join request.
chat_id
,
user_id
方法描述
banChatMember
封禁用户。参数:
chat_id
user_id
until_date
revoke_messages
unbanChatMember
解封用户。参数:
chat_id
user_id
only_if_banned
restrictChatMember
限制用户权限。参数:
chat_id
user_id
permissions
until_date
promoteChatMember
提升为管理员。参数:
chat_id
user_id
can_change_info
can_post_messages
can_edit_messages
can_delete_messages
can_invite_users
can_restrict_members
can_pin_messages
can_promote_members
can_manage_video_chats
can_manage_chat
setChatAdministratorCustomTitle
设置管理员自定义头衔。参数:
chat_id
user_id
custom_title
approveChatJoinRequest
批准加入请求。参数:
chat_id
user_id
declineChatJoinRequest
拒绝加入请求。参数:
chat_id
user_id

Invite Links

邀请链接

MethodDescription
exportChatInviteLink
Create new primary link.
chat_id
createChatInviteLink
Create invite link.
chat_id
,
name
,
expire_date
,
member_limit
,
creates_join_request
editChatInviteLink
Edit invite link.
chat_id
,
invite_link
, ...
revokeChatInviteLink
Revoke link.
chat_id
,
invite_link
createChatSubscriptionInviteLink
Paid subscription link.
chat_id
,
subscription_period
,
subscription_price
方法描述
exportChatInviteLink
创建新的主邀请链接。参数:
chat_id
createChatInviteLink
创建邀请链接。参数:
chat_id
name
expire_date
member_limit
creates_join_request
editChatInviteLink
编辑邀请链接。参数:
chat_id
invite_link
、...
revokeChatInviteLink
撤销邀请链接。参数:
chat_id
invite_link
createChatSubscriptionInviteLink
创建付费订阅链接。参数:
chat_id
subscription_period
subscription_price

Forum Topics

论坛话题

MethodDescription
createForumTopic
Create topic.
chat_id
,
name
,
icon_color
,
icon_custom_emoji_id
editForumTopic
Edit topic.
chat_id
,
message_thread_id
,
name
,
icon_custom_emoji_id
closeForumTopic
Close topic.
chat_id
,
message_thread_id
reopenForumTopic
Reopen topic.
chat_id
,
message_thread_id
deleteForumTopic
Delete topic.
chat_id
,
message_thread_id
unpinAllForumTopicMessages
Unpin all in topic.
chat_id
,
message_thread_id
getForumTopicIconStickers
Get available topic icons
editGeneralForumTopic
Edit General topic.
chat_id
,
name
closeGeneralForumTopic
Close General.
chat_id
reopenGeneralForumTopic
Reopen General.
chat_id
hideGeneralForumTopic
Hide General.
chat_id
unhideGeneralForumTopic
Unhide General.
chat_id
方法描述
createForumTopic
创建话题。参数:
chat_id
name
icon_color
icon_custom_emoji_id
editForumTopic
编辑话题。参数:
chat_id
message_thread_id
name
icon_custom_emoji_id
closeForumTopic
关闭话题。参数:
chat_id
message_thread_id
reopenForumTopic
重新打开话题。参数:
chat_id
message_thread_id
deleteForumTopic
删除话题。参数:
chat_id
message_thread_id
unpinAllForumTopicMessages
取消话题内所有置顶消息。参数:
chat_id
message_thread_id
getForumTopicIconStickers
获取可用的话题图标贴纸
editGeneralForumTopic
编辑通用话题。参数:
chat_id
name
closeGeneralForumTopic
关闭通用话题。参数:
chat_id
reopenGeneralForumTopic
重新打开通用话题。参数:
chat_id
hideGeneralForumTopic
隐藏通用话题。参数:
chat_id
unhideGeneralForumTopic
显示通用话题。参数:
chat_id

Bot Profile

Bot资料

MethodDescription
getMe
Get bot info
setMyName
Set bot name.
name
,
language_code
getMyName
Get bot name
setMyDescription
Set bot description.
description
,
language_code
getMyDescription
Get bot description
setMyShortDescription
Set short description.
short_description
getMyShortDescription
Get short description
setMyProfilePhoto
Set bot profile photo.
photo
removeMyProfilePhoto
Remove bot profile photo
setMyCommands
Set command list.
commands
([{command,description}]),
scope
,
language_code
getMyCommands
Get commands
deleteMyCommands
Delete commands
setChatMenuButton
Set menu button.
chat_id
,
menu_button
getChatMenuButton
Get menu button
setMyDefaultAdministratorRights
Set default admin rights.
rights
,
for_channels
getMyDefaultAdministratorRights
Get default admin rights
方法描述
getMe
获取Bot信息
setMyName
设置Bot名称。参数:
name
language_code
getMyName
获取Bot名称
setMyDescription
设置Bot描述。参数:
description
language_code
getMyDescription
获取Bot描述
setMyShortDescription
设置Bot简短描述。参数:
short_description
getMyShortDescription
获取Bot简短描述
setMyProfilePhoto
设置Bot头像。参数:
photo
removeMyProfilePhoto
移除Bot头像
setMyCommands
设置命令列表。参数:
commands
([{command,description}])、
scope
language_code
getMyCommands
获取命令列表
deleteMyCommands
删除命令列表
setChatMenuButton
设置菜单按钮。参数:
chat_id
menu_button
getChatMenuButton
获取菜单按钮
setMyDefaultAdministratorRights
设置默认管理员权限。参数:
rights
for_channels
getMyDefaultAdministratorRights
获取默认管理员权限

User Info

用户信息

MethodDescription
getUserProfilePhotos
Get profile photos.
user_id
,
offset
,
limit
getUserProfileAudios
Get profile audios.
user_id
方法描述
getUserProfilePhotos
获取用户头像。参数:
user_id
offset
limit
getUserProfileAudios
获取用户个人音频。参数:
user_id

Files

文件

MethodDescription
getFile
Get file download info.
file_id
. Download:
https://api.telegram.org/file/bot<TOKEN>/<file_path>
方法描述
getFile
获取文件下载信息。参数:
file_id
。下载地址:
https://api.telegram.org/file/bot<TOKEN>/<file_path>

Inline Keyboards & Callbacks

内联键盘与回调

json
// reply_markup for inline buttons
{
  "inline_keyboard": [
    [{"text": "Button 1", "callback_data": "btn1"}, {"text": "URL", "url": "https://example.com"}],
    [{"text": "Row 2", "callback_data": "btn2"}]
  ]
}
MethodDescription
answerCallbackQuery
Answer callback from inline button.
callback_query_id
,
text
,
show_alert
json
// 内联按钮的reply_markup
{
  "inline_keyboard": [
    [{"text": "Button 1", "callback_data": "btn1"}, {"text": "URL", "url": "https://example.com"}],
    [{"text": "Row 2", "callback_data": "btn2"}]
  ]
}
方法描述
answerCallbackQuery
响应内联按钮的回调。参数:
callback_query_id
text
show_alert

Stickers

贴纸

MethodDescription
sendSticker
Send sticker.
chat_id
,
sticker
getStickerSet
Get sticker set.
name
getCustomEmojiStickers
Get custom emoji.
custom_emoji_ids
createNewStickerSet
Create sticker set.
user_id
,
name
,
title
,
stickers
addStickerToSet
Add sticker.
user_id
,
name
,
sticker
setStickerPositionInSet
Reorder.
sticker
,
position
deleteStickerFromSet
Delete sticker.
sticker
setStickerSetTitle
Set title.
name
,
title
setStickerSetThumbnail
Set thumbnail.
name
,
user_id
,
thumbnail
方法描述
sendSticker
发送贴纸。参数:
chat_id
sticker
getStickerSet
获取贴纸套装。参数:
name
getCustomEmojiStickers
获取自定义表情。参数:
custom_emoji_ids
createNewStickerSet
创建新贴纸套装。参数:
user_id
name
title
stickers
addStickerToSet
向套装添加贴纸。参数:
user_id
name
sticker
setStickerPositionInSet
调整贴纸顺序。参数:
sticker
position
deleteStickerFromSet
从套装删除贴纸。参数:
sticker
setStickerSetTitle
设置套装标题。参数:
name
title
setStickerSetThumbnail
设置套装缩略图。参数:
name
user_id
thumbnail

Payments

支付

MethodDescription
sendInvoice
Send invoice.
chat_id
,
title
,
description
,
payload
,
currency
,
prices
createInvoiceLink
Create payment link
answerShippingQuery
Answer shipping.
shipping_query_id
,
ok
,
shipping_options
answerPreCheckoutQuery
Answer checkout.
pre_checkout_query_id
,
ok
refundStarPayment
Refund stars.
user_id
,
telegram_payment_charge_id
方法描述
sendInvoice
发送发票。参数:
chat_id
title
description
payload
currency
prices
createInvoiceLink
创建支付链接
answerShippingQuery
响应配送查询。参数:
shipping_query_id
ok
shipping_options
answerPreCheckoutQuery
响应预结账查询。参数:
pre_checkout_query_id
ok
refundStarPayment
退款Stars支付。参数:
user_id
telegram_payment_charge_id

Games

游戏

MethodDescription
sendGame
Send game.
chat_id
,
game_short_name
setGameScore
Set score.
user_id
,
score
,
chat_id
,
message_id
getGameHighScores
Get scores.
user_id
,
chat_id
,
message_id

方法描述
sendGame
发送游戏。参数:
chat_id
game_short_name
setGameScore
设置游戏分数。参数:
user_id
score
chat_id
message_id
getGameHighScores
获取游戏最高分。参数:
user_id
chat_id
message_id

Common Examples

常见示例

Post to a channel

发布到频道

bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "@channel_username", "text": "Hello!"}'
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "@channel_username", "text": "Hello!"}'

Send photo with inline keyboard

发送带内联键盘的照片

bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendPhoto" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "'$ALMA_CHAT_ID'",
    "photo": "https://example.com/image.jpg",
    "caption": "Check this out!",
    "reply_markup": {"inline_keyboard": [[{"text":"👍 Like","callback_data":"like"},{"text":"👎","callback_data":"dislike"}]]}
  }'
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendPhoto" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "'$ALMA_CHAT_ID'",
    "photo": "https://example.com/image.jpg",
    "caption": "Check this out!",
    "reply_markup": {"inline_keyboard": [[{"text":"👍 Like","callback_data":"like"},{"text":"👎","callback_data":"dislike"}]]}
  }'

Forward message between chats

在聊天之间转发消息

bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/forwardMessage" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "<TARGET>", "from_chat_id": "<SOURCE>", "message_id": 123}'
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/forwardMessage" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "<TARGET>", "from_chat_id": "<SOURCE>", "message_id": 123}'

Create a poll

创建投票

bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendPoll" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "'$ALMA_CHAT_ID'", "question": "Best language?", "options": [{"text":"Rust"},{"text":"TypeScript"},{"text":"Python"}], "is_anonymous": false}'
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendPoll" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "'$ALMA_CHAT_ID'", "question": "Best language?", "options": [{"text":"Rust"},{"text":"TypeScript"},{"text":"Python"}], "is_anonymous": false}'

Reply to a specific message

回复特定消息

bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "'$ALMA_CHAT_ID'", "text": "Replying!", "reply_parameters": {"message_id": 5678}}'
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "'$ALMA_CHAT_ID'", "text": "Replying!", "reply_parameters": {"message_id": 5678}}'

Promote user to admin

提升用户为管理员

bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/promoteChatMember" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "<GROUP>", "user_id": 12345, "can_pin_messages": true, "can_invite_users": true}'
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/promoteChatMember" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "<GROUP>", "user_id": 12345, "can_pin_messages": true, "can_invite_users": true}'

Upload and send a local file

上传并发送本地文件

bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument" \
  -F "chat_id=$ALMA_CHAT_ID" \
  -F "document=@/path/to/file.pdf" \
  -F "caption=Here's the document"
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument" \
  -F "chat_id=$ALMA_CHAT_ID" \
  -F "document=@/path/to/file.pdf" \
  -F "caption=Here's the document"

Send album (media group)

发送相册(媒体组)

bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "'$ALMA_CHAT_ID'", "media": [
    {"type":"photo","media":"https://example.com/1.jpg","caption":"First"},
    {"type":"photo","media":"https://example.com/2.jpg"}
  ]}'
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "'$ALMA_CHAT_ID'", "media": [
    {"type":"photo","media":"https://example.com/1.jpg","caption":"First"},
    {"type":"photo","media":"https://example.com/2.jpg"}
  ]}'

Create invite link

创建邀请链接

bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/createChatInviteLink" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "<GROUP>", "name": "My Link", "member_limit": 100}'
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/createChatInviteLink" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": "<GROUP>", "name": "My Link", "member_limit": 100}'

Tips

提示

  • Channel posts: Use
    @channel_username
    or numeric chat_id (starts with
    -100
    )
  • Bot must be admin to: post to channels, pin, delete others' messages, ban, manage topics
  • ALMA_CHAT_ID is auto-set in Bash tool env — use it for current chat
  • File uploads: Use
    -F
    multipart form, not
    -d
    JSON
  • parse_mode: Use
    "HTML"
    for
    <b>bold</b> <i>italic</i> <code>code</code> <a href="url">link</a>
  • Group IDs are negative; user IDs are positive
  • Message IDs are visible as
    [msg:xxx]
    in chat
  • For methods not listed here, check https://core.telegram.org/bots/api
  • 频道发帖:使用
    @channel_username
    或数字聊天ID(以
    -100
    开头)
  • Bot必须是管理员才能:在频道发帖、置顶消息、删除他人消息、封禁用户、管理话题
  • ALMA_CHAT_ID会在Bash工具环境中自动设置 — 可用于当前聊天
  • 文件上传:使用
    -F
    多部分表单,而非
    -d
    JSON
  • parse_mode:使用
    "HTML"
    来实现
    <b>粗体</b> <i>斜体</i> <code>代码</code> <a href="url">链接</a>
    格式
  • 群组ID为负数;用户ID为正数
  • 消息ID在聊天中显示为
    [msg:xxx]
  • 未在此列出的方法,请查看https://core.telegram.org/bots/api