gotd/message: fix generators and update entity utilities

This commit is contained in:
Tulir Asokan
2026-03-03 15:16:44 +02:00
parent e5914196c5
commit 67adededff
5 changed files with 40 additions and 4 deletions
+26
View File
@@ -396,3 +396,29 @@ func Blockquote(collapsed bool) Formatter {
func (b *Builder) Blockquote(s string, collapsed bool) *Builder {
return b.Format(s, Blockquote(collapsed))
}
// FormattedDate creates Formatter of FormattedDate message entity.
//
// See https://core.telegram.org/constructor/messageEntityFormattedDate.
func FormattedDate(relative bool, shortTime bool, longTime bool, shortDate bool, longDate bool, dayOfWeek bool, date int) Formatter {
return func(offset, length int) tg.MessageEntityClass {
return &tg.MessageEntityFormattedDate{
Offset: offset,
Length: length,
Relative: relative,
ShortTime: shortTime,
LongTime: longTime,
ShortDate: shortDate,
LongDate: longDate,
DayOfWeek: dayOfWeek,
Date: date,
}
}
}
// FormattedDate adds and formats message as FormattedDate message entity.
//
// See https://core.telegram.org/constructor/messageEntityFormattedDate.
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))
}