// 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{} ) // MessagesGetEmojiGroupsRequest represents TL type `messages.getEmojiGroups#7488ce5b`. // Represents a list of emoji categories¹. // // Links: // 1. https://core.telegram.org/api/emoji-categories // // See https://core.telegram.org/method/messages.getEmojiGroups for reference. type MessagesGetEmojiGroupsRequest struct { // Hash used for caching, for more info click here¹. // // Links: // 1) https://core.telegram.org/api/offsets#hash-generation Hash int } // MessagesGetEmojiGroupsRequestTypeID is TL type id of MessagesGetEmojiGroupsRequest. const MessagesGetEmojiGroupsRequestTypeID = 0x7488ce5b // Ensuring interfaces in compile-time for MessagesGetEmojiGroupsRequest. var ( _ bin.Encoder = &MessagesGetEmojiGroupsRequest{} _ bin.Decoder = &MessagesGetEmojiGroupsRequest{} _ bin.BareEncoder = &MessagesGetEmojiGroupsRequest{} _ bin.BareDecoder = &MessagesGetEmojiGroupsRequest{} ) func (g *MessagesGetEmojiGroupsRequest) Zero() bool { if g == nil { return true } if !(g.Hash == 0) { return false } return true } // String implements fmt.Stringer. func (g *MessagesGetEmojiGroupsRequest) String() string { if g == nil { return "MessagesGetEmojiGroupsRequest(nil)" } type Alias MessagesGetEmojiGroupsRequest return fmt.Sprintf("MessagesGetEmojiGroupsRequest%+v", Alias(*g)) } // FillFrom fills MessagesGetEmojiGroupsRequest from given interface. func (g *MessagesGetEmojiGroupsRequest) FillFrom(from interface { GetHash() (value int) }) { g.Hash = from.GetHash() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*MessagesGetEmojiGroupsRequest) TypeID() uint32 { return MessagesGetEmojiGroupsRequestTypeID } // TypeName returns name of type in TL schema. func (*MessagesGetEmojiGroupsRequest) TypeName() string { return "messages.getEmojiGroups" } // TypeInfo returns info about TL type. func (g *MessagesGetEmojiGroupsRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "messages.getEmojiGroups", ID: MessagesGetEmojiGroupsRequestTypeID, } if g == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Hash", SchemaName: "hash", }, } return typ } // Encode implements bin.Encoder. func (g *MessagesGetEmojiGroupsRequest) Encode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode messages.getEmojiGroups#7488ce5b as nil") } b.PutID(MessagesGetEmojiGroupsRequestTypeID) return g.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (g *MessagesGetEmojiGroupsRequest) EncodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode messages.getEmojiGroups#7488ce5b as nil") } b.PutInt(g.Hash) return nil } // Decode implements bin.Decoder. func (g *MessagesGetEmojiGroupsRequest) Decode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode messages.getEmojiGroups#7488ce5b to nil") } if err := b.ConsumeID(MessagesGetEmojiGroupsRequestTypeID); err != nil { return fmt.Errorf("unable to decode messages.getEmojiGroups#7488ce5b: %w", err) } return g.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (g *MessagesGetEmojiGroupsRequest) DecodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode messages.getEmojiGroups#7488ce5b to nil") } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode messages.getEmojiGroups#7488ce5b: field hash: %w", err) } g.Hash = value } return nil } // GetHash returns value of Hash field. func (g *MessagesGetEmojiGroupsRequest) GetHash() (value int) { if g == nil { return } return g.Hash } // MessagesGetEmojiGroups invokes method messages.getEmojiGroups#7488ce5b returning error if any. // Represents a list of emoji categories¹. // // Links: // 1. https://core.telegram.org/api/emoji-categories // // See https://core.telegram.org/method/messages.getEmojiGroups for reference. func (c *Client) MessagesGetEmojiGroups(ctx context.Context, hash int) (MessagesEmojiGroupsClass, error) { var result MessagesEmojiGroupsBox request := &MessagesGetEmojiGroupsRequest{ Hash: hash, } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } return result.EmojiGroups, nil }