|
|
|
@ -1590,49 +1590,3 @@ func (b *Bot) DeleteStickerFromSet(sticker string) error {
|
|
|
|
|
|
|
|
|
|
return extractOkResponse(respJSON)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SendPoll sends poll to chat
|
|
|
|
|
func (b *Bot) SendPoll(to Recipient, poll *Poll, options *PollOptions) (*Message, error) {
|
|
|
|
|
params := map[string]string{
|
|
|
|
|
"chat_id": to.Recipient(),
|
|
|
|
|
"question": poll.Question,
|
|
|
|
|
"type": poll.Type,
|
|
|
|
|
"allows_multiple_answers": strconv.FormatBool(poll.AllowsMultipleAnswers),
|
|
|
|
|
"correct_option_id": strconv.Itoa(poll.CorrectOptionID),
|
|
|
|
|
"is_anonymous": strconv.FormatBool(poll.IsAnonymous),
|
|
|
|
|
"is_closed": strconv.FormatBool(poll.IsClosed),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if poll.Type == "" {
|
|
|
|
|
params["type"] = "regular"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if poll.Options != nil {
|
|
|
|
|
var options []string
|
|
|
|
|
for _, opt := range poll.Options {
|
|
|
|
|
options = append(options, opt.Text)
|
|
|
|
|
}
|
|
|
|
|
opts, _ := json.Marshal(options)
|
|
|
|
|
params["options"] = string(opts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if options != nil {
|
|
|
|
|
if options.DisableNotification {
|
|
|
|
|
params["disable_notification"] = "true"
|
|
|
|
|
}
|
|
|
|
|
if options.ReplyToMessageID != nil {
|
|
|
|
|
params["reply_to_message_id"] = strconv.Itoa(*options.ReplyToMessageID)
|
|
|
|
|
}
|
|
|
|
|
if options.ReplyMarkup != nil {
|
|
|
|
|
markup, _ := json.Marshal(options.ReplyMarkup)
|
|
|
|
|
params["reply_markup"] = string(markup)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
respJSON, err := b.Raw("sendPoll", params)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return extractMsgResponse(respJSON)
|
|
|
|
|
}
|
|
|
|
|