Messages

Polls & reactions

Two small features on the messages namespace. Polls are first-class server objects with their own update stream. Reactions are short tag-like emojis attached to any message.

Polls

client.SendPoll(peerID, "Tabs or spaces?", []string{
	"Tabs",
	"Spaces",
	"Honestly I do not care",
}, &telegram.PollOptions{
	PublicVoters: false, // anonymous
	MCQ:          false, // single choice
})
client.SendPoll(peerID, "Tabs or spaces?", []string{
	"Tabs",
	"Spaces",
	"Honestly I do not care",
}, &telegram.PollOptions{
	PublicVoters: false, // anonymous
	MCQ:          false, // single choice
})

PollOptions fields:

PublicVoters
Show who voted for each option. Off by default in groups, forced on by the server for quizzes.
MCQ
Allow voting for more than one option.
ClosePeriod
Seconds before the poll auto-closes (measured from creation).
CloseDate
Unix timestamp; the poll closes at that absolute moment.
NoForwards
Prevent the poll message from being forwarded or saved.
client.SendPoll(peerID, "Coffee?", []string{"Yes", "No"}, &telegram.PollOptions{
	ClosePeriod: 300, // 5 minutes
})
client.SendPoll(peerID, "Coffee?", []string{"Yes", "No"}, &telegram.PollOptions{
	ClosePeriod: 300, // 5 minutes
})

Quizzes

Quizzes are polls with a marked correct answer and an optional explanation that shows after the user picks. Set IsQuiz: true, list the 0-based correct option indexes in CorrectAnswers, and supply a Solution for the post-answer card.

client.SendPoll(peerID, "Capital of Bolivia?", []string{
	"La Paz",
	"Sucre",
	"Santa Cruz",
}, &telegram.PollOptions{
	IsQuiz:         true,
	CorrectAnswers: []int{1}, // 0-based: "Sucre"
	Solution:       "Constitutionally Sucre; La Paz is the seat of government.",
})
client.SendPoll(peerID, "Capital of Bolivia?", []string{
	"La Paz",
	"Sucre",
	"Santa Cruz",
}, &telegram.PollOptions{
	IsQuiz:         true,
	CorrectAnswers: []int{1}, // 0-based: "Sucre"
	Solution:       "Constitutionally Sucre; La Paz is the seat of government.",
})

Quizzes are always single-choice and always non-anonymous โ€” the server enforces both.

Reactions

The signature is SendReaction(peer, msgID, reaction, big...):

_ = client.SendReaction(peerID, msgID, "๐Ÿ‘")
_ = client.SendReaction(peerID, msgID, "๐Ÿ”ฅ", true) // big animated
_ = client.SendReaction(peerID, msgID, []string{"โค๏ธ", "๐ŸŽ‰"})
_ = client.SendReaction(peerID, msgID, "๐Ÿ‘")
_ = client.SendReaction(peerID, msgID, "๐Ÿ”ฅ", true) // big animated
_ = client.SendReaction(peerID, msgID, []string{"โค๏ธ", "๐ŸŽ‰"})

The reactionargument is loose โ€” a single emoji string, a slice of emoji strings (premium accounts only), or a Reaction TL object for custom emoji reactions from a sticker pack.

From inside a handler, m.React is the one-liner:

client.On("message:*", func(m *telegram.NewMessage) error {
	return m.React("๐Ÿ‘")
})
client.On("message:*", func(m *telegram.NewMessage) error {
	return m.React("๐Ÿ‘")
})

Practical limits

  • Polls allow 2โ€“10 options. The server rejects more.
  • Quizzes allow exactly one correct answer.
  • Bots cannot vote in polls. User accounts can.
  • Reactions are limited to the set of allowed reactions for the chat โ€” chat admins configure this. Trying to react with a blocked emoji returns REACTION_INVALID.
  • Free accounts can attach one reaction per message. Premium accounts can stack up to three.