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
ecdb14aaca
commit
7fef8438c5
9 changed files with 166 additions and 174 deletions
|
|
@ -844,8 +844,8 @@ func TestInlineBotArticleTextChannelRoundTrip(t *testing.T) {
|
|||
}
|
||||
editReq := &tg.MessagesEditInlineBotMessageRequest{ID: msgID}
|
||||
editReq.SetMessage("inline group edited")
|
||||
editReq.SetReplyMarkup(&tg.ReplyInlineMarkup{Rows: []tg.KeyboardButtonRow{{
|
||||
Buttons: []tg.KeyboardButtonClass{&tg.KeyboardButtonCallback{Text: "Done", Data: []byte("v2")}},
|
||||
editReq.SetReplyMarkup(&tg.ReplyInlineMarkup{Rows: []tg.KeyboardInlineButtonRow{{
|
||||
Buttons: []tg.KeyboardInlineButton{{Text: "Done", Type: &tg.InlineButtonTypeCallback{Data: []byte("v2")}}},
|
||||
}}})
|
||||
if ok, err := f.router.onMessagesEditInlineBotMessage(botCtx, editReq); err != nil || !ok {
|
||||
t.Fatalf("channel inline edit = %v,%v, want true,nil", ok, err)
|
||||
|
|
@ -2065,12 +2065,13 @@ func assertTGInlineReplyMarkup(t *testing.T, msg *tg.Message, wantText string, w
|
|||
if len(markup.Rows) != 1 || len(markup.Rows[0].Buttons) != 1 {
|
||||
t.Fatalf("reply_markup rows = %+v, want one callback button", markup.Rows)
|
||||
}
|
||||
button, ok := markup.Rows[0].Buttons[0].(*tg.KeyboardButtonCallback)
|
||||
button := markup.Rows[0].Buttons[0]
|
||||
buttonType, ok := button.Type.(*tg.InlineButtonTypeCallback)
|
||||
if !ok {
|
||||
t.Fatalf("reply_markup button = %T, want callback", markup.Rows[0].Buttons[0])
|
||||
t.Fatalf("reply_markup button = %T, want callback", button.Type)
|
||||
}
|
||||
if button.Text != wantText || !bytes.Equal(button.Data, wantData) {
|
||||
t.Fatalf("reply_markup button = %q/%v, want %q/%v", button.Text, button.Data, wantText, wantData)
|
||||
if button.Text != wantText || !bytes.Equal(buttonType.Data, wantData) {
|
||||
t.Fatalf("reply_markup button = %q/%v, want %q/%v", button.Text, buttonType.Data, wantText, wantData)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2119,8 +2120,8 @@ func inlineArticleResult(id, message string) tg.InputBotInlineResultClass {
|
|||
func inlineArticleResultWithCallback(id, message, button string, data []byte) tg.InputBotInlineResultClass {
|
||||
result := inlineArticleResult(id, message).(*tg.InputBotInlineResult)
|
||||
msg := result.SendMessage.(*tg.InputBotInlineMessageText)
|
||||
msg.SetReplyMarkup(&tg.ReplyInlineMarkup{Rows: []tg.KeyboardButtonRow{{
|
||||
Buttons: []tg.KeyboardButtonClass{&tg.KeyboardButtonCallback{Text: button, Data: data}},
|
||||
msg.SetReplyMarkup(&tg.ReplyInlineMarkup{Rows: []tg.KeyboardInlineButtonRow{{
|
||||
Buttons: []tg.KeyboardInlineButton{{Text: button, Type: &tg.InlineButtonTypeCallback{Data: data}}},
|
||||
}}})
|
||||
return result
|
||||
}
|
||||
|
|
@ -2308,8 +2309,8 @@ func inlineContactResult(id, phone, first, last, vcard string) *tg.InputBotInlin
|
|||
func inlineContactResultWithCallback(id, phone, first, last string, data []byte) tg.InputBotInlineResultClass {
|
||||
result := inlineContactResult(id, phone, first, last, "BEGIN:VCARD\nFN:"+first+" "+last+"\nEND:VCARD")
|
||||
msg := result.SendMessage.(*tg.InputBotInlineMessageMediaContact)
|
||||
msg.SetReplyMarkup(&tg.ReplyInlineMarkup{Rows: []tg.KeyboardButtonRow{{
|
||||
Buttons: []tg.KeyboardButtonClass{&tg.KeyboardButtonCallback{Text: "Contact", Data: data}},
|
||||
msg.SetReplyMarkup(&tg.ReplyInlineMarkup{Rows: []tg.KeyboardInlineButtonRow{{
|
||||
Buttons: []tg.KeyboardInlineButton{{Text: "Contact", Type: &tg.InlineButtonTypeCallback{Data: data}}},
|
||||
}}})
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue