sendPoll method
Future<Message>
sendPoll(
- dynamic chat_id,
- String question,
- List<
String> options, { - bool? is_anonymous,
- String? type,
- bool? allows_multiple_answers,
- int? correct_option_id,
- String? explanation,
- String? explanation_parse_mode,
- List<
MessageEntity> ? explanation_entities, - int? open_period,
- int? close_date,
- bool? is_closed,
- bool? disable_notification,
- int? reply_to_message_id,
- bool? allow_sending_without_reply,
- ReplyMarkup? reply_markup,
inherited
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 chat_id, String question, List<String> options,
{bool? is_anonymous,
String? type,
bool? allows_multiple_answers,
int? correct_option_id,
String? explanation,
String? explanation_parse_mode,
List<MessageEntity>? explanation_entities,
int? open_period,
int? close_date,
bool? is_closed,
bool? disable_notification,
int? reply_to_message_id,
bool? allow_sending_without_reply,
ReplyMarkup? reply_markup}) async {
if (chat_id is! String && chat_id is! int) {
return Future.error(TelegramException(
'Attribute \'chat_id\' can only be either type of String or int'));
}
var requestUrl = _apiUri('sendPoll');
var body = <String, dynamic>{
'chat_id': chat_id,
'question': question,
'options': jsonEncode(options),
'is_anonymous': is_anonymous,
'type': type,
'allows_multiple_answers': allows_multiple_answers,
'correct_option_id': correct_option_id,
'explanation': explanation,
'explanation_parse_mode': explanation_parse_mode,
'explanation_entities': explanation_entities == null
? null
: jsonEncode(explanation_entities),
'open_period': open_period,
'close_date': close_date,
'is_closed': is_closed,
'disable_notification': disable_notification,
'reply_to_message_id': reply_to_message_id,
'allow_sending_without_reply': allow_sending_without_reply,
'reply_markup': reply_markup == null ? null : jsonEncode(reply_markup),
};
return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}