// Code generated by gotdgen, DO NOT EDIT. package tdapi 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{} ) // GetMessageLinkRequest represents TL type `getMessageLink#c556ef7a`. type GetMessageLinkRequest struct { // Identifier of the chat to which the message belongs ChatID int64 // Identifier of the message MessageID int64 // If not 0, timestamp from which the video/audio/video note/voice note/story playing // must start, in seconds. The media can be in the message content or in its link preview MediaTimestamp int32 // Pass true to create a link for the whole media album ForAlbum bool // Pass true to create a link to the message as a channel post comment, in a message // thread, or a forum topic InMessageThread bool } // GetMessageLinkRequestTypeID is TL type id of GetMessageLinkRequest. const GetMessageLinkRequestTypeID = 0xc556ef7a // Ensuring interfaces in compile-time for GetMessageLinkRequest. var ( _ bin.Encoder = &GetMessageLinkRequest{} _ bin.Decoder = &GetMessageLinkRequest{} _ bin.BareEncoder = &GetMessageLinkRequest{} _ bin.BareDecoder = &GetMessageLinkRequest{} ) func (g *GetMessageLinkRequest) Zero() bool { if g == nil { return true } if !(g.ChatID == 0) { return false } if !(g.MessageID == 0) { return false } if !(g.MediaTimestamp == 0) { return false } if !(g.ForAlbum == false) { return false } if !(g.InMessageThread == false) { return false } return true } // String implements fmt.Stringer. func (g *GetMessageLinkRequest) String() string { if g == nil { return "GetMessageLinkRequest(nil)" } type Alias GetMessageLinkRequest return fmt.Sprintf("GetMessageLinkRequest%+v", Alias(*g)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*GetMessageLinkRequest) TypeID() uint32 { return GetMessageLinkRequestTypeID } // TypeName returns name of type in TL schema. func (*GetMessageLinkRequest) TypeName() string { return "getMessageLink" } // TypeInfo returns info about TL type. func (g *GetMessageLinkRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "getMessageLink", ID: GetMessageLinkRequestTypeID, } if g == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ChatID", SchemaName: "chat_id", }, { Name: "MessageID", SchemaName: "message_id", }, { Name: "MediaTimestamp", SchemaName: "media_timestamp", }, { Name: "ForAlbum", SchemaName: "for_album", }, { Name: "InMessageThread", SchemaName: "in_message_thread", }, } return typ } // Encode implements bin.Encoder. func (g *GetMessageLinkRequest) Encode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode getMessageLink#c556ef7a as nil") } b.PutID(GetMessageLinkRequestTypeID) return g.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (g *GetMessageLinkRequest) EncodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode getMessageLink#c556ef7a as nil") } b.PutInt53(g.ChatID) b.PutInt53(g.MessageID) b.PutInt32(g.MediaTimestamp) b.PutBool(g.ForAlbum) b.PutBool(g.InMessageThread) return nil } // Decode implements bin.Decoder. func (g *GetMessageLinkRequest) Decode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode getMessageLink#c556ef7a to nil") } if err := b.ConsumeID(GetMessageLinkRequestTypeID); err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: %w", err) } return g.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (g *GetMessageLinkRequest) DecodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode getMessageLink#c556ef7a to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field chat_id: %w", err) } g.ChatID = value } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field message_id: %w", err) } g.MessageID = value } { value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field media_timestamp: %w", err) } g.MediaTimestamp = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field for_album: %w", err) } g.ForAlbum = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field in_message_thread: %w", err) } g.InMessageThread = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (g *GetMessageLinkRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if g == nil { return fmt.Errorf("can't encode getMessageLink#c556ef7a as nil") } b.ObjStart() b.PutID("getMessageLink") b.Comma() b.FieldStart("chat_id") b.PutInt53(g.ChatID) b.Comma() b.FieldStart("message_id") b.PutInt53(g.MessageID) b.Comma() b.FieldStart("media_timestamp") b.PutInt32(g.MediaTimestamp) b.Comma() b.FieldStart("for_album") b.PutBool(g.ForAlbum) b.Comma() b.FieldStart("in_message_thread") b.PutBool(g.InMessageThread) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (g *GetMessageLinkRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if g == nil { return fmt.Errorf("can't decode getMessageLink#c556ef7a to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("getMessageLink"); err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: %w", err) } case "chat_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field chat_id: %w", err) } g.ChatID = value case "message_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field message_id: %w", err) } g.MessageID = value case "media_timestamp": value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field media_timestamp: %w", err) } g.MediaTimestamp = value case "for_album": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field for_album: %w", err) } g.ForAlbum = value case "in_message_thread": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode getMessageLink#c556ef7a: field in_message_thread: %w", err) } g.InMessageThread = value default: return b.Skip() } return nil }) } // GetChatID returns value of ChatID field. func (g *GetMessageLinkRequest) GetChatID() (value int64) { if g == nil { return } return g.ChatID } // GetMessageID returns value of MessageID field. func (g *GetMessageLinkRequest) GetMessageID() (value int64) { if g == nil { return } return g.MessageID } // GetMediaTimestamp returns value of MediaTimestamp field. func (g *GetMessageLinkRequest) GetMediaTimestamp() (value int32) { if g == nil { return } return g.MediaTimestamp } // GetForAlbum returns value of ForAlbum field. func (g *GetMessageLinkRequest) GetForAlbum() (value bool) { if g == nil { return } return g.ForAlbum } // GetInMessageThread returns value of InMessageThread field. func (g *GetMessageLinkRequest) GetInMessageThread() (value bool) { if g == nil { return } return g.InMessageThread } // GetMessageLink invokes method getMessageLink#c556ef7a returning error if any. func (c *Client) GetMessageLink(ctx context.Context, request *GetMessageLinkRequest) (*MessageLink, error) { var result MessageLink if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } return &result, nil }