sendPoll
Anket gönderir.
Dönüş değeri: Başarılı olduğunda Message döndürür.
Parametreler
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
business_connection_id | String | İsteğe bağlı | İşletme bağlantısı ID'si |
chat_id | Integer or String | Evet | Sohbet ID'si veya @username |
message_thread_id | Integer | İsteğe bağlı | Forum konusu ID'si |
question | String | Evet | Soru (1-300 karakter) |
question_parse_mode | String | İsteğe bağlı | Soru biçimlendirme modu: HTML, Markdown, MarkdownV2 |
question_entities | Array of MessageEntity | İsteğe bağlı | Soru için JSON MessageEntity dizisi |
options | Array of InputPollOption | Evet | JSON InputPollOption dizisi [{"text":"Option 1"},{"text":"Option 2"}] |
is_anonymous | Boolean | İsteğe bağlı | Anonim anket (varsayılan true) |
type | String | İsteğe bağlı | quiz veya regular |
allows_multiple_answers | Boolean | İsteğe bağlı | Birden fazla cevaba izin ver |
allows_revoting | Boolean | İsteğe bağlı | Yeniden oy vermeye izin ver (Bot API 9.6) |
shuffle_options | Boolean | İsteğe bağlı | Seçenekleri karıştır (Bot API 9.6) |
allow_adding_options | Boolean | İsteğe bağlı | Seçenek eklemeye izin ver (Bot API 9.6) |
hide_results_until_closes | Boolean | İsteğe bağlı | Anket kapanana kadar sonuçları gizle (Bot API 9.6) |
members_only | Boolean | İsteğe bağlı | Yalnızca üyeler (Bot API 10.0) |
country_codes | Array of String | İsteğe bağlı | Ülke kodlarının JSON dizisi (Bot API 10.0) |
correct_option_ids | Array of Integer | İsteğe bağlı | Doğru seçenek ID'lerinin JSON dizisi (quiz için), ör. [0] |
explanation | String | İsteğe bağlı | Doğru cevabın açıklaması (quiz için) |
explanation_parse_mode | String | İsteğe bağlı | Açıklama biçimlendirme modu |
explanation_entities | Array of MessageEntity | İsteğe bağlı | Açıklama için JSON MessageEntity dizisi |
explanation_media | InputPollMedia | İsteğe bağlı | JSON InputPollMedia nesnesi (Bot API 10.0) |
open_period | Integer | İsteğe bağlı | Anketin açık kalma süresi (saniye, 5-2628000) |
close_date | Integer | İsteğe bağlı | Anketin kapanacağı Unix zaman damgası |
is_closed | Boolean | İsteğe bağlı | Anketi hemen kapat |
description | String | İsteğe bağlı | Anket açıklaması (0-1024 karakter, Bot API 9.6) |
description_parse_mode | String | İsteğe bağlı | Açıklama biçimlendirme modu: HTML, Markdown, MarkdownV2 |
description_entities | Array of MessageEntity | İsteğe bağlı | Açıklama için JSON MessageEntity dizisi |
media | InputPollMedia | İsteğe bağlı | JSON InputPollMedia nesnesi — anket medyası (Bot API 10.0) |
disable_notification | Boolean | İsteğe bağlı | Sessiz gönder |
protect_content | Boolean | İsteğe bağlı | İçeriği koru |
allow_paid_broadcast | Boolean | İsteğe bağlı | Ücretli yayına izin ver |
message_effect_id | String | İsteğe bağlı | Mesaj efekti ID'si |
reply_parameters | ReplyParameters | İsteğe bağlı | JSON ReplyParameters nesnesi |
reply_markup | InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply | İsteğe bağlı | JSON: InlineKeyboardMarkup / ReplyKeyboardMarkup / ReplyKeyboardRemove / ForceReply |
Örnek istek
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendPoll" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 123456789,
"question": "Which language do you use?",
"options": [
{
"text": "Python"
},
{
"text": "JavaScript"
}
]
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/sendPoll",
json={
"chat_id": 123456789,
"question": "Which language do you use?",
"options": [
{
"text": "Python"
},
{
"text": "JavaScript"
}
]
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendPoll`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"question": "Which language do you use?",
"options": [
{
"text": "Python"
},
{
"text": "JavaScript"
}
]
}),
});
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
stopPollAnketi durdurur.