sendGame
Envía un juego.
Devuelve: Si la llamada tiene éxito, devuelve Message.
Parámetros
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
business_connection_id | String | Opcional | ID de la conexión empresarial |
chat_id | Integer or String | Sí | ID del chat o @username |
message_thread_id | Integer | Opcional | ID del tema del foro |
game_short_name | String | Sí | Nombre corto del juego |
disable_notification | Boolean | Opcional | Enviar sin sonido |
protect_content | Boolean | Opcional | Proteger el contenido |
allow_paid_broadcast | Boolean | Opcional | Permitir difusión de pago |
message_effect_id | String | Opcional | ID del efecto del mensaje |
reply_parameters | ReplyParameters | Opcional | Objeto JSON ReplyParameters |
reply_markup | InlineKeyboardMarkup | Opcional | Objeto JSON InlineKeyboardMarkup |
Ejemplo de solicitud
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());
Guía paso a paso: Cómo crear un bot en Telegram paso a paso: de BotFather a tu primer mensaje
Métodos relacionados
setGameScoreEstablece la puntuación de un usuario en un juego.getGameHighScoresDevuelve las mejores puntuaciones de un juego.