// 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{} ) // AddRecentlyFoundChatRequest represents TL type `addRecentlyFoundChat#97e8198d`. type AddRecentlyFoundChatRequest struct { // Identifier of the chat to add ChatID int64 } // AddRecentlyFoundChatRequestTypeID is TL type id of AddRecentlyFoundChatRequest. const AddRecentlyFoundChatRequestTypeID = 0x97e8198d // Ensuring interfaces in compile-time for AddRecentlyFoundChatRequest. var ( _ bin.Encoder = &AddRecentlyFoundChatRequest{} _ bin.Decoder = &AddRecentlyFoundChatRequest{} _ bin.BareEncoder = &AddRecentlyFoundChatRequest{} _ bin.BareDecoder = &AddRecentlyFoundChatRequest{} ) func (a *AddRecentlyFoundChatRequest) Zero() bool { if a == nil { return true } if !(a.ChatID == 0) { return false } return true } // String implements fmt.Stringer. func (a *AddRecentlyFoundChatRequest) String() string { if a == nil { return "AddRecentlyFoundChatRequest(nil)" } type Alias AddRecentlyFoundChatRequest return fmt.Sprintf("AddRecentlyFoundChatRequest%+v", Alias(*a)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*AddRecentlyFoundChatRequest) TypeID() uint32 { return AddRecentlyFoundChatRequestTypeID } // TypeName returns name of type in TL schema. func (*AddRecentlyFoundChatRequest) TypeName() string { return "addRecentlyFoundChat" } // TypeInfo returns info about TL type. func (a *AddRecentlyFoundChatRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "addRecentlyFoundChat", ID: AddRecentlyFoundChatRequestTypeID, } if a == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ChatID", SchemaName: "chat_id", }, } return typ } // Encode implements bin.Encoder. func (a *AddRecentlyFoundChatRequest) Encode(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't encode addRecentlyFoundChat#97e8198d as nil") } b.PutID(AddRecentlyFoundChatRequestTypeID) return a.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (a *AddRecentlyFoundChatRequest) EncodeBare(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't encode addRecentlyFoundChat#97e8198d as nil") } b.PutInt53(a.ChatID) return nil } // Decode implements bin.Decoder. func (a *AddRecentlyFoundChatRequest) Decode(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't decode addRecentlyFoundChat#97e8198d to nil") } if err := b.ConsumeID(AddRecentlyFoundChatRequestTypeID); err != nil { return fmt.Errorf("unable to decode addRecentlyFoundChat#97e8198d: %w", err) } return a.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (a *AddRecentlyFoundChatRequest) DecodeBare(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't decode addRecentlyFoundChat#97e8198d to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode addRecentlyFoundChat#97e8198d: field chat_id: %w", err) } a.ChatID = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (a *AddRecentlyFoundChatRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if a == nil { return fmt.Errorf("can't encode addRecentlyFoundChat#97e8198d as nil") } b.ObjStart() b.PutID("addRecentlyFoundChat") b.Comma() b.FieldStart("chat_id") b.PutInt53(a.ChatID) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (a *AddRecentlyFoundChatRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if a == nil { return fmt.Errorf("can't decode addRecentlyFoundChat#97e8198d to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("addRecentlyFoundChat"); err != nil { return fmt.Errorf("unable to decode addRecentlyFoundChat#97e8198d: %w", err) } case "chat_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode addRecentlyFoundChat#97e8198d: field chat_id: %w", err) } a.ChatID = value default: return b.Skip() } return nil }) } // GetChatID returns value of ChatID field. func (a *AddRecentlyFoundChatRequest) GetChatID() (value int64) { if a == nil { return } return a.ChatID } // AddRecentlyFoundChat invokes method addRecentlyFoundChat#97e8198d returning error if any. func (c *Client) AddRecentlyFoundChat(ctx context.Context, chatid int64) error { var ok Ok request := &AddRecentlyFoundChatRequest{ ChatID: chatid, } if err := c.rpc.Invoke(ctx, request, &ok); err != nil { return err } return nil }