gotd: update to layer 224
This commit is contained in:
+58
@@ -422,3 +422,61 @@ func FormattedDate(relative bool, shortTime bool, longTime bool, shortDate bool,
|
||||
func (b *Builder) FormattedDate(s string, relative bool, shortTime bool, longTime bool, shortDate bool, longDate bool, dayOfWeek bool, date int) *Builder {
|
||||
return b.Format(s, FormattedDate(relative, shortTime, longTime, shortDate, longDate, dayOfWeek, date))
|
||||
}
|
||||
|
||||
// DiffInsert creates Formatter of DiffInsert message entity.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messageEntityDiffInsert.
|
||||
func DiffInsert() Formatter {
|
||||
return func(offset, length int) tg.MessageEntityClass {
|
||||
return &tg.MessageEntityDiffInsert{
|
||||
Offset: offset,
|
||||
Length: length,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DiffInsert adds and formats message as DiffInsert message entity.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messageEntityDiffInsert.
|
||||
func (b *Builder) DiffInsert(s string) *Builder {
|
||||
return b.Format(s, DiffInsert())
|
||||
}
|
||||
|
||||
// DiffReplace creates Formatter of DiffReplace message entity.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messageEntityDiffReplace.
|
||||
func DiffReplace(oldText string) Formatter {
|
||||
return func(offset, length int) tg.MessageEntityClass {
|
||||
return &tg.MessageEntityDiffReplace{
|
||||
Offset: offset,
|
||||
Length: length,
|
||||
OldText: oldText,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DiffReplace adds and formats message as DiffReplace message entity.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messageEntityDiffReplace.
|
||||
func (b *Builder) DiffReplace(s string, oldText string) *Builder {
|
||||
return b.Format(s, DiffReplace(oldText))
|
||||
}
|
||||
|
||||
// DiffDelete creates Formatter of DiffDelete message entity.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messageEntityDiffDelete.
|
||||
func DiffDelete() Formatter {
|
||||
return func(offset, length int) tg.MessageEntityClass {
|
||||
return &tg.MessageEntityDiffDelete{
|
||||
Offset: offset,
|
||||
Length: length,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DiffDelete adds and formats message as DiffDelete message entity.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messageEntityDiffDelete.
|
||||
func (b *Builder) DiffDelete(s string) *Builder {
|
||||
return b.Format(s, DiffDelete())
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type pollAnswerBuilder struct {
|
||||
type PollAnswerOption func(p *pollAnswerBuilder)
|
||||
|
||||
// RawPollAnswer creates new raw poll answer option.
|
||||
func RawPollAnswer(poll tg.PollAnswer) PollAnswerOption {
|
||||
func RawPollAnswer(poll *tg.PollAnswer) PollAnswerOption {
|
||||
return func(p *pollAnswerBuilder) {
|
||||
p.input.Poll.Answers = append(p.input.Poll.Answers, poll)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func RawPollAnswer(poll tg.PollAnswer) 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{
|
||||
p.input.Poll.Answers = append(p.input.Poll.Answers, &tg.PollAnswer{
|
||||
Text: tg.TextWithEntities{Text: text, Entities: entities},
|
||||
Option: []byte(strconv.Itoa(i)),
|
||||
})
|
||||
@@ -44,11 +44,11 @@ func CorrectPollAnswer(text string, entities ...tg.MessageEntityClass) PollAnswe
|
||||
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{
|
||||
p.input.Poll.Answers = append(p.input.Poll.Answers, &tg.PollAnswer{
|
||||
Text: tg.TextWithEntities{Text: text, Entities: entities},
|
||||
Option: option,
|
||||
})
|
||||
p.input.CorrectAnswers = append(p.input.CorrectAnswers, option)
|
||||
p.input.CorrectAnswers = append(p.input.CorrectAnswers, i)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestPoll(t *testing.T) {
|
||||
id = m.Poll.ID
|
||||
require.Len(t, m.Poll.Answers, 3)
|
||||
require.Len(t, m.CorrectAnswers, 1)
|
||||
require.Equal(t, m.Poll.Answers[0].Option, m.CorrectAnswers[0])
|
||||
require.Equal(t, 0, m.CorrectAnswers[0])
|
||||
}).ThenResult(&tg.Updates{})
|
||||
mock.ExpectFunc(func(b bin.Encoder) {
|
||||
req, ok := b.(*tg.MessagesSendMediaRequest)
|
||||
|
||||
+30
@@ -221,3 +221,33 @@ func FormattedDate(s string, relative bool, shortTime bool, longTime bool, short
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// DiffInsert formats text as DiffInsert entity.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messageEntityDiffInsert.
|
||||
func DiffInsert(s string) StyledTextOption {
|
||||
return styledTextOption(s, func(b *textBuilder) error {
|
||||
b.DiffInsert(s)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// DiffReplace formats text as DiffReplace entity.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messageEntityDiffReplace.
|
||||
func DiffReplace(s string, oldText string) StyledTextOption {
|
||||
return styledTextOption(s, func(b *textBuilder) error {
|
||||
b.DiffReplace(s, oldText)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// DiffDelete formats text as DiffDelete entity.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messageEntityDiffDelete.
|
||||
func DiffDelete(s string) StyledTextOption {
|
||||
return styledTextOption(s, func(b *textBuilder) error {
|
||||
b.DiffDelete(s)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user