(new): support Bot API 10.3
Golang lint / lint (push) Failing after 1m37s

(fix): finalize v2 contracts
(tests): cover v2 migration
(doc): prepare release guidance
This commit is contained in:
2026-09-08 23:21:38 +03:00
parent 24040fe164
commit d78526242b
88 changed files with 2321 additions and 918 deletions
+26 -1
View File
@@ -5,7 +5,7 @@ import (
"strconv"
"strings"
"git.scuroneko.dev/scuroneko/laniakea/tgapi"
"git.scuroneko.dev/scuroneko/laniakea/v2/tgapi"
)
type buildState struct {
@@ -61,6 +61,8 @@ func (s *buildState) addMedia(media tgapi.InputMedia) (string, error) {
}
var kind string
switch media.Type {
case tgapi.InputMediaTypeDocument:
kind = "document"
case tgapi.InputMediaTypePhoto:
kind = "photo"
case tgapi.InputMediaTypeAnimation, tgapi.InputMediaTypeVideo:
@@ -77,6 +79,8 @@ func (s *buildState) addMedia(media tgapi.InputMedia) (string, error) {
func renderText(t tgapi.RichText, step int) (string, error) {
switch el := t.(type) {
case tgapi.RichTextButton:
return renderButton(el.Button, step+1)
case tgapi.RichTextPlain:
return escapeHTML(string(el)), nil
case tgapi.RichTextArray:
@@ -203,6 +207,9 @@ func renderHTMLTable(t tgapi.InputRichBlockTable, step int, state *buildState) (
if t.IsBordered {
attrs["bordered"] = ""
}
if t.IsCompact {
attrs["compact"] = ""
}
if t.IsStriped {
attrs["striped"] = ""
}
@@ -470,6 +477,20 @@ func renderBlockHTMLState(block tgapi.InputRichBlock, step int, state *buildStat
credit = "<cite>" + credit + "</cite>"
}
return "<blockquote>" + strings.Join(content, "") + credit + "</blockquote>", nil
case tgapi.InputRichBlockExpandableBlockQuotation:
text, err := renderText(el.Text, step+1)
if err != nil {
return "", err
}
credit := ""
if el.Credit != nil {
credit, err = renderText(*el.Credit, step+1)
if err != nil {
return "", err
}
credit = "<cite>" + credit + "</cite>"
}
return "<blockquote expandable>" + text + credit + "</blockquote>", nil
case tgapi.InputRichBlockPullQuotation:
text, err := renderText(el.Text, step+1)
if err != nil {
@@ -532,6 +553,10 @@ func renderBlockHTMLState(block tgapi.InputRichBlock, step int, state *buildStat
return renderHTMLMap(el, step)
case tgapi.InputRichBlockAnimation:
return renderHTMLMedia(el.Animation, el.Caption, "video", step, state)
case tgapi.InputRichBlockDocument:
return renderHTMLMedia(el.Document, el.Caption, "tg-document", step, state)
case tgapi.InputRichBlockButtons:
return renderButtons(el, step)
case tgapi.InputRichBlockAudio:
return renderHTMLMedia(el.Audio, el.Caption, "audio", step, state)
case tgapi.InputRichBlockPhoto: