Files
mautrix-telegram/pkg/gotd/tg/tl_messages_request_url_auth_gen.go
T
2026-03-03 15:13:10 +02:00

426 lines
10 KiB
Go
Generated

// Code generated by gotdgen, DO NOT EDIT.
package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)
// No-op definition for keeping imports.
var (
_ = bin.Buffer{}
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = multierr.AppendInto
_ = sort.Ints
_ = tdp.Format
_ = tgerr.Error{}
_ = tdjson.Encoder{}
)
// MessagesRequestURLAuthRequest represents TL type `messages.requestUrlAuth#894cc99c`.
// Get more info about a Seamless Telegram Login authorization request, for more info
// click here »¹
//
// Links:
// 1. https://core.telegram.org/api/url-authorization
//
// See https://core.telegram.org/method/messages.requestUrlAuth for reference.
type MessagesRequestURLAuthRequest struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Peer where the message is located
//
// Use SetPeer and GetPeer helpers.
Peer InputPeerClass
// The message
//
// Use SetMsgID and GetMsgID helpers.
MsgID int
// The ID of the button with the authorization request
//
// Use SetButtonID and GetButtonID helpers.
ButtonID int
// URL used for link URL authorization, click here for more info »¹
//
// Links:
// 1) https://core.telegram.org/api/url-authorization#link-url-authorization
//
// Use SetURL and GetURL helpers.
URL string
// InAppOrigin field of MessagesRequestURLAuthRequest.
//
// Use SetInAppOrigin and GetInAppOrigin helpers.
InAppOrigin string
}
// MessagesRequestURLAuthRequestTypeID is TL type id of MessagesRequestURLAuthRequest.
const MessagesRequestURLAuthRequestTypeID = 0x894cc99c
// Ensuring interfaces in compile-time for MessagesRequestURLAuthRequest.
var (
_ bin.Encoder = &MessagesRequestURLAuthRequest{}
_ bin.Decoder = &MessagesRequestURLAuthRequest{}
_ bin.BareEncoder = &MessagesRequestURLAuthRequest{}
_ bin.BareDecoder = &MessagesRequestURLAuthRequest{}
)
func (r *MessagesRequestURLAuthRequest) Zero() bool {
if r == nil {
return true
}
if !(r.Flags.Zero()) {
return false
}
if !(r.Peer == nil) {
return false
}
if !(r.MsgID == 0) {
return false
}
if !(r.ButtonID == 0) {
return false
}
if !(r.URL == "") {
return false
}
if !(r.InAppOrigin == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (r *MessagesRequestURLAuthRequest) String() string {
if r == nil {
return "MessagesRequestURLAuthRequest(nil)"
}
type Alias MessagesRequestURLAuthRequest
return fmt.Sprintf("MessagesRequestURLAuthRequest%+v", Alias(*r))
}
// FillFrom fills MessagesRequestURLAuthRequest from given interface.
func (r *MessagesRequestURLAuthRequest) FillFrom(from interface {
GetPeer() (value InputPeerClass, ok bool)
GetMsgID() (value int, ok bool)
GetButtonID() (value int, ok bool)
GetURL() (value string, ok bool)
GetInAppOrigin() (value string, ok bool)
}) {
if val, ok := from.GetPeer(); ok {
r.Peer = val
}
if val, ok := from.GetMsgID(); ok {
r.MsgID = val
}
if val, ok := from.GetButtonID(); ok {
r.ButtonID = val
}
if val, ok := from.GetURL(); ok {
r.URL = val
}
if val, ok := from.GetInAppOrigin(); ok {
r.InAppOrigin = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessagesRequestURLAuthRequest) TypeID() uint32 {
return MessagesRequestURLAuthRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*MessagesRequestURLAuthRequest) TypeName() string {
return "messages.requestUrlAuth"
}
// TypeInfo returns info about TL type.
func (r *MessagesRequestURLAuthRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "messages.requestUrlAuth",
ID: MessagesRequestURLAuthRequestTypeID,
}
if r == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Peer",
SchemaName: "peer",
Null: !r.Flags.Has(1),
},
{
Name: "MsgID",
SchemaName: "msg_id",
Null: !r.Flags.Has(1),
},
{
Name: "ButtonID",
SchemaName: "button_id",
Null: !r.Flags.Has(1),
},
{
Name: "URL",
SchemaName: "url",
Null: !r.Flags.Has(2),
},
{
Name: "InAppOrigin",
SchemaName: "in_app_origin",
Null: !r.Flags.Has(3),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (r *MessagesRequestURLAuthRequest) SetFlags() {
if !(r.Peer == nil) {
r.Flags.Set(1)
}
if !(r.MsgID == 0) {
r.Flags.Set(1)
}
if !(r.ButtonID == 0) {
r.Flags.Set(1)
}
if !(r.URL == "") {
r.Flags.Set(2)
}
if !(r.InAppOrigin == "") {
r.Flags.Set(3)
}
}
// Encode implements bin.Encoder.
func (r *MessagesRequestURLAuthRequest) Encode(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't encode messages.requestUrlAuth#894cc99c as nil")
}
b.PutID(MessagesRequestURLAuthRequestTypeID)
return r.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (r *MessagesRequestURLAuthRequest) EncodeBare(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't encode messages.requestUrlAuth#894cc99c as nil")
}
r.SetFlags()
if err := r.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode messages.requestUrlAuth#894cc99c: field flags: %w", err)
}
if r.Flags.Has(1) {
if r.Peer == nil {
return fmt.Errorf("unable to encode messages.requestUrlAuth#894cc99c: field peer is nil")
}
if err := r.Peer.Encode(b); err != nil {
return fmt.Errorf("unable to encode messages.requestUrlAuth#894cc99c: field peer: %w", err)
}
}
if r.Flags.Has(1) {
b.PutInt(r.MsgID)
}
if r.Flags.Has(1) {
b.PutInt(r.ButtonID)
}
if r.Flags.Has(2) {
b.PutString(r.URL)
}
if r.Flags.Has(3) {
b.PutString(r.InAppOrigin)
}
return nil
}
// Decode implements bin.Decoder.
func (r *MessagesRequestURLAuthRequest) Decode(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't decode messages.requestUrlAuth#894cc99c to nil")
}
if err := b.ConsumeID(MessagesRequestURLAuthRequestTypeID); err != nil {
return fmt.Errorf("unable to decode messages.requestUrlAuth#894cc99c: %w", err)
}
return r.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (r *MessagesRequestURLAuthRequest) DecodeBare(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't decode messages.requestUrlAuth#894cc99c to nil")
}
{
if err := r.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode messages.requestUrlAuth#894cc99c: field flags: %w", err)
}
}
if r.Flags.Has(1) {
value, err := DecodeInputPeer(b)
if err != nil {
return fmt.Errorf("unable to decode messages.requestUrlAuth#894cc99c: field peer: %w", err)
}
r.Peer = value
}
if r.Flags.Has(1) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode messages.requestUrlAuth#894cc99c: field msg_id: %w", err)
}
r.MsgID = value
}
if r.Flags.Has(1) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode messages.requestUrlAuth#894cc99c: field button_id: %w", err)
}
r.ButtonID = value
}
if r.Flags.Has(2) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode messages.requestUrlAuth#894cc99c: field url: %w", err)
}
r.URL = value
}
if r.Flags.Has(3) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode messages.requestUrlAuth#894cc99c: field in_app_origin: %w", err)
}
r.InAppOrigin = value
}
return nil
}
// SetPeer sets value of Peer conditional field.
func (r *MessagesRequestURLAuthRequest) SetPeer(value InputPeerClass) {
r.Flags.Set(1)
r.Peer = value
}
// GetPeer returns value of Peer conditional field and
// boolean which is true if field was set.
func (r *MessagesRequestURLAuthRequest) GetPeer() (value InputPeerClass, ok bool) {
if r == nil {
return
}
if !r.Flags.Has(1) {
return value, false
}
return r.Peer, true
}
// SetMsgID sets value of MsgID conditional field.
func (r *MessagesRequestURLAuthRequest) SetMsgID(value int) {
r.Flags.Set(1)
r.MsgID = value
}
// GetMsgID returns value of MsgID conditional field and
// boolean which is true if field was set.
func (r *MessagesRequestURLAuthRequest) GetMsgID() (value int, ok bool) {
if r == nil {
return
}
if !r.Flags.Has(1) {
return value, false
}
return r.MsgID, true
}
// SetButtonID sets value of ButtonID conditional field.
func (r *MessagesRequestURLAuthRequest) SetButtonID(value int) {
r.Flags.Set(1)
r.ButtonID = value
}
// GetButtonID returns value of ButtonID conditional field and
// boolean which is true if field was set.
func (r *MessagesRequestURLAuthRequest) GetButtonID() (value int, ok bool) {
if r == nil {
return
}
if !r.Flags.Has(1) {
return value, false
}
return r.ButtonID, true
}
// SetURL sets value of URL conditional field.
func (r *MessagesRequestURLAuthRequest) SetURL(value string) {
r.Flags.Set(2)
r.URL = value
}
// GetURL returns value of URL conditional field and
// boolean which is true if field was set.
func (r *MessagesRequestURLAuthRequest) GetURL() (value string, ok bool) {
if r == nil {
return
}
if !r.Flags.Has(2) {
return value, false
}
return r.URL, true
}
// SetInAppOrigin sets value of InAppOrigin conditional field.
func (r *MessagesRequestURLAuthRequest) SetInAppOrigin(value string) {
r.Flags.Set(3)
r.InAppOrigin = value
}
// GetInAppOrigin returns value of InAppOrigin conditional field and
// boolean which is true if field was set.
func (r *MessagesRequestURLAuthRequest) GetInAppOrigin() (value string, ok bool) {
if r == nil {
return
}
if !r.Flags.Has(3) {
return value, false
}
return r.InAppOrigin, true
}
// MessagesRequestURLAuth invokes method messages.requestUrlAuth#894cc99c returning error if any.
// Get more info about a Seamless Telegram Login authorization request, for more info
// click here »¹
//
// Links:
// 1. https://core.telegram.org/api/url-authorization
//
// See https://core.telegram.org/method/messages.requestUrlAuth for reference.
func (c *Client) MessagesRequestURLAuth(ctx context.Context, request *MessagesRequestURLAuthRequest) (URLAuthResultClass, error) {
var result URLAuthResultBox
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return result.UrlAuthResult, nil
}