diff --git a/telegram/message/poll.go b/telegram/message/poll.go index aaf8a08cbd..d82d88b74c 100644 --- a/telegram/message/poll.go +++ b/telegram/message/poll.go @@ -28,24 +28,24 @@ func RawPollAnswer(poll tg.PollAnswer) PollAnswerOption { } // PollAnswer creates new plain poll answer option. -func PollAnswer(text string) PollAnswerOption { +func PollAnswer(text string, entities ...tg.MessageEntityClass) PollAnswerOption { return func(p *pollAnswerBuilder) { i := len(p.input.Poll.Answers) p.input.Poll.Answers = append(p.input.Poll.Answers, tg.PollAnswer{ - Text: text, + Text: tg.TextWithEntities{Text: text, Entities: entities}, Option: []byte(strconv.Itoa(i)), }) } } // CorrectPollAnswer creates new correct poll answer option. -func CorrectPollAnswer(text string) PollAnswerOption { +func CorrectPollAnswer(text string, entities ...tg.MessageEntityClass) PollAnswerOption { return func(p *pollAnswerBuilder) { p.input.Poll.Quiz = true i := len(p.input.Poll.Answers) option := []byte(strconv.Itoa(i)) p.input.Poll.Answers = append(p.input.Poll.Answers, tg.PollAnswer{ - Text: text, + Text: tg.TextWithEntities{Text: text, Entities: entities}, Option: option, }) p.input.CorrectAnswers = append(p.input.CorrectAnswers, option) @@ -148,12 +148,19 @@ func (p *PollBuilder) apply(ctx context.Context, b *multiMediaBuilder) error { return Media(&p.input).apply(ctx, b) } +func (p *PollBuilder) QuestionEntities(entities []tg.MessageEntityClass) *PollBuilder { + p.input.Poll.Question.Entities = entities + return p +} + // Poll adds poll attachment. +// +// To set poll question entities, use [QuestionEntities](#PollBuilder.QuestionEntities). func Poll(question string, a, b PollAnswerOption, answers ...PollAnswerOption) *PollBuilder { return &PollBuilder{ input: tg.InputMediaPoll{ Poll: tg.Poll{ - Question: question, + Question: tg.TextWithEntities{Text: question}, }, }, answers: append([]PollAnswerOption{a, b}, answers...), diff --git a/telegram/message/poll_test.go b/telegram/message/poll_test.go index 6e8bbc1440..864f085c84 100644 --- a/telegram/message/poll_test.go +++ b/telegram/message/poll_test.go @@ -43,11 +43,15 @@ func TestPoll(t *testing.T) { CorrectPollAnswer("A?"), PollAnswer("Che?"), PollAnswer("Kuda?"), - ).PublicVoters(true). + ). + PublicVoters(true). StyledExplanation( styling.Plain("See"), styling.TextURL("https://youtu.be/PYzX7SDKhd0.", "https://youtu.be/PYzX7SDKhd0"), - ) + ). + QuestionEntities([]tg.MessageEntityClass{ + &tg.MessageEntityEmail{Offset: 0, Length: 128}, + }) _, err := sender.Self().Media(ctx, poll) require.NoError(t, err)