setGameScore
Kullanıcının oyun skorunu ayarlar.
Dönüş değeri: Başarılı olduğunda Message or True döndürür.
Parametreler
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
user_id | Integer | Evet | Kullanıcı ID'si |
score | Integer | Evet | Yeni skor |
force | Boolean | İsteğe bağlı | Daha düşük olsa bile skorun üzerine yaz |
disable_edit_message | Boolean | İsteğe bağlı | Mesajı düzenleme, yenisini gönder |
chat_id | Integer | İsteğe bağlı | Sohbet ID'si (satır içi olmayan mesajlar için) |
message_id | Integer | İsteğe bağlı | Mesaj ID'si (satır içi olmayan mesajlar için) |
inline_message_id | String | İsteğe bağlı | Satır içi mesaj ID'si |
Örnek istek
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/setGameScore" \
-H "Content-Type: application/json" \
-d '{"user_id":123456789,"score":100}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/setGameScore",
json={
"user_id": 123456789,
"score": 100
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/setGameScore`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"user_id": 123456789,
"score": 100
}),
});
console.log(await res.json());
Adım adım rehber: Telegram bot nasıl yapılır? BotFather ile adım adım bot oluşturma
İlgili metotlar
sendGameOyun gönderir.getGameHighScoresOyunun yüksek skorlarını döndürür.