N
N
Newmo2019-10-10 15:27:30
go
Newmo, 2019-10-10 15:27:30

Is it possible to create a poll using telegram-bot-api?

Is it possible to create a poll using telegram-bot-api?
I did not find anything in the documentation on github (github.com/go-telegram-bot-api/telegram-bot-api).

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
Newmo, 2019-10-14
@Newmo

I found support for a new api with anonymous polls in the dev branch.
poll := tgbotapi.SendPollConfig{BaseChat, "Question", []x}
bot.Send(poll)

A
Alexander Pavlyuk, 2019-10-10
@pav5000

It is possible, somewhere you look at the documentation in the wrong place.
Here is the official doc on api methods, the sendPoll method publishes a poll https://core.telegram.org/bots/api#sendpoll
Another question is that the go-telegram-bot-api library you are using may not yet support this method. You can write it down and make a pull request about it.

A
Anton Neverov, 2019-10-10
@TTATPuOT

Yes, you can.
A poll is the most common bot that consults a database and stores data in it.

N
Nikita, 2020-12-17
@somebug

An example for quiz, maybe it will be useful to someone

poll := tgbotapi.SendPollConfig{
  BaseChat: tgbotapi.BaseChat{
    ChatID: update.Message.Chat.ID,
  },
  Question:        "Answer to the Ultimate Question of Life, the Universe, and Everything",
  Type:            "quiz",
  Options:         []string{"41", "42", "32", "1"},
  CorrectOptionID: 1,
}
bot.Send(poll)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question