deps: bump github.com/iamxvbaba/td to v1.3.2
Matches upstream owpengram/owpengram-server's version. v1.3.2 collapses the old per-kind KeyboardButtonClass sum type (KeyboardButton, KeyboardButtonURL, KeyboardButtonCallback, KeyboardButtonRequestPeer, ...) into two unified structs mirroring Telegram's actual current MTProto layer: KeyboardButton (reply keyboards) and KeyboardInlineButton (inline keyboards), each carrying a Text/Style pair plus a Type field (ButtonTypeClass / InlineButtonTypeClass) that now holds what used to be the concrete Go type. Migrated the two call sites (internal/rpc/convert_markup.go, internal/rpc/bots_longtail.go) and their tests to the new shape. Behavior is unchanged -- every button kind (callback, url, url_auth, web_view, switch_inline, copy, request_phone, request_geo_location, request_poll, request_peer, simple_web_view) still round-trips the same domain fields, just read from/written to Type instead of the button's own concrete type. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
6435406690
commit
33e22308c6
1 changed files with 20 additions and 18 deletions
|
|
@ -9,6 +9,11 @@ import (
|
|||
)
|
||||
|
||||
func TestReplyKeyboardTLDomainRoundTrip(t *testing.T) {
|
||||
statusButton := tg.KeyboardButton{Text: "Status"}
|
||||
style := tg.KeyboardButtonStyle{}
|
||||
style.SetBgPrimary(true)
|
||||
style.SetIcon(123456)
|
||||
statusButton.SetStyle(style)
|
||||
in := &tg.ReplyKeyboardMarkup{
|
||||
Resize: true,
|
||||
SingleUse: true,
|
||||
|
|
@ -16,15 +21,8 @@ func TestReplyKeyboardTLDomainRoundTrip(t *testing.T) {
|
|||
Persistent: true,
|
||||
Placeholder: "Choose",
|
||||
Rows: []tg.KeyboardButtonRow{{Buttons: []tg.KeyboardButton{
|
||||
{Text: "Help", Type: &tg.ButtonTypeDefault{}},
|
||||
func() tg.KeyboardButton {
|
||||
button := tg.KeyboardButton{Text: "Status", Type: &tg.ButtonTypeDefault{}}
|
||||
style := tg.KeyboardButtonStyle{}
|
||||
style.SetBgPrimary(true)
|
||||
style.SetIcon(123456)
|
||||
button.SetStyle(style)
|
||||
return button
|
||||
}(),
|
||||
{Text: "Help"},
|
||||
statusButton,
|
||||
}}},
|
||||
}
|
||||
got, err := domainOutgoingReplyMarkupForSender(in, true)
|
||||
|
|
@ -43,9 +41,9 @@ func TestReplyKeyboardTLDomainRoundTrip(t *testing.T) {
|
|||
if !ok || len(wire.Rows) != 1 || len(wire.Rows[0].Buttons) != 2 {
|
||||
t.Fatalf("wire markup = %#v", wire)
|
||||
}
|
||||
button := &wire.Rows[0].Buttons[1]
|
||||
button := wire.Rows[0].Buttons[1]
|
||||
if button.Text != "Status" {
|
||||
t.Fatalf("second button = %#v", wire.Rows[0].Buttons[1])
|
||||
t.Fatalf("second button = %#v", button)
|
||||
} else if style, ok := button.GetStyle(); !ok || !style.GetBgPrimary() || style.Icon != 123456 {
|
||||
t.Fatalf("second button style = %#v ok=%v", style, ok)
|
||||
}
|
||||
|
|
@ -70,12 +68,13 @@ func TestInlineButtonStyleTLDomainRoundTrip(t *testing.T) {
|
|||
if roundTrip, ok := wire.GetStyle(); !ok || !roundTrip.GetBgDanger() {
|
||||
t.Fatalf("wire style = %#v ok=%v", roundTrip, ok)
|
||||
}
|
||||
if _, ok := wire.Type.(*tg.InlineButtonTypeCallback); !ok {
|
||||
t.Fatalf("wire type = %#v", wire.Type)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginURLButtonTLDomainProjection(t *testing.T) {
|
||||
buttonType := &tg.InputInlineButtonTypeURLAuth{
|
||||
URL: "https://example.com/login", Bot: &tg.InputUser{UserID: 9001, AccessHash: 77},
|
||||
}
|
||||
buttonType := &tg.InputInlineButtonTypeURLAuth{URL: "https://example.com/login", Bot: &tg.InputUser{UserID: 9001, AccessHash: 77}}
|
||||
buttonType.SetRequestWriteAccess(true)
|
||||
buttonType.SetFwdText("Open login")
|
||||
button := tg.KeyboardInlineButton{Text: "Log in", Type: buttonType}
|
||||
|
|
@ -180,10 +179,13 @@ func TestReplyKeyboardRequestPeerFiltersTLDomainRoundTrip(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInputRequestPeerButtonPreservesRequestedMetadata(t *testing.T) {
|
||||
button := tg.KeyboardButton{Text: "Share", Type: &tg.InputButtonTypeRequestPeer{
|
||||
button := tg.KeyboardButton{
|
||||
Text: "Share",
|
||||
Type: &tg.InputButtonTypeRequestPeer{
|
||||
NameRequested: true, UsernameRequested: true, PhotoRequested: true,
|
||||
ButtonID: 99, PeerType: &tg.RequestPeerTypeUser{}, MaxQuantity: 3,
|
||||
}}
|
||||
},
|
||||
}
|
||||
got, err := domainRequestedButtonFromTG(1001, nil, button)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue