sendPoll method
Future<Message>
sendPoll(
- dynamic chatId,
- String question,
- List<
String> options, { - int? messageThreadId,
- bool? isAnonymous,
- String? type,
- bool? allowsMultipleAnswers,
- int? correctOptionId,
- String? explanation,
- String? explanationParseMode,
- List<
MessageEntity> ? explanationEntities, - int? openPeriod,
- int? closeDate,
- bool? isClosed,
- bool? disableNotification,
- bool? protectContent,
- int? replyToMessageId,
- bool? allowSendingWithoutReply,
- ReplyMarkup? replyMarkup,
Use this method to send a native poll
A native poll can't be sent to a private chat.
On success, the sent Message is returned.
Implementation
Future<Message> sendPoll(
dynamic chatId, String question, List<String> options,
{int? messageThreadId,
bool? isAnonymous,
String? type,
bool? allowsMultipleAnswers,
int? correctOptionId,
String? explanation,
String? explanationParseMode,
List<MessageEntity>? explanationEntities,
int? openPeriod,
int? closeDate,
bool? isClosed,
bool? disableNotification,
bool? protectContent,
int? replyToMessageId,
bool? allowSendingWithoutReply,
ReplyMarkup? replyMarkup}) async {
if (chatId is! String && chatId is! int) {
return Future.error(TelegramException(
'Attribute \'chatId\' can only be either type of String or int'));
}
var requestUrl = _apiUri('sendPoll');
var body = <String, dynamic>{
'chat_id': chatId,
'message_thread_id': messageThreadId,
'question': question,
'options': jsonEncode(options),
'is_anonymous': isAnonymous,
'type': type,
'allows_multiple_answers': allowsMultipleAnswers,
'correct_option_id': correctOptionId,
'explanation': explanation,
'explanation_parse_mode': explanationParseMode,
'explanation_entities':
explanationEntities == null ? null : jsonEncode(explanationEntities),
'open_period': openPeriod,
'close_date': closeDate,
'is_closed': isClosed,
'disable_notification': disableNotification,
'protect_content': protectContent,
'reply_to_message_id': replyToMessageId,
'allow_sending_without_reply': allowSendingWithoutReply,
'reply_markup': replyMarkup == null ? null : jsonEncode(replyMarkup),
};
return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}