setGameScore
사용자의 게임 점수를 설정합니다.
반환값: 성공 시 반환값: Message or True.
매개변수
| 매개변수 | 타입 | 필수 | 설명 |
|---|---|---|---|
user_id | Integer | 예 | 사용자 ID |
score | Integer | 예 | 새 점수 |
force | Boolean | 선택 | 더 낮아도 점수 덮어쓰기 |
disable_edit_message | Boolean | 선택 | 메시지를 수정하지 않고 새로 전송 |
chat_id | Integer | 선택 | 채팅 ID (인라인이 아닌 메시지용) |
message_id | Integer | 선택 | 메시지 ID (인라인이 아닌 메시지용) |
inline_message_id | String | 선택 | 인라인 메시지 ID |
요청 예제
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());
단계별 가이드: 텔레그램 봇 만들기: @BotFather로 생성하고 첫 메시지 보내기
관련 메서드
sendGame게임을 전송합니다.getGameHighScores게임 최고 점수를 반환합니다.