diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 9fa76fed9..cf62a015d 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -2,7 +2,7 @@ // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl // Layer: 179 -// SHA256: 68c4230a10c3ec143824dc09bd82601bd78975d208c4743e7ce54c58bc73cab4 +// SHA256: 9eb6aa1c5c25c900796809ce40385160142eaebc0ab5b68af4b8a4567fec6f05 boolFalse#bc799737 = Bool; @@ -2288,6 +2288,10 @@ emojiList#7a1e11d1 hash:long document_id:Vector = EmojiList; emojiGroup#7a9abda9 title:string icon_emoji_id:long emoticons:Vector = EmojiGroup; +emojiGroupGreeting#80d26cc7 title:string icon_emoji_id:long emoticons:Vector = EmojiGroup; + +emojiGroupPremium#93bcf34 title:string icon_emoji_id:long = EmojiGroup; + messages.emojiGroupsNotModified#6fb4ad87 = messages.EmojiGroups; messages.emojiGroups#881fb94b hash:int groups:Vector = messages.EmojiGroups; @@ -2568,7 +2572,7 @@ channels.sponsoredMessageReportResultAdsHidden#3e3bcf2f = channels.SponsoredMess channels.sponsoredMessageReportResultReported#ad798849 = channels.SponsoredMessageReportResult; -stats.broadcastRevenueStats#d07b4bad top_hours_graph:StatsGraph revenue_graph:StatsGraph current_balance:long available_balance:long overall_revenue:long usd_rate:double = stats.BroadcastRevenueStats; +stats.broadcastRevenueStats#5407e297 top_hours_graph:StatsGraph revenue_graph:StatsGraph balances:BroadcastRevenueBalances usd_rate:double = stats.BroadcastRevenueStats; stats.broadcastRevenueWithdrawalUrl#ec659737 url:string = stats.BroadcastRevenueWithdrawalUrl; @@ -2586,6 +2590,8 @@ reactionNotificationsFromAll#4b9e22a0 = ReactionNotificationsFrom; reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNotificationsFrom stories_notify_from:flags.1?ReactionNotificationsFrom sound:NotificationSound show_previews:Bool = ReactionsNotifySettings; +broadcastRevenueBalances#8438f1c6 current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; + ---functions--- @@ -3351,6 +3357,8 @@ messages.toggleDialogFilterTags#fd2dda49 enabled:Bool = Bool; messages.getMyStickers#d0b5e1fc offset_id:long limit:int = messages.MyStickers; +messages.getEmojiStickerGroups#1dd840f5 hash:int = messages.EmojiGroups; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 43281a7ba..306981366 100644 --- a/_schema/telegram.tl +++ b/_schema/telegram.tl @@ -3,7 +3,7 @@ // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl // Merge: _schema/legacy.tl // Layer: 179 -// SHA256: 68c4230a10c3ec143824dc09bd82601bd78975d208c4743e7ce54c58bc73cab4 +// SHA256: 9eb6aa1c5c25c900796809ce40385160142eaebc0ab5b68af4b8a4567fec6f05 boolFalse#bc799737 = Bool; @@ -2289,6 +2289,10 @@ emojiList#7a1e11d1 hash:long document_id:Vector = EmojiList; emojiGroup#7a9abda9 title:string icon_emoji_id:long emoticons:Vector = EmojiGroup; +emojiGroupGreeting#80d26cc7 title:string icon_emoji_id:long emoticons:Vector = EmojiGroup; + +emojiGroupPremium#93bcf34 title:string icon_emoji_id:long = EmojiGroup; + messages.emojiGroupsNotModified#6fb4ad87 = messages.EmojiGroups; messages.emojiGroups#881fb94b hash:int groups:Vector = messages.EmojiGroups; @@ -2569,7 +2573,7 @@ channels.sponsoredMessageReportResultAdsHidden#3e3bcf2f = channels.SponsoredMess channels.sponsoredMessageReportResultReported#ad798849 = channels.SponsoredMessageReportResult; -stats.broadcastRevenueStats#d07b4bad top_hours_graph:StatsGraph revenue_graph:StatsGraph current_balance:long available_balance:long overall_revenue:long usd_rate:double = stats.BroadcastRevenueStats; +stats.broadcastRevenueStats#5407e297 top_hours_graph:StatsGraph revenue_graph:StatsGraph balances:BroadcastRevenueBalances usd_rate:double = stats.BroadcastRevenueStats; stats.broadcastRevenueWithdrawalUrl#ec659737 url:string = stats.BroadcastRevenueWithdrawalUrl; @@ -2587,6 +2591,8 @@ reactionNotificationsFromAll#4b9e22a0 = ReactionNotificationsFrom; reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNotificationsFrom stories_notify_from:flags.1?ReactionNotificationsFrom sound:NotificationSound show_previews:Bool = ReactionsNotifySettings; +broadcastRevenueBalances#8438f1c6 current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; + ---functions--- @@ -3352,6 +3358,8 @@ messages.toggleDialogFilterTags#fd2dda49 enabled:Bool = Bool; messages.getMyStickers#d0b5e1fc offset_id:long limit:int = messages.MyStickers; +messages.getEmojiStickerGroups#1dd840f5 hash:int = messages.EmojiGroups; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; diff --git a/tg/tl_broadcast_revenue_balances_gen.go b/tg/tl_broadcast_revenue_balances_gen.go new file mode 100644 index 000000000..4ee8c6b86 --- /dev/null +++ b/tg/tl_broadcast_revenue_balances_gen.go @@ -0,0 +1,215 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/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{} +) + +// BroadcastRevenueBalances represents TL type `broadcastRevenueBalances#8438f1c6`. +// +// See https://core.telegram.org/constructor/broadcastRevenueBalances for reference. +type BroadcastRevenueBalances struct { + // CurrentBalance field of BroadcastRevenueBalances. + CurrentBalance int64 + // AvailableBalance field of BroadcastRevenueBalances. + AvailableBalance int64 + // OverallRevenue field of BroadcastRevenueBalances. + OverallRevenue int64 +} + +// BroadcastRevenueBalancesTypeID is TL type id of BroadcastRevenueBalances. +const BroadcastRevenueBalancesTypeID = 0x8438f1c6 + +// Ensuring interfaces in compile-time for BroadcastRevenueBalances. +var ( + _ bin.Encoder = &BroadcastRevenueBalances{} + _ bin.Decoder = &BroadcastRevenueBalances{} + _ bin.BareEncoder = &BroadcastRevenueBalances{} + _ bin.BareDecoder = &BroadcastRevenueBalances{} +) + +func (b *BroadcastRevenueBalances) Zero() bool { + if b == nil { + return true + } + if !(b.CurrentBalance == 0) { + return false + } + if !(b.AvailableBalance == 0) { + return false + } + if !(b.OverallRevenue == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *BroadcastRevenueBalances) String() string { + if b == nil { + return "BroadcastRevenueBalances(nil)" + } + type Alias BroadcastRevenueBalances + return fmt.Sprintf("BroadcastRevenueBalances%+v", Alias(*b)) +} + +// FillFrom fills BroadcastRevenueBalances from given interface. +func (b *BroadcastRevenueBalances) FillFrom(from interface { + GetCurrentBalance() (value int64) + GetAvailableBalance() (value int64) + GetOverallRevenue() (value int64) +}) { + b.CurrentBalance = from.GetCurrentBalance() + b.AvailableBalance = from.GetAvailableBalance() + b.OverallRevenue = from.GetOverallRevenue() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BroadcastRevenueBalances) TypeID() uint32 { + return BroadcastRevenueBalancesTypeID +} + +// TypeName returns name of type in TL schema. +func (*BroadcastRevenueBalances) TypeName() string { + return "broadcastRevenueBalances" +} + +// TypeInfo returns info about TL type. +func (b *BroadcastRevenueBalances) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "broadcastRevenueBalances", + ID: BroadcastRevenueBalancesTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "CurrentBalance", + SchemaName: "current_balance", + }, + { + Name: "AvailableBalance", + SchemaName: "available_balance", + }, + { + Name: "OverallRevenue", + SchemaName: "overall_revenue", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (b *BroadcastRevenueBalances) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode broadcastRevenueBalances#8438f1c6 as nil") + } + buf.PutID(BroadcastRevenueBalancesTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *BroadcastRevenueBalances) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode broadcastRevenueBalances#8438f1c6 as nil") + } + buf.PutLong(b.CurrentBalance) + buf.PutLong(b.AvailableBalance) + buf.PutLong(b.OverallRevenue) + return nil +} + +// Decode implements bin.Decoder. +func (b *BroadcastRevenueBalances) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode broadcastRevenueBalances#8438f1c6 to nil") + } + if err := buf.ConsumeID(BroadcastRevenueBalancesTypeID); err != nil { + return fmt.Errorf("unable to decode broadcastRevenueBalances#8438f1c6: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *BroadcastRevenueBalances) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode broadcastRevenueBalances#8438f1c6 to nil") + } + { + value, err := buf.Long() + if err != nil { + return fmt.Errorf("unable to decode broadcastRevenueBalances#8438f1c6: field current_balance: %w", err) + } + b.CurrentBalance = value + } + { + value, err := buf.Long() + if err != nil { + return fmt.Errorf("unable to decode broadcastRevenueBalances#8438f1c6: field available_balance: %w", err) + } + b.AvailableBalance = value + } + { + value, err := buf.Long() + if err != nil { + return fmt.Errorf("unable to decode broadcastRevenueBalances#8438f1c6: field overall_revenue: %w", err) + } + b.OverallRevenue = value + } + return nil +} + +// GetCurrentBalance returns value of CurrentBalance field. +func (b *BroadcastRevenueBalances) GetCurrentBalance() (value int64) { + if b == nil { + return + } + return b.CurrentBalance +} + +// GetAvailableBalance returns value of AvailableBalance field. +func (b *BroadcastRevenueBalances) GetAvailableBalance() (value int64) { + if b == nil { + return + } + return b.AvailableBalance +} + +// GetOverallRevenue returns value of OverallRevenue field. +func (b *BroadcastRevenueBalances) GetOverallRevenue() (value int64) { + if b == nil { + return + } + return b.OverallRevenue +} diff --git a/tg/tl_broadcast_revenue_balances_slices_gen.go b/tg/tl_broadcast_revenue_balances_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_broadcast_revenue_balances_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/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{} +) diff --git a/tg/tl_emoji_group_gen.go b/tg/tl_emoji_group_gen.go index b25e3f0f6..a47ac8b27 100644 --- a/tg/tl_emoji_group_gen.go +++ b/tg/tl_emoji_group_gen.go @@ -50,12 +50,17 @@ type EmojiGroup struct { // EmojiGroupTypeID is TL type id of EmojiGroup. const EmojiGroupTypeID = 0x7a9abda9 +// construct implements constructor of EmojiGroupClass. +func (e EmojiGroup) construct() EmojiGroupClass { return &e } + // Ensuring interfaces in compile-time for EmojiGroup. var ( _ bin.Encoder = &EmojiGroup{} _ bin.Decoder = &EmojiGroup{} _ bin.BareEncoder = &EmojiGroup{} _ bin.BareDecoder = &EmojiGroup{} + + _ EmojiGroupClass = &EmojiGroup{} ) func (e *EmojiGroup) Zero() bool { @@ -230,3 +235,468 @@ func (e *EmojiGroup) GetEmoticons() (value []string) { } return e.Emoticons } + +// EmojiGroupGreeting represents TL type `emojiGroupGreeting#80d26cc7`. +// +// See https://core.telegram.org/constructor/emojiGroupGreeting for reference. +type EmojiGroupGreeting struct { + // Title field of EmojiGroupGreeting. + Title string + // IconEmojiID field of EmojiGroupGreeting. + IconEmojiID int64 + // Emoticons field of EmojiGroupGreeting. + Emoticons []string +} + +// EmojiGroupGreetingTypeID is TL type id of EmojiGroupGreeting. +const EmojiGroupGreetingTypeID = 0x80d26cc7 + +// construct implements constructor of EmojiGroupClass. +func (e EmojiGroupGreeting) construct() EmojiGroupClass { return &e } + +// Ensuring interfaces in compile-time for EmojiGroupGreeting. +var ( + _ bin.Encoder = &EmojiGroupGreeting{} + _ bin.Decoder = &EmojiGroupGreeting{} + _ bin.BareEncoder = &EmojiGroupGreeting{} + _ bin.BareDecoder = &EmojiGroupGreeting{} + + _ EmojiGroupClass = &EmojiGroupGreeting{} +) + +func (e *EmojiGroupGreeting) Zero() bool { + if e == nil { + return true + } + if !(e.Title == "") { + return false + } + if !(e.IconEmojiID == 0) { + return false + } + if !(e.Emoticons == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmojiGroupGreeting) String() string { + if e == nil { + return "EmojiGroupGreeting(nil)" + } + type Alias EmojiGroupGreeting + return fmt.Sprintf("EmojiGroupGreeting%+v", Alias(*e)) +} + +// FillFrom fills EmojiGroupGreeting from given interface. +func (e *EmojiGroupGreeting) FillFrom(from interface { + GetTitle() (value string) + GetIconEmojiID() (value int64) + GetEmoticons() (value []string) +}) { + e.Title = from.GetTitle() + e.IconEmojiID = from.GetIconEmojiID() + e.Emoticons = from.GetEmoticons() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmojiGroupGreeting) TypeID() uint32 { + return EmojiGroupGreetingTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmojiGroupGreeting) TypeName() string { + return "emojiGroupGreeting" +} + +// TypeInfo returns info about TL type. +func (e *EmojiGroupGreeting) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emojiGroupGreeting", + ID: EmojiGroupGreetingTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "IconEmojiID", + SchemaName: "icon_emoji_id", + }, + { + Name: "Emoticons", + SchemaName: "emoticons", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *EmojiGroupGreeting) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiGroupGreeting#80d26cc7 as nil") + } + b.PutID(EmojiGroupGreetingTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmojiGroupGreeting) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiGroupGreeting#80d26cc7 as nil") + } + b.PutString(e.Title) + b.PutLong(e.IconEmojiID) + b.PutVectorHeader(len(e.Emoticons)) + for _, v := range e.Emoticons { + b.PutString(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (e *EmojiGroupGreeting) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiGroupGreeting#80d26cc7 to nil") + } + if err := b.ConsumeID(EmojiGroupGreetingTypeID); err != nil { + return fmt.Errorf("unable to decode emojiGroupGreeting#80d26cc7: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmojiGroupGreeting) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiGroupGreeting#80d26cc7 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode emojiGroupGreeting#80d26cc7: field title: %w", err) + } + e.Title = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode emojiGroupGreeting#80d26cc7: field icon_emoji_id: %w", err) + } + e.IconEmojiID = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode emojiGroupGreeting#80d26cc7: field emoticons: %w", err) + } + + if headerLen > 0 { + e.Emoticons = make([]string, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode emojiGroupGreeting#80d26cc7: field emoticons: %w", err) + } + e.Emoticons = append(e.Emoticons, value) + } + } + return nil +} + +// GetTitle returns value of Title field. +func (e *EmojiGroupGreeting) GetTitle() (value string) { + if e == nil { + return + } + return e.Title +} + +// GetIconEmojiID returns value of IconEmojiID field. +func (e *EmojiGroupGreeting) GetIconEmojiID() (value int64) { + if e == nil { + return + } + return e.IconEmojiID +} + +// GetEmoticons returns value of Emoticons field. +func (e *EmojiGroupGreeting) GetEmoticons() (value []string) { + if e == nil { + return + } + return e.Emoticons +} + +// EmojiGroupPremium represents TL type `emojiGroupPremium#93bcf34`. +// +// See https://core.telegram.org/constructor/emojiGroupPremium for reference. +type EmojiGroupPremium struct { + // Title field of EmojiGroupPremium. + Title string + // IconEmojiID field of EmojiGroupPremium. + IconEmojiID int64 +} + +// EmojiGroupPremiumTypeID is TL type id of EmojiGroupPremium. +const EmojiGroupPremiumTypeID = 0x93bcf34 + +// construct implements constructor of EmojiGroupClass. +func (e EmojiGroupPremium) construct() EmojiGroupClass { return &e } + +// Ensuring interfaces in compile-time for EmojiGroupPremium. +var ( + _ bin.Encoder = &EmojiGroupPremium{} + _ bin.Decoder = &EmojiGroupPremium{} + _ bin.BareEncoder = &EmojiGroupPremium{} + _ bin.BareDecoder = &EmojiGroupPremium{} + + _ EmojiGroupClass = &EmojiGroupPremium{} +) + +func (e *EmojiGroupPremium) Zero() bool { + if e == nil { + return true + } + if !(e.Title == "") { + return false + } + if !(e.IconEmojiID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmojiGroupPremium) String() string { + if e == nil { + return "EmojiGroupPremium(nil)" + } + type Alias EmojiGroupPremium + return fmt.Sprintf("EmojiGroupPremium%+v", Alias(*e)) +} + +// FillFrom fills EmojiGroupPremium from given interface. +func (e *EmojiGroupPremium) FillFrom(from interface { + GetTitle() (value string) + GetIconEmojiID() (value int64) +}) { + e.Title = from.GetTitle() + e.IconEmojiID = from.GetIconEmojiID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmojiGroupPremium) TypeID() uint32 { + return EmojiGroupPremiumTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmojiGroupPremium) TypeName() string { + return "emojiGroupPremium" +} + +// TypeInfo returns info about TL type. +func (e *EmojiGroupPremium) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emojiGroupPremium", + ID: EmojiGroupPremiumTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "IconEmojiID", + SchemaName: "icon_emoji_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *EmojiGroupPremium) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiGroupPremium#93bcf34 as nil") + } + b.PutID(EmojiGroupPremiumTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmojiGroupPremium) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiGroupPremium#93bcf34 as nil") + } + b.PutString(e.Title) + b.PutLong(e.IconEmojiID) + return nil +} + +// Decode implements bin.Decoder. +func (e *EmojiGroupPremium) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiGroupPremium#93bcf34 to nil") + } + if err := b.ConsumeID(EmojiGroupPremiumTypeID); err != nil { + return fmt.Errorf("unable to decode emojiGroupPremium#93bcf34: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmojiGroupPremium) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiGroupPremium#93bcf34 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode emojiGroupPremium#93bcf34: field title: %w", err) + } + e.Title = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode emojiGroupPremium#93bcf34: field icon_emoji_id: %w", err) + } + e.IconEmojiID = value + } + return nil +} + +// GetTitle returns value of Title field. +func (e *EmojiGroupPremium) GetTitle() (value string) { + if e == nil { + return + } + return e.Title +} + +// GetIconEmojiID returns value of IconEmojiID field. +func (e *EmojiGroupPremium) GetIconEmojiID() (value int64) { + if e == nil { + return + } + return e.IconEmojiID +} + +// EmojiGroupClassName is schema name of EmojiGroupClass. +const EmojiGroupClassName = "EmojiGroup" + +// EmojiGroupClass represents EmojiGroup generic type. +// +// See https://core.telegram.org/type/EmojiGroup for reference. +// +// Example: +// +// g, err := tg.DecodeEmojiGroup(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.EmojiGroup: // emojiGroup#7a9abda9 +// case *tg.EmojiGroupGreeting: // emojiGroupGreeting#80d26cc7 +// case *tg.EmojiGroupPremium: // emojiGroupPremium#93bcf34 +// default: panic(v) +// } +type EmojiGroupClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() EmojiGroupClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // Category name, i.e. "Animals", "Flags", "Faces" and so on... + GetTitle() (value string) + + // A single custom emoji used as preview for the category. + GetIconEmojiID() (value int64) +} + +// DecodeEmojiGroup implements binary de-serialization for EmojiGroupClass. +func DecodeEmojiGroup(buf *bin.Buffer) (EmojiGroupClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case EmojiGroupTypeID: + // Decoding emojiGroup#7a9abda9. + v := EmojiGroup{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmojiGroupClass: %w", err) + } + return &v, nil + case EmojiGroupGreetingTypeID: + // Decoding emojiGroupGreeting#80d26cc7. + v := EmojiGroupGreeting{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmojiGroupClass: %w", err) + } + return &v, nil + case EmojiGroupPremiumTypeID: + // Decoding emojiGroupPremium#93bcf34. + v := EmojiGroupPremium{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmojiGroupClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode EmojiGroupClass: %w", bin.NewUnexpectedID(id)) + } +} + +// EmojiGroup boxes the EmojiGroupClass providing a helper. +type EmojiGroupBox struct { + EmojiGroup EmojiGroupClass +} + +// Decode implements bin.Decoder for EmojiGroupBox. +func (b *EmojiGroupBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode EmojiGroupBox to nil") + } + v, err := DecodeEmojiGroup(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.EmojiGroup = v + return nil +} + +// Encode implements bin.Encode for EmojiGroupBox. +func (b *EmojiGroupBox) Encode(buf *bin.Buffer) error { + if b == nil || b.EmojiGroup == nil { + return fmt.Errorf("unable to encode EmojiGroupClass as nil") + } + return b.EmojiGroup.Encode(buf) +} diff --git a/tg/tl_emoji_group_slices_gen.go b/tg/tl_emoji_group_slices_gen.go index fe21471a4..93529ec0b 100644 --- a/tg/tl_emoji_group_slices_gen.go +++ b/tg/tl_emoji_group_slices_gen.go @@ -33,3 +33,370 @@ var ( _ = tgerr.Error{} _ = tdjson.Encoder{} ) + +// EmojiGroupClassArray is adapter for slice of EmojiGroupClass. +type EmojiGroupClassArray []EmojiGroupClass + +// Sort sorts slice of EmojiGroupClass. +func (s EmojiGroupClassArray) Sort(less func(a, b EmojiGroupClass) bool) EmojiGroupClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmojiGroupClass. +func (s EmojiGroupClassArray) SortStable(less func(a, b EmojiGroupClass) bool) EmojiGroupClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmojiGroupClass. +func (s EmojiGroupClassArray) Retain(keep func(x EmojiGroupClass) bool) EmojiGroupClassArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmojiGroupClassArray) First() (v EmojiGroupClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmojiGroupClassArray) Last() (v EmojiGroupClass, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmojiGroupClassArray) PopFirst() (v EmojiGroupClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmojiGroupClass + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmojiGroupClassArray) Pop() (v EmojiGroupClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AsEmojiGroup returns copy with only EmojiGroup constructors. +func (s EmojiGroupClassArray) AsEmojiGroup() (to EmojiGroupArray) { + for _, elem := range s { + value, ok := elem.(*EmojiGroup) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsEmojiGroupGreeting returns copy with only EmojiGroupGreeting constructors. +func (s EmojiGroupClassArray) AsEmojiGroupGreeting() (to EmojiGroupGreetingArray) { + for _, elem := range s { + value, ok := elem.(*EmojiGroupGreeting) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsEmojiGroupPremium returns copy with only EmojiGroupPremium constructors. +func (s EmojiGroupClassArray) AsEmojiGroupPremium() (to EmojiGroupPremiumArray) { + for _, elem := range s { + value, ok := elem.(*EmojiGroupPremium) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// EmojiGroupArray is adapter for slice of EmojiGroup. +type EmojiGroupArray []EmojiGroup + +// Sort sorts slice of EmojiGroup. +func (s EmojiGroupArray) Sort(less func(a, b EmojiGroup) bool) EmojiGroupArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmojiGroup. +func (s EmojiGroupArray) SortStable(less func(a, b EmojiGroup) bool) EmojiGroupArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmojiGroup. +func (s EmojiGroupArray) Retain(keep func(x EmojiGroup) bool) EmojiGroupArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmojiGroupArray) First() (v EmojiGroup, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmojiGroupArray) Last() (v EmojiGroup, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmojiGroupArray) PopFirst() (v EmojiGroup, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmojiGroup + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmojiGroupArray) Pop() (v EmojiGroup, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// EmojiGroupGreetingArray is adapter for slice of EmojiGroupGreeting. +type EmojiGroupGreetingArray []EmojiGroupGreeting + +// Sort sorts slice of EmojiGroupGreeting. +func (s EmojiGroupGreetingArray) Sort(less func(a, b EmojiGroupGreeting) bool) EmojiGroupGreetingArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmojiGroupGreeting. +func (s EmojiGroupGreetingArray) SortStable(less func(a, b EmojiGroupGreeting) bool) EmojiGroupGreetingArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmojiGroupGreeting. +func (s EmojiGroupGreetingArray) Retain(keep func(x EmojiGroupGreeting) bool) EmojiGroupGreetingArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmojiGroupGreetingArray) First() (v EmojiGroupGreeting, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmojiGroupGreetingArray) Last() (v EmojiGroupGreeting, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmojiGroupGreetingArray) PopFirst() (v EmojiGroupGreeting, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmojiGroupGreeting + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmojiGroupGreetingArray) Pop() (v EmojiGroupGreeting, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// EmojiGroupPremiumArray is adapter for slice of EmojiGroupPremium. +type EmojiGroupPremiumArray []EmojiGroupPremium + +// Sort sorts slice of EmojiGroupPremium. +func (s EmojiGroupPremiumArray) Sort(less func(a, b EmojiGroupPremium) bool) EmojiGroupPremiumArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmojiGroupPremium. +func (s EmojiGroupPremiumArray) SortStable(less func(a, b EmojiGroupPremium) bool) EmojiGroupPremiumArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmojiGroupPremium. +func (s EmojiGroupPremiumArray) Retain(keep func(x EmojiGroupPremium) bool) EmojiGroupPremiumArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmojiGroupPremiumArray) First() (v EmojiGroupPremium, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmojiGroupPremiumArray) Last() (v EmojiGroupPremium, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmojiGroupPremiumArray) PopFirst() (v EmojiGroupPremium, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmojiGroupPremium + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmojiGroupPremiumArray) Pop() (v EmojiGroupPremium, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_messages_emoji_groups_gen.go b/tg/tl_messages_emoji_groups_gen.go index 5ad702b5b..e82dd896f 100644 --- a/tg/tl_messages_emoji_groups_gen.go +++ b/tg/tl_messages_emoji_groups_gen.go @@ -153,7 +153,7 @@ type MessagesEmojiGroups struct { // // Links: // 1) https://core.telegram.org/api/custom-emoji#emoji-categories - Groups []EmojiGroup + Groups []EmojiGroupClass } // MessagesEmojiGroupsTypeID is TL type id of MessagesEmojiGroups. @@ -198,7 +198,7 @@ func (e *MessagesEmojiGroups) String() string { // FillFrom fills MessagesEmojiGroups from given interface. func (e *MessagesEmojiGroups) FillFrom(from interface { GetHash() (value int) - GetGroups() (value []EmojiGroup) + GetGroups() (value []EmojiGroupClass) }) { e.Hash = from.GetHash() e.Groups = from.GetGroups() @@ -256,6 +256,9 @@ func (e *MessagesEmojiGroups) EncodeBare(b *bin.Buffer) error { b.PutInt(e.Hash) b.PutVectorHeader(len(e.Groups)) for idx, v := range e.Groups { + if v == nil { + return fmt.Errorf("unable to encode messages.emojiGroups#881fb94b: field groups element with index %d is nil", idx) + } if err := v.Encode(b); err != nil { return fmt.Errorf("unable to encode messages.emojiGroups#881fb94b: field groups element with index %d: %w", idx, err) } @@ -293,11 +296,11 @@ func (e *MessagesEmojiGroups) DecodeBare(b *bin.Buffer) error { } if headerLen > 0 { - e.Groups = make([]EmojiGroup, 0, headerLen%bin.PreallocateLimit) + e.Groups = make([]EmojiGroupClass, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { - var value EmojiGroup - if err := value.Decode(b); err != nil { + value, err := DecodeEmojiGroup(b) + if err != nil { return fmt.Errorf("unable to decode messages.emojiGroups#881fb94b: field groups: %w", err) } e.Groups = append(e.Groups, value) @@ -315,13 +318,18 @@ func (e *MessagesEmojiGroups) GetHash() (value int) { } // GetGroups returns value of Groups field. -func (e *MessagesEmojiGroups) GetGroups() (value []EmojiGroup) { +func (e *MessagesEmojiGroups) GetGroups() (value []EmojiGroupClass) { if e == nil { return } return e.Groups } +// MapGroups returns field Groups wrapped in EmojiGroupClassArray helper. +func (e *MessagesEmojiGroups) MapGroups() (value EmojiGroupClassArray) { + return EmojiGroupClassArray(e.Groups) +} + // MessagesEmojiGroupsClassName is schema name of MessagesEmojiGroupsClass. const MessagesEmojiGroupsClassName = "messages.EmojiGroups" diff --git a/tg/tl_messages_get_emoji_sticker_groups_gen.go b/tg/tl_messages_get_emoji_sticker_groups_gen.go new file mode 100644 index 000000000..e71b9662d --- /dev/null +++ b/tg/tl_messages_get_emoji_sticker_groups_gen.go @@ -0,0 +1,176 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/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{} +) + +// MessagesGetEmojiStickerGroupsRequest represents TL type `messages.getEmojiStickerGroups#1dd840f5`. +// +// See https://core.telegram.org/method/messages.getEmojiStickerGroups for reference. +type MessagesGetEmojiStickerGroupsRequest struct { + // Hash field of MessagesGetEmojiStickerGroupsRequest. + Hash int +} + +// MessagesGetEmojiStickerGroupsRequestTypeID is TL type id of MessagesGetEmojiStickerGroupsRequest. +const MessagesGetEmojiStickerGroupsRequestTypeID = 0x1dd840f5 + +// Ensuring interfaces in compile-time for MessagesGetEmojiStickerGroupsRequest. +var ( + _ bin.Encoder = &MessagesGetEmojiStickerGroupsRequest{} + _ bin.Decoder = &MessagesGetEmojiStickerGroupsRequest{} + _ bin.BareEncoder = &MessagesGetEmojiStickerGroupsRequest{} + _ bin.BareDecoder = &MessagesGetEmojiStickerGroupsRequest{} +) + +func (g *MessagesGetEmojiStickerGroupsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetEmojiStickerGroupsRequest) String() string { + if g == nil { + return "MessagesGetEmojiStickerGroupsRequest(nil)" + } + type Alias MessagesGetEmojiStickerGroupsRequest + return fmt.Sprintf("MessagesGetEmojiStickerGroupsRequest%+v", Alias(*g)) +} + +// FillFrom fills MessagesGetEmojiStickerGroupsRequest from given interface. +func (g *MessagesGetEmojiStickerGroupsRequest) 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 (*MessagesGetEmojiStickerGroupsRequest) TypeID() uint32 { + return MessagesGetEmojiStickerGroupsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetEmojiStickerGroupsRequest) TypeName() string { + return "messages.getEmojiStickerGroups" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetEmojiStickerGroupsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getEmojiStickerGroups", + ID: MessagesGetEmojiStickerGroupsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetEmojiStickerGroupsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getEmojiStickerGroups#1dd840f5 as nil") + } + b.PutID(MessagesGetEmojiStickerGroupsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetEmojiStickerGroupsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getEmojiStickerGroups#1dd840f5 as nil") + } + b.PutInt(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetEmojiStickerGroupsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getEmojiStickerGroups#1dd840f5 to nil") + } + if err := b.ConsumeID(MessagesGetEmojiStickerGroupsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getEmojiStickerGroups#1dd840f5: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetEmojiStickerGroupsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getEmojiStickerGroups#1dd840f5 to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getEmojiStickerGroups#1dd840f5: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetHash returns value of Hash field. +func (g *MessagesGetEmojiStickerGroupsRequest) GetHash() (value int) { + if g == nil { + return + } + return g.Hash +} + +// MessagesGetEmojiStickerGroups invokes method messages.getEmojiStickerGroups#1dd840f5 returning error if any. +// +// See https://core.telegram.org/method/messages.getEmojiStickerGroups for reference. +func (c *Client) MessagesGetEmojiStickerGroups(ctx context.Context, hash int) (MessagesEmojiGroupsClass, error) { + var result MessagesEmojiGroupsBox + + request := &MessagesGetEmojiStickerGroupsRequest{ + Hash: hash, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.EmojiGroups, nil +} diff --git a/tg/tl_messages_get_emoji_sticker_groups_slices_gen.go b/tg/tl_messages_get_emoji_sticker_groups_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_messages_get_emoji_sticker_groups_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/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{} +) diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index a058ae84b..7ac4ab133 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -1179,6 +1179,8 @@ func TypesMap() map[uint32]string { EmojiListNotModifiedTypeID: "emojiListNotModified#481eadfa", EmojiListTypeID: "emojiList#7a1e11d1", EmojiGroupTypeID: "emojiGroup#7a9abda9", + EmojiGroupGreetingTypeID: "emojiGroupGreeting#80d26cc7", + EmojiGroupPremiumTypeID: "emojiGroupPremium#93bcf34", MessagesEmojiGroupsNotModifiedTypeID: "messages.emojiGroupsNotModified#6fb4ad87", MessagesEmojiGroupsTypeID: "messages.emojiGroups#881fb94b", TextWithEntitiesTypeID: "textWithEntities#751f3146", @@ -1319,7 +1321,7 @@ func TypesMap() map[uint32]string { ChannelsSponsoredMessageReportResultChooseOptionTypeID: "channels.sponsoredMessageReportResultChooseOption#846f9e42", ChannelsSponsoredMessageReportResultAdsHiddenTypeID: "channels.sponsoredMessageReportResultAdsHidden#3e3bcf2f", ChannelsSponsoredMessageReportResultReportedTypeID: "channels.sponsoredMessageReportResultReported#ad798849", - StatsBroadcastRevenueStatsTypeID: "stats.broadcastRevenueStats#d07b4bad", + StatsBroadcastRevenueStatsTypeID: "stats.broadcastRevenueStats#5407e297", StatsBroadcastRevenueWithdrawalURLTypeID: "stats.broadcastRevenueWithdrawalUrl#ec659737", BroadcastRevenueTransactionProceedsTypeID: "broadcastRevenueTransactionProceeds#557e2cc4", BroadcastRevenueTransactionWithdrawalTypeID: "broadcastRevenueTransactionWithdrawal#5a590978", @@ -1328,6 +1330,7 @@ func TypesMap() map[uint32]string { ReactionNotificationsFromContactsTypeID: "reactionNotificationsFromContacts#bac3a61a", ReactionNotificationsFromAllTypeID: "reactionNotificationsFromAll#4b9e22a0", ReactionsNotifySettingsTypeID: "reactionsNotifySettings#56e34970", + BroadcastRevenueBalancesTypeID: "broadcastRevenueBalances#8438f1c6", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1709,6 +1712,7 @@ func TypesMap() map[uint32]string { MessagesDeleteQuickReplyMessagesRequestTypeID: "messages.deleteQuickReplyMessages#e105e910", MessagesToggleDialogFilterTagsRequestTypeID: "messages.toggleDialogFilterTags#fd2dda49", MessagesGetMyStickersRequestTypeID: "messages.getMyStickers#d0b5e1fc", + MessagesGetEmojiStickerGroupsRequestTypeID: "messages.getEmojiStickerGroups#1dd840f5", UpdatesGetStateRequestTypeID: "updates.getState#edd4882a", UpdatesGetDifferenceRequestTypeID: "updates.getDifference#19c2f763", UpdatesGetChannelDifferenceRequestTypeID: "updates.getChannelDifference#3173d78", @@ -3114,6 +3118,8 @@ func NamesMap() map[string]uint32 { "emojiListNotModified": EmojiListNotModifiedTypeID, "emojiList": EmojiListTypeID, "emojiGroup": EmojiGroupTypeID, + "emojiGroupGreeting": EmojiGroupGreetingTypeID, + "emojiGroupPremium": EmojiGroupPremiumTypeID, "messages.emojiGroupsNotModified": MessagesEmojiGroupsNotModifiedTypeID, "messages.emojiGroups": MessagesEmojiGroupsTypeID, "textWithEntities": TextWithEntitiesTypeID, @@ -3263,6 +3269,7 @@ func NamesMap() map[string]uint32 { "reactionNotificationsFromContacts": ReactionNotificationsFromContactsTypeID, "reactionNotificationsFromAll": ReactionNotificationsFromAllTypeID, "reactionsNotifySettings": ReactionsNotifySettingsTypeID, + "broadcastRevenueBalances": BroadcastRevenueBalancesTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -3644,6 +3651,7 @@ func NamesMap() map[string]uint32 { "messages.deleteQuickReplyMessages": MessagesDeleteQuickReplyMessagesRequestTypeID, "messages.toggleDialogFilterTags": MessagesToggleDialogFilterTagsRequestTypeID, "messages.getMyStickers": MessagesGetMyStickersRequestTypeID, + "messages.getEmojiStickerGroups": MessagesGetEmojiStickerGroupsRequestTypeID, "updates.getState": UpdatesGetStateRequestTypeID, "updates.getDifference": UpdatesGetDifferenceRequestTypeID, "updates.getChannelDifference": UpdatesGetChannelDifferenceRequestTypeID, @@ -5049,6 +5057,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { EmojiListNotModifiedTypeID: func() bin.Object { return &EmojiListNotModified{} }, EmojiListTypeID: func() bin.Object { return &EmojiList{} }, EmojiGroupTypeID: func() bin.Object { return &EmojiGroup{} }, + EmojiGroupGreetingTypeID: func() bin.Object { return &EmojiGroupGreeting{} }, + EmojiGroupPremiumTypeID: func() bin.Object { return &EmojiGroupPremium{} }, MessagesEmojiGroupsNotModifiedTypeID: func() bin.Object { return &MessagesEmojiGroupsNotModified{} }, MessagesEmojiGroupsTypeID: func() bin.Object { return &MessagesEmojiGroups{} }, TextWithEntitiesTypeID: func() bin.Object { return &TextWithEntities{} }, @@ -5198,6 +5208,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ReactionNotificationsFromContactsTypeID: func() bin.Object { return &ReactionNotificationsFromContacts{} }, ReactionNotificationsFromAllTypeID: func() bin.Object { return &ReactionNotificationsFromAll{} }, ReactionsNotifySettingsTypeID: func() bin.Object { return &ReactionsNotifySettings{} }, + BroadcastRevenueBalancesTypeID: func() bin.Object { return &BroadcastRevenueBalances{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -5579,6 +5590,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagesDeleteQuickReplyMessagesRequestTypeID: func() bin.Object { return &MessagesDeleteQuickReplyMessagesRequest{} }, MessagesToggleDialogFilterTagsRequestTypeID: func() bin.Object { return &MessagesToggleDialogFilterTagsRequest{} }, MessagesGetMyStickersRequestTypeID: func() bin.Object { return &MessagesGetMyStickersRequest{} }, + MessagesGetEmojiStickerGroupsRequestTypeID: func() bin.Object { return &MessagesGetEmojiStickerGroupsRequest{} }, UpdatesGetStateRequestTypeID: func() bin.Object { return &UpdatesGetStateRequest{} }, UpdatesGetDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetDifferenceRequest{} }, UpdatesGetChannelDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetChannelDifferenceRequest{} }, @@ -6144,6 +6156,11 @@ func ClassConstructorsMap() map[string][]uint32 { EmailVerifyPurposeLoginChangeTypeID, EmailVerifyPurposePassportTypeID, }, + EmojiGroupClassName: { + EmojiGroupTypeID, + EmojiGroupGreetingTypeID, + EmojiGroupPremiumTypeID, + }, EmojiKeywordClassName: { EmojiKeywordTypeID, EmojiKeywordDeletedTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index ddb126395..82e7cb9a2 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -6890,6 +6890,23 @@ func (s *ServerDispatcher) OnMessagesGetMyStickers(f func(ctx context.Context, r s.handlers[MessagesGetMyStickersRequestTypeID] = handler } +func (s *ServerDispatcher) OnMessagesGetEmojiStickerGroups(f func(ctx context.Context, hash int) (MessagesEmojiGroupsClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetEmojiStickerGroupsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Hash) + if err != nil { + return nil, err + } + return &MessagesEmojiGroupsBox{EmojiGroups: response}, nil + } + + s.handlers[MessagesGetEmojiStickerGroupsRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUpdatesGetState(f func(ctx context.Context) (*UpdatesState, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UpdatesGetStateRequest diff --git a/tg/tl_stats_broadcast_revenue_stats_gen.go b/tg/tl_stats_broadcast_revenue_stats_gen.go index ad603b062..0808a8e3b 100644 --- a/tg/tl_stats_broadcast_revenue_stats_gen.go +++ b/tg/tl_stats_broadcast_revenue_stats_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// StatsBroadcastRevenueStats represents TL type `stats.broadcastRevenueStats#d07b4bad`. +// StatsBroadcastRevenueStats represents TL type `stats.broadcastRevenueStats#5407e297`. // // See https://core.telegram.org/constructor/stats.broadcastRevenueStats for reference. type StatsBroadcastRevenueStats struct { @@ -39,18 +39,14 @@ type StatsBroadcastRevenueStats struct { TopHoursGraph StatsGraphClass // RevenueGraph field of StatsBroadcastRevenueStats. RevenueGraph StatsGraphClass - // CurrentBalance field of StatsBroadcastRevenueStats. - CurrentBalance int64 - // AvailableBalance field of StatsBroadcastRevenueStats. - AvailableBalance int64 - // OverallRevenue field of StatsBroadcastRevenueStats. - OverallRevenue int64 + // Balances field of StatsBroadcastRevenueStats. + Balances BroadcastRevenueBalances // UsdRate field of StatsBroadcastRevenueStats. UsdRate float64 } // StatsBroadcastRevenueStatsTypeID is TL type id of StatsBroadcastRevenueStats. -const StatsBroadcastRevenueStatsTypeID = 0xd07b4bad +const StatsBroadcastRevenueStatsTypeID = 0x5407e297 // Ensuring interfaces in compile-time for StatsBroadcastRevenueStats. var ( @@ -70,13 +66,7 @@ func (b *StatsBroadcastRevenueStats) Zero() bool { if !(b.RevenueGraph == nil) { return false } - if !(b.CurrentBalance == 0) { - return false - } - if !(b.AvailableBalance == 0) { - return false - } - if !(b.OverallRevenue == 0) { + if !(b.Balances.Zero()) { return false } if !(b.UsdRate == 0) { @@ -99,16 +89,12 @@ func (b *StatsBroadcastRevenueStats) String() string { func (b *StatsBroadcastRevenueStats) FillFrom(from interface { GetTopHoursGraph() (value StatsGraphClass) GetRevenueGraph() (value StatsGraphClass) - GetCurrentBalance() (value int64) - GetAvailableBalance() (value int64) - GetOverallRevenue() (value int64) + GetBalances() (value BroadcastRevenueBalances) GetUsdRate() (value float64) }) { b.TopHoursGraph = from.GetTopHoursGraph() b.RevenueGraph = from.GetRevenueGraph() - b.CurrentBalance = from.GetCurrentBalance() - b.AvailableBalance = from.GetAvailableBalance() - b.OverallRevenue = from.GetOverallRevenue() + b.Balances = from.GetBalances() b.UsdRate = from.GetUsdRate() } @@ -144,16 +130,8 @@ func (b *StatsBroadcastRevenueStats) TypeInfo() tdp.Type { SchemaName: "revenue_graph", }, { - Name: "CurrentBalance", - SchemaName: "current_balance", - }, - { - Name: "AvailableBalance", - SchemaName: "available_balance", - }, - { - Name: "OverallRevenue", - SchemaName: "overall_revenue", + Name: "Balances", + SchemaName: "balances", }, { Name: "UsdRate", @@ -166,7 +144,7 @@ func (b *StatsBroadcastRevenueStats) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (b *StatsBroadcastRevenueStats) Encode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode stats.broadcastRevenueStats#d07b4bad as nil") + return fmt.Errorf("can't encode stats.broadcastRevenueStats#5407e297 as nil") } buf.PutID(StatsBroadcastRevenueStatsTypeID) return b.EncodeBare(buf) @@ -175,23 +153,23 @@ func (b *StatsBroadcastRevenueStats) Encode(buf *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (b *StatsBroadcastRevenueStats) EncodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode stats.broadcastRevenueStats#d07b4bad as nil") + return fmt.Errorf("can't encode stats.broadcastRevenueStats#5407e297 as nil") } if b.TopHoursGraph == nil { - return fmt.Errorf("unable to encode stats.broadcastRevenueStats#d07b4bad: field top_hours_graph is nil") + return fmt.Errorf("unable to encode stats.broadcastRevenueStats#5407e297: field top_hours_graph is nil") } if err := b.TopHoursGraph.Encode(buf); err != nil { - return fmt.Errorf("unable to encode stats.broadcastRevenueStats#d07b4bad: field top_hours_graph: %w", err) + return fmt.Errorf("unable to encode stats.broadcastRevenueStats#5407e297: field top_hours_graph: %w", err) } if b.RevenueGraph == nil { - return fmt.Errorf("unable to encode stats.broadcastRevenueStats#d07b4bad: field revenue_graph is nil") + return fmt.Errorf("unable to encode stats.broadcastRevenueStats#5407e297: field revenue_graph is nil") } if err := b.RevenueGraph.Encode(buf); err != nil { - return fmt.Errorf("unable to encode stats.broadcastRevenueStats#d07b4bad: field revenue_graph: %w", err) + return fmt.Errorf("unable to encode stats.broadcastRevenueStats#5407e297: field revenue_graph: %w", err) + } + if err := b.Balances.Encode(buf); err != nil { + return fmt.Errorf("unable to encode stats.broadcastRevenueStats#5407e297: field balances: %w", err) } - buf.PutLong(b.CurrentBalance) - buf.PutLong(b.AvailableBalance) - buf.PutLong(b.OverallRevenue) buf.PutDouble(b.UsdRate) return nil } @@ -199,10 +177,10 @@ func (b *StatsBroadcastRevenueStats) EncodeBare(buf *bin.Buffer) error { // Decode implements bin.Decoder. func (b *StatsBroadcastRevenueStats) Decode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode stats.broadcastRevenueStats#d07b4bad to nil") + return fmt.Errorf("can't decode stats.broadcastRevenueStats#5407e297 to nil") } if err := buf.ConsumeID(StatsBroadcastRevenueStatsTypeID); err != nil { - return fmt.Errorf("unable to decode stats.broadcastRevenueStats#d07b4bad: %w", err) + return fmt.Errorf("unable to decode stats.broadcastRevenueStats#5407e297: %w", err) } return b.DecodeBare(buf) } @@ -210,47 +188,31 @@ func (b *StatsBroadcastRevenueStats) Decode(buf *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (b *StatsBroadcastRevenueStats) DecodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode stats.broadcastRevenueStats#d07b4bad to nil") + return fmt.Errorf("can't decode stats.broadcastRevenueStats#5407e297 to nil") } { value, err := DecodeStatsGraph(buf) if err != nil { - return fmt.Errorf("unable to decode stats.broadcastRevenueStats#d07b4bad: field top_hours_graph: %w", err) + return fmt.Errorf("unable to decode stats.broadcastRevenueStats#5407e297: field top_hours_graph: %w", err) } b.TopHoursGraph = value } { value, err := DecodeStatsGraph(buf) if err != nil { - return fmt.Errorf("unable to decode stats.broadcastRevenueStats#d07b4bad: field revenue_graph: %w", err) + return fmt.Errorf("unable to decode stats.broadcastRevenueStats#5407e297: field revenue_graph: %w", err) } b.RevenueGraph = value } { - value, err := buf.Long() - if err != nil { - return fmt.Errorf("unable to decode stats.broadcastRevenueStats#d07b4bad: field current_balance: %w", err) - } - b.CurrentBalance = value - } - { - value, err := buf.Long() - if err != nil { - return fmt.Errorf("unable to decode stats.broadcastRevenueStats#d07b4bad: field available_balance: %w", err) - } - b.AvailableBalance = value - } - { - value, err := buf.Long() - if err != nil { - return fmt.Errorf("unable to decode stats.broadcastRevenueStats#d07b4bad: field overall_revenue: %w", err) + if err := b.Balances.Decode(buf); err != nil { + return fmt.Errorf("unable to decode stats.broadcastRevenueStats#5407e297: field balances: %w", err) } - b.OverallRevenue = value } { value, err := buf.Double() if err != nil { - return fmt.Errorf("unable to decode stats.broadcastRevenueStats#d07b4bad: field usd_rate: %w", err) + return fmt.Errorf("unable to decode stats.broadcastRevenueStats#5407e297: field usd_rate: %w", err) } b.UsdRate = value } @@ -273,28 +235,12 @@ func (b *StatsBroadcastRevenueStats) GetRevenueGraph() (value StatsGraphClass) { return b.RevenueGraph } -// GetCurrentBalance returns value of CurrentBalance field. -func (b *StatsBroadcastRevenueStats) GetCurrentBalance() (value int64) { - if b == nil { - return - } - return b.CurrentBalance -} - -// GetAvailableBalance returns value of AvailableBalance field. -func (b *StatsBroadcastRevenueStats) GetAvailableBalance() (value int64) { - if b == nil { - return - } - return b.AvailableBalance -} - -// GetOverallRevenue returns value of OverallRevenue field. -func (b *StatsBroadcastRevenueStats) GetOverallRevenue() (value int64) { +// GetBalances returns value of Balances field. +func (b *StatsBroadcastRevenueStats) GetBalances() (value BroadcastRevenueBalances) { if b == nil { return } - return b.OverallRevenue + return b.Balances } // GetUsdRate returns value of UsdRate field.