sendGame
Gửi trò chơi.
Giá trị trả về: Nếu thành công, trả về Message.
Tham số
| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
business_connection_id | String | Tùy chọn | ID kết nối doanh nghiệp |
chat_id | Integer or String | Có | ID chat hoặc @username |
message_thread_id | Integer | Tùy chọn | ID chủ đề diễn đàn |
game_short_name | String | Có | Tên ngắn của trò chơi |
disable_notification | Boolean | Tùy chọn | Gửi không âm thanh |
protect_content | Boolean | Tùy chọn | Bảo vệ nội dung |
allow_paid_broadcast | Boolean | Tùy chọn | Cho phép gửi hàng loạt trả phí |
message_effect_id | String | Tùy chọn | ID hiệu ứng tin nhắn |
reply_parameters | ReplyParameters | Tùy chọn | Đối tượng JSON ReplyParameters |
reply_markup | InlineKeyboardMarkup | Tùy chọn | JSON: InlineKeyboardMarkup |
Ví dụ request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendGame" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789,"game_short_name":"mygame"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/sendGame",
json={
"chat_id": 123456789,
"game_short_name": "mygame"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendGame`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"game_short_name": "mygame"
}),
});
console.log(await res.json());
Hướng dẫn từng bước: Cách tạo bot Telegram từ A đến Z: BotFather, token và tin nhắn đầu tiên
Phương thức liên quan
setGameScoreĐặt điểm trò chơi của người dùng.getGameHighScoresTrả về bảng điểm cao của trò chơi.