7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
1744 lines
43 KiB
Go
1744 lines
43 KiB
Go
// 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{}
|
|
)
|
|
|
|
// ChannelParticipant represents TL type `channelParticipant#cb397619`.
|
|
// Channel/supergroup participant
|
|
//
|
|
// See https://core.telegram.org/constructor/channelParticipant for reference.
|
|
type ChannelParticipant struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// Participant user ID
|
|
UserID int64
|
|
// Date joined
|
|
Date int
|
|
// If set, contains the expiration date of the current Telegram Star subscription period
|
|
// »¹ for the specified participant.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/stars#star-subscriptions
|
|
//
|
|
// Use SetSubscriptionUntilDate and GetSubscriptionUntilDate helpers.
|
|
SubscriptionUntilDate int
|
|
}
|
|
|
|
// ChannelParticipantTypeID is TL type id of ChannelParticipant.
|
|
const ChannelParticipantTypeID = 0xcb397619
|
|
|
|
// construct implements constructor of ChannelParticipantClass.
|
|
func (c ChannelParticipant) construct() ChannelParticipantClass { return &c }
|
|
|
|
// Ensuring interfaces in compile-time for ChannelParticipant.
|
|
var (
|
|
_ bin.Encoder = &ChannelParticipant{}
|
|
_ bin.Decoder = &ChannelParticipant{}
|
|
_ bin.BareEncoder = &ChannelParticipant{}
|
|
_ bin.BareDecoder = &ChannelParticipant{}
|
|
|
|
_ ChannelParticipantClass = &ChannelParticipant{}
|
|
)
|
|
|
|
func (c *ChannelParticipant) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.UserID == 0) {
|
|
return false
|
|
}
|
|
if !(c.Date == 0) {
|
|
return false
|
|
}
|
|
if !(c.SubscriptionUntilDate == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChannelParticipant) String() string {
|
|
if c == nil {
|
|
return "ChannelParticipant(nil)"
|
|
}
|
|
type Alias ChannelParticipant
|
|
return fmt.Sprintf("ChannelParticipant%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills ChannelParticipant from given interface.
|
|
func (c *ChannelParticipant) FillFrom(from interface {
|
|
GetUserID() (value int64)
|
|
GetDate() (value int)
|
|
GetSubscriptionUntilDate() (value int, ok bool)
|
|
}) {
|
|
c.UserID = from.GetUserID()
|
|
c.Date = from.GetDate()
|
|
if val, ok := from.GetSubscriptionUntilDate(); ok {
|
|
c.SubscriptionUntilDate = val
|
|
}
|
|
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChannelParticipant) TypeID() uint32 {
|
|
return ChannelParticipantTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChannelParticipant) TypeName() string {
|
|
return "channelParticipant"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChannelParticipant) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "channelParticipant",
|
|
ID: ChannelParticipantTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "UserID",
|
|
SchemaName: "user_id",
|
|
},
|
|
{
|
|
Name: "Date",
|
|
SchemaName: "date",
|
|
},
|
|
{
|
|
Name: "SubscriptionUntilDate",
|
|
SchemaName: "subscription_until_date",
|
|
Null: !c.Flags.Has(0),
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (c *ChannelParticipant) SetFlags() {
|
|
if !(c.SubscriptionUntilDate == 0) {
|
|
c.Flags.Set(0)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChannelParticipant) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipant#cb397619 as nil")
|
|
}
|
|
b.PutID(ChannelParticipantTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChannelParticipant) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipant#cb397619 as nil")
|
|
}
|
|
c.SetFlags()
|
|
if err := c.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipant#cb397619: field flags: %w", err)
|
|
}
|
|
b.PutLong(c.UserID)
|
|
b.PutInt(c.Date)
|
|
if c.Flags.Has(0) {
|
|
b.PutInt(c.SubscriptionUntilDate)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChannelParticipant) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipant#cb397619 to nil")
|
|
}
|
|
if err := b.ConsumeID(ChannelParticipantTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipant#cb397619: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChannelParticipant) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipant#cb397619 to nil")
|
|
}
|
|
{
|
|
if err := c.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipant#cb397619: field flags: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipant#cb397619: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipant#cb397619: field date: %w", err)
|
|
}
|
|
c.Date = value
|
|
}
|
|
if c.Flags.Has(0) {
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipant#cb397619: field subscription_until_date: %w", err)
|
|
}
|
|
c.SubscriptionUntilDate = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetUserID returns value of UserID field.
|
|
func (c *ChannelParticipant) GetUserID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.UserID
|
|
}
|
|
|
|
// GetDate returns value of Date field.
|
|
func (c *ChannelParticipant) GetDate() (value int) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Date
|
|
}
|
|
|
|
// SetSubscriptionUntilDate sets value of SubscriptionUntilDate conditional field.
|
|
func (c *ChannelParticipant) SetSubscriptionUntilDate(value int) {
|
|
c.Flags.Set(0)
|
|
c.SubscriptionUntilDate = value
|
|
}
|
|
|
|
// GetSubscriptionUntilDate returns value of SubscriptionUntilDate conditional field and
|
|
// boolean which is true if field was set.
|
|
func (c *ChannelParticipant) GetSubscriptionUntilDate() (value int, ok bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
if !c.Flags.Has(0) {
|
|
return value, false
|
|
}
|
|
return c.SubscriptionUntilDate, true
|
|
}
|
|
|
|
// ChannelParticipantSelf represents TL type `channelParticipantSelf#4f607bef`.
|
|
// Myself
|
|
//
|
|
// See https://core.telegram.org/constructor/channelParticipantSelf for reference.
|
|
type ChannelParticipantSelf struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// Whether I joined upon specific approval of an admin
|
|
ViaRequest bool
|
|
// User ID
|
|
UserID int64
|
|
// User that invited me to the channel/supergroup
|
|
InviterID int64
|
|
// When did I join the channel/supergroup
|
|
Date int
|
|
// If set, contains the expiration date of the current Telegram Star subscription period
|
|
// »¹ for the specified participant.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/stars#star-subscriptions
|
|
//
|
|
// Use SetSubscriptionUntilDate and GetSubscriptionUntilDate helpers.
|
|
SubscriptionUntilDate int
|
|
}
|
|
|
|
// ChannelParticipantSelfTypeID is TL type id of ChannelParticipantSelf.
|
|
const ChannelParticipantSelfTypeID = 0x4f607bef
|
|
|
|
// construct implements constructor of ChannelParticipantClass.
|
|
func (c ChannelParticipantSelf) construct() ChannelParticipantClass { return &c }
|
|
|
|
// Ensuring interfaces in compile-time for ChannelParticipantSelf.
|
|
var (
|
|
_ bin.Encoder = &ChannelParticipantSelf{}
|
|
_ bin.Decoder = &ChannelParticipantSelf{}
|
|
_ bin.BareEncoder = &ChannelParticipantSelf{}
|
|
_ bin.BareDecoder = &ChannelParticipantSelf{}
|
|
|
|
_ ChannelParticipantClass = &ChannelParticipantSelf{}
|
|
)
|
|
|
|
func (c *ChannelParticipantSelf) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.ViaRequest == false) {
|
|
return false
|
|
}
|
|
if !(c.UserID == 0) {
|
|
return false
|
|
}
|
|
if !(c.InviterID == 0) {
|
|
return false
|
|
}
|
|
if !(c.Date == 0) {
|
|
return false
|
|
}
|
|
if !(c.SubscriptionUntilDate == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChannelParticipantSelf) String() string {
|
|
if c == nil {
|
|
return "ChannelParticipantSelf(nil)"
|
|
}
|
|
type Alias ChannelParticipantSelf
|
|
return fmt.Sprintf("ChannelParticipantSelf%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills ChannelParticipantSelf from given interface.
|
|
func (c *ChannelParticipantSelf) FillFrom(from interface {
|
|
GetViaRequest() (value bool)
|
|
GetUserID() (value int64)
|
|
GetInviterID() (value int64)
|
|
GetDate() (value int)
|
|
GetSubscriptionUntilDate() (value int, ok bool)
|
|
}) {
|
|
c.ViaRequest = from.GetViaRequest()
|
|
c.UserID = from.GetUserID()
|
|
c.InviterID = from.GetInviterID()
|
|
c.Date = from.GetDate()
|
|
if val, ok := from.GetSubscriptionUntilDate(); ok {
|
|
c.SubscriptionUntilDate = val
|
|
}
|
|
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChannelParticipantSelf) TypeID() uint32 {
|
|
return ChannelParticipantSelfTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChannelParticipantSelf) TypeName() string {
|
|
return "channelParticipantSelf"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChannelParticipantSelf) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "channelParticipantSelf",
|
|
ID: ChannelParticipantSelfTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ViaRequest",
|
|
SchemaName: "via_request",
|
|
Null: !c.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "UserID",
|
|
SchemaName: "user_id",
|
|
},
|
|
{
|
|
Name: "InviterID",
|
|
SchemaName: "inviter_id",
|
|
},
|
|
{
|
|
Name: "Date",
|
|
SchemaName: "date",
|
|
},
|
|
{
|
|
Name: "SubscriptionUntilDate",
|
|
SchemaName: "subscription_until_date",
|
|
Null: !c.Flags.Has(1),
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (c *ChannelParticipantSelf) SetFlags() {
|
|
if !(c.ViaRequest == false) {
|
|
c.Flags.Set(0)
|
|
}
|
|
if !(c.SubscriptionUntilDate == 0) {
|
|
c.Flags.Set(1)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChannelParticipantSelf) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantSelf#4f607bef as nil")
|
|
}
|
|
b.PutID(ChannelParticipantSelfTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChannelParticipantSelf) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantSelf#4f607bef as nil")
|
|
}
|
|
c.SetFlags()
|
|
if err := c.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipantSelf#4f607bef: field flags: %w", err)
|
|
}
|
|
b.PutLong(c.UserID)
|
|
b.PutLong(c.InviterID)
|
|
b.PutInt(c.Date)
|
|
if c.Flags.Has(1) {
|
|
b.PutInt(c.SubscriptionUntilDate)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChannelParticipantSelf) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantSelf#4f607bef to nil")
|
|
}
|
|
if err := b.ConsumeID(ChannelParticipantSelfTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantSelf#4f607bef: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChannelParticipantSelf) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantSelf#4f607bef to nil")
|
|
}
|
|
{
|
|
if err := c.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantSelf#4f607bef: field flags: %w", err)
|
|
}
|
|
}
|
|
c.ViaRequest = c.Flags.Has(0)
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantSelf#4f607bef: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantSelf#4f607bef: field inviter_id: %w", err)
|
|
}
|
|
c.InviterID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantSelf#4f607bef: field date: %w", err)
|
|
}
|
|
c.Date = value
|
|
}
|
|
if c.Flags.Has(1) {
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantSelf#4f607bef: field subscription_until_date: %w", err)
|
|
}
|
|
c.SubscriptionUntilDate = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetViaRequest sets value of ViaRequest conditional field.
|
|
func (c *ChannelParticipantSelf) SetViaRequest(value bool) {
|
|
if value {
|
|
c.Flags.Set(0)
|
|
c.ViaRequest = true
|
|
} else {
|
|
c.Flags.Unset(0)
|
|
c.ViaRequest = false
|
|
}
|
|
}
|
|
|
|
// GetViaRequest returns value of ViaRequest conditional field.
|
|
func (c *ChannelParticipantSelf) GetViaRequest() (value bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Flags.Has(0)
|
|
}
|
|
|
|
// GetUserID returns value of UserID field.
|
|
func (c *ChannelParticipantSelf) GetUserID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.UserID
|
|
}
|
|
|
|
// GetInviterID returns value of InviterID field.
|
|
func (c *ChannelParticipantSelf) GetInviterID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.InviterID
|
|
}
|
|
|
|
// GetDate returns value of Date field.
|
|
func (c *ChannelParticipantSelf) GetDate() (value int) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Date
|
|
}
|
|
|
|
// SetSubscriptionUntilDate sets value of SubscriptionUntilDate conditional field.
|
|
func (c *ChannelParticipantSelf) SetSubscriptionUntilDate(value int) {
|
|
c.Flags.Set(1)
|
|
c.SubscriptionUntilDate = value
|
|
}
|
|
|
|
// GetSubscriptionUntilDate returns value of SubscriptionUntilDate conditional field and
|
|
// boolean which is true if field was set.
|
|
func (c *ChannelParticipantSelf) GetSubscriptionUntilDate() (value int, ok bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
if !c.Flags.Has(1) {
|
|
return value, false
|
|
}
|
|
return c.SubscriptionUntilDate, true
|
|
}
|
|
|
|
// ChannelParticipantCreator represents TL type `channelParticipantCreator#2fe601d3`.
|
|
// Channel/supergroup creator
|
|
//
|
|
// See https://core.telegram.org/constructor/channelParticipantCreator for reference.
|
|
type ChannelParticipantCreator struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// User ID
|
|
UserID int64
|
|
// Creator admin rights
|
|
AdminRights ChatAdminRights
|
|
// The role (rank) of the group creator in the group: just an arbitrary string, admin by
|
|
// default
|
|
//
|
|
// Use SetRank and GetRank helpers.
|
|
Rank string
|
|
}
|
|
|
|
// ChannelParticipantCreatorTypeID is TL type id of ChannelParticipantCreator.
|
|
const ChannelParticipantCreatorTypeID = 0x2fe601d3
|
|
|
|
// construct implements constructor of ChannelParticipantClass.
|
|
func (c ChannelParticipantCreator) construct() ChannelParticipantClass { return &c }
|
|
|
|
// Ensuring interfaces in compile-time for ChannelParticipantCreator.
|
|
var (
|
|
_ bin.Encoder = &ChannelParticipantCreator{}
|
|
_ bin.Decoder = &ChannelParticipantCreator{}
|
|
_ bin.BareEncoder = &ChannelParticipantCreator{}
|
|
_ bin.BareDecoder = &ChannelParticipantCreator{}
|
|
|
|
_ ChannelParticipantClass = &ChannelParticipantCreator{}
|
|
)
|
|
|
|
func (c *ChannelParticipantCreator) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.UserID == 0) {
|
|
return false
|
|
}
|
|
if !(c.AdminRights.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.Rank == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChannelParticipantCreator) String() string {
|
|
if c == nil {
|
|
return "ChannelParticipantCreator(nil)"
|
|
}
|
|
type Alias ChannelParticipantCreator
|
|
return fmt.Sprintf("ChannelParticipantCreator%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills ChannelParticipantCreator from given interface.
|
|
func (c *ChannelParticipantCreator) FillFrom(from interface {
|
|
GetUserID() (value int64)
|
|
GetAdminRights() (value ChatAdminRights)
|
|
GetRank() (value string, ok bool)
|
|
}) {
|
|
c.UserID = from.GetUserID()
|
|
c.AdminRights = from.GetAdminRights()
|
|
if val, ok := from.GetRank(); ok {
|
|
c.Rank = val
|
|
}
|
|
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChannelParticipantCreator) TypeID() uint32 {
|
|
return ChannelParticipantCreatorTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChannelParticipantCreator) TypeName() string {
|
|
return "channelParticipantCreator"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChannelParticipantCreator) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "channelParticipantCreator",
|
|
ID: ChannelParticipantCreatorTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "UserID",
|
|
SchemaName: "user_id",
|
|
},
|
|
{
|
|
Name: "AdminRights",
|
|
SchemaName: "admin_rights",
|
|
},
|
|
{
|
|
Name: "Rank",
|
|
SchemaName: "rank",
|
|
Null: !c.Flags.Has(0),
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (c *ChannelParticipantCreator) SetFlags() {
|
|
if !(c.Rank == "") {
|
|
c.Flags.Set(0)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChannelParticipantCreator) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantCreator#2fe601d3 as nil")
|
|
}
|
|
b.PutID(ChannelParticipantCreatorTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChannelParticipantCreator) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantCreator#2fe601d3 as nil")
|
|
}
|
|
c.SetFlags()
|
|
if err := c.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipantCreator#2fe601d3: field flags: %w", err)
|
|
}
|
|
b.PutLong(c.UserID)
|
|
if err := c.AdminRights.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipantCreator#2fe601d3: field admin_rights: %w", err)
|
|
}
|
|
if c.Flags.Has(0) {
|
|
b.PutString(c.Rank)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChannelParticipantCreator) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantCreator#2fe601d3 to nil")
|
|
}
|
|
if err := b.ConsumeID(ChannelParticipantCreatorTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantCreator#2fe601d3: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChannelParticipantCreator) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantCreator#2fe601d3 to nil")
|
|
}
|
|
{
|
|
if err := c.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantCreator#2fe601d3: field flags: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantCreator#2fe601d3: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
}
|
|
{
|
|
if err := c.AdminRights.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantCreator#2fe601d3: field admin_rights: %w", err)
|
|
}
|
|
}
|
|
if c.Flags.Has(0) {
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantCreator#2fe601d3: field rank: %w", err)
|
|
}
|
|
c.Rank = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetUserID returns value of UserID field.
|
|
func (c *ChannelParticipantCreator) GetUserID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.UserID
|
|
}
|
|
|
|
// GetAdminRights returns value of AdminRights field.
|
|
func (c *ChannelParticipantCreator) GetAdminRights() (value ChatAdminRights) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.AdminRights
|
|
}
|
|
|
|
// SetRank sets value of Rank conditional field.
|
|
func (c *ChannelParticipantCreator) SetRank(value string) {
|
|
c.Flags.Set(0)
|
|
c.Rank = value
|
|
}
|
|
|
|
// GetRank returns value of Rank conditional field and
|
|
// boolean which is true if field was set.
|
|
func (c *ChannelParticipantCreator) GetRank() (value string, ok bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
if !c.Flags.Has(0) {
|
|
return value, false
|
|
}
|
|
return c.Rank, true
|
|
}
|
|
|
|
// ChannelParticipantAdmin represents TL type `channelParticipantAdmin#34c3bb53`.
|
|
// Admin
|
|
//
|
|
// See https://core.telegram.org/constructor/channelParticipantAdmin for reference.
|
|
type ChannelParticipantAdmin struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// Can this admin promote other admins with the same permissions?
|
|
CanEdit bool
|
|
// Is this the current user
|
|
Self bool
|
|
// Admin user ID
|
|
UserID int64
|
|
// User that invited the admin to the channel/group
|
|
//
|
|
// Use SetInviterID and GetInviterID helpers.
|
|
InviterID int64
|
|
// User that promoted the user to admin
|
|
PromotedBy int64
|
|
// When did the user join
|
|
Date int
|
|
// Admin rights¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/rights
|
|
AdminRights ChatAdminRights
|
|
// The role (rank) of the admin in the group: just an arbitrary string, admin by default
|
|
//
|
|
// Use SetRank and GetRank helpers.
|
|
Rank string
|
|
}
|
|
|
|
// ChannelParticipantAdminTypeID is TL type id of ChannelParticipantAdmin.
|
|
const ChannelParticipantAdminTypeID = 0x34c3bb53
|
|
|
|
// construct implements constructor of ChannelParticipantClass.
|
|
func (c ChannelParticipantAdmin) construct() ChannelParticipantClass { return &c }
|
|
|
|
// Ensuring interfaces in compile-time for ChannelParticipantAdmin.
|
|
var (
|
|
_ bin.Encoder = &ChannelParticipantAdmin{}
|
|
_ bin.Decoder = &ChannelParticipantAdmin{}
|
|
_ bin.BareEncoder = &ChannelParticipantAdmin{}
|
|
_ bin.BareDecoder = &ChannelParticipantAdmin{}
|
|
|
|
_ ChannelParticipantClass = &ChannelParticipantAdmin{}
|
|
)
|
|
|
|
func (c *ChannelParticipantAdmin) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.CanEdit == false) {
|
|
return false
|
|
}
|
|
if !(c.Self == false) {
|
|
return false
|
|
}
|
|
if !(c.UserID == 0) {
|
|
return false
|
|
}
|
|
if !(c.InviterID == 0) {
|
|
return false
|
|
}
|
|
if !(c.PromotedBy == 0) {
|
|
return false
|
|
}
|
|
if !(c.Date == 0) {
|
|
return false
|
|
}
|
|
if !(c.AdminRights.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.Rank == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChannelParticipantAdmin) String() string {
|
|
if c == nil {
|
|
return "ChannelParticipantAdmin(nil)"
|
|
}
|
|
type Alias ChannelParticipantAdmin
|
|
return fmt.Sprintf("ChannelParticipantAdmin%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills ChannelParticipantAdmin from given interface.
|
|
func (c *ChannelParticipantAdmin) FillFrom(from interface {
|
|
GetCanEdit() (value bool)
|
|
GetSelf() (value bool)
|
|
GetUserID() (value int64)
|
|
GetInviterID() (value int64, ok bool)
|
|
GetPromotedBy() (value int64)
|
|
GetDate() (value int)
|
|
GetAdminRights() (value ChatAdminRights)
|
|
GetRank() (value string, ok bool)
|
|
}) {
|
|
c.CanEdit = from.GetCanEdit()
|
|
c.Self = from.GetSelf()
|
|
c.UserID = from.GetUserID()
|
|
if val, ok := from.GetInviterID(); ok {
|
|
c.InviterID = val
|
|
}
|
|
|
|
c.PromotedBy = from.GetPromotedBy()
|
|
c.Date = from.GetDate()
|
|
c.AdminRights = from.GetAdminRights()
|
|
if val, ok := from.GetRank(); ok {
|
|
c.Rank = val
|
|
}
|
|
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChannelParticipantAdmin) TypeID() uint32 {
|
|
return ChannelParticipantAdminTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChannelParticipantAdmin) TypeName() string {
|
|
return "channelParticipantAdmin"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChannelParticipantAdmin) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "channelParticipantAdmin",
|
|
ID: ChannelParticipantAdminTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "CanEdit",
|
|
SchemaName: "can_edit",
|
|
Null: !c.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "Self",
|
|
SchemaName: "self",
|
|
Null: !c.Flags.Has(1),
|
|
},
|
|
{
|
|
Name: "UserID",
|
|
SchemaName: "user_id",
|
|
},
|
|
{
|
|
Name: "InviterID",
|
|
SchemaName: "inviter_id",
|
|
Null: !c.Flags.Has(1),
|
|
},
|
|
{
|
|
Name: "PromotedBy",
|
|
SchemaName: "promoted_by",
|
|
},
|
|
{
|
|
Name: "Date",
|
|
SchemaName: "date",
|
|
},
|
|
{
|
|
Name: "AdminRights",
|
|
SchemaName: "admin_rights",
|
|
},
|
|
{
|
|
Name: "Rank",
|
|
SchemaName: "rank",
|
|
Null: !c.Flags.Has(2),
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (c *ChannelParticipantAdmin) SetFlags() {
|
|
if !(c.CanEdit == false) {
|
|
c.Flags.Set(0)
|
|
}
|
|
if !(c.Self == false) {
|
|
c.Flags.Set(1)
|
|
}
|
|
if !(c.InviterID == 0) {
|
|
c.Flags.Set(1)
|
|
}
|
|
if !(c.Rank == "") {
|
|
c.Flags.Set(2)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChannelParticipantAdmin) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantAdmin#34c3bb53 as nil")
|
|
}
|
|
b.PutID(ChannelParticipantAdminTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChannelParticipantAdmin) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantAdmin#34c3bb53 as nil")
|
|
}
|
|
c.SetFlags()
|
|
if err := c.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipantAdmin#34c3bb53: field flags: %w", err)
|
|
}
|
|
b.PutLong(c.UserID)
|
|
if c.Flags.Has(1) {
|
|
b.PutLong(c.InviterID)
|
|
}
|
|
b.PutLong(c.PromotedBy)
|
|
b.PutInt(c.Date)
|
|
if err := c.AdminRights.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipantAdmin#34c3bb53: field admin_rights: %w", err)
|
|
}
|
|
if c.Flags.Has(2) {
|
|
b.PutString(c.Rank)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChannelParticipantAdmin) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantAdmin#34c3bb53 to nil")
|
|
}
|
|
if err := b.ConsumeID(ChannelParticipantAdminTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChannelParticipantAdmin) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantAdmin#34c3bb53 to nil")
|
|
}
|
|
{
|
|
if err := c.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field flags: %w", err)
|
|
}
|
|
}
|
|
c.CanEdit = c.Flags.Has(0)
|
|
c.Self = c.Flags.Has(1)
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
}
|
|
if c.Flags.Has(1) {
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field inviter_id: %w", err)
|
|
}
|
|
c.InviterID = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field promoted_by: %w", err)
|
|
}
|
|
c.PromotedBy = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field date: %w", err)
|
|
}
|
|
c.Date = value
|
|
}
|
|
{
|
|
if err := c.AdminRights.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field admin_rights: %w", err)
|
|
}
|
|
}
|
|
if c.Flags.Has(2) {
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field rank: %w", err)
|
|
}
|
|
c.Rank = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetCanEdit sets value of CanEdit conditional field.
|
|
func (c *ChannelParticipantAdmin) SetCanEdit(value bool) {
|
|
if value {
|
|
c.Flags.Set(0)
|
|
c.CanEdit = true
|
|
} else {
|
|
c.Flags.Unset(0)
|
|
c.CanEdit = false
|
|
}
|
|
}
|
|
|
|
// GetCanEdit returns value of CanEdit conditional field.
|
|
func (c *ChannelParticipantAdmin) GetCanEdit() (value bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Flags.Has(0)
|
|
}
|
|
|
|
// SetSelf sets value of Self conditional field.
|
|
func (c *ChannelParticipantAdmin) SetSelf(value bool) {
|
|
if value {
|
|
c.Flags.Set(1)
|
|
c.Self = true
|
|
} else {
|
|
c.Flags.Unset(1)
|
|
c.Self = false
|
|
}
|
|
}
|
|
|
|
// GetSelf returns value of Self conditional field.
|
|
func (c *ChannelParticipantAdmin) GetSelf() (value bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Flags.Has(1)
|
|
}
|
|
|
|
// GetUserID returns value of UserID field.
|
|
func (c *ChannelParticipantAdmin) GetUserID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.UserID
|
|
}
|
|
|
|
// SetInviterID sets value of InviterID conditional field.
|
|
func (c *ChannelParticipantAdmin) SetInviterID(value int64) {
|
|
c.Flags.Set(1)
|
|
c.InviterID = value
|
|
}
|
|
|
|
// GetInviterID returns value of InviterID conditional field and
|
|
// boolean which is true if field was set.
|
|
func (c *ChannelParticipantAdmin) GetInviterID() (value int64, ok bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
if !c.Flags.Has(1) {
|
|
return value, false
|
|
}
|
|
return c.InviterID, true
|
|
}
|
|
|
|
// GetPromotedBy returns value of PromotedBy field.
|
|
func (c *ChannelParticipantAdmin) GetPromotedBy() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.PromotedBy
|
|
}
|
|
|
|
// GetDate returns value of Date field.
|
|
func (c *ChannelParticipantAdmin) GetDate() (value int) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Date
|
|
}
|
|
|
|
// GetAdminRights returns value of AdminRights field.
|
|
func (c *ChannelParticipantAdmin) GetAdminRights() (value ChatAdminRights) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.AdminRights
|
|
}
|
|
|
|
// SetRank sets value of Rank conditional field.
|
|
func (c *ChannelParticipantAdmin) SetRank(value string) {
|
|
c.Flags.Set(2)
|
|
c.Rank = value
|
|
}
|
|
|
|
// GetRank returns value of Rank conditional field and
|
|
// boolean which is true if field was set.
|
|
func (c *ChannelParticipantAdmin) GetRank() (value string, ok bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
if !c.Flags.Has(2) {
|
|
return value, false
|
|
}
|
|
return c.Rank, true
|
|
}
|
|
|
|
// ChannelParticipantBanned represents TL type `channelParticipantBanned#6df8014e`.
|
|
// Banned/kicked user
|
|
//
|
|
// See https://core.telegram.org/constructor/channelParticipantBanned for reference.
|
|
type ChannelParticipantBanned struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// Whether the user has left the group
|
|
Left bool
|
|
// The banned peer
|
|
Peer PeerClass
|
|
// User was kicked by the specified admin
|
|
KickedBy int64
|
|
// When did the user join the group
|
|
Date int
|
|
// Banned rights¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/rights
|
|
BannedRights ChatBannedRights
|
|
}
|
|
|
|
// ChannelParticipantBannedTypeID is TL type id of ChannelParticipantBanned.
|
|
const ChannelParticipantBannedTypeID = 0x6df8014e
|
|
|
|
// construct implements constructor of ChannelParticipantClass.
|
|
func (c ChannelParticipantBanned) construct() ChannelParticipantClass { return &c }
|
|
|
|
// Ensuring interfaces in compile-time for ChannelParticipantBanned.
|
|
var (
|
|
_ bin.Encoder = &ChannelParticipantBanned{}
|
|
_ bin.Decoder = &ChannelParticipantBanned{}
|
|
_ bin.BareEncoder = &ChannelParticipantBanned{}
|
|
_ bin.BareDecoder = &ChannelParticipantBanned{}
|
|
|
|
_ ChannelParticipantClass = &ChannelParticipantBanned{}
|
|
)
|
|
|
|
func (c *ChannelParticipantBanned) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.Left == false) {
|
|
return false
|
|
}
|
|
if !(c.Peer == nil) {
|
|
return false
|
|
}
|
|
if !(c.KickedBy == 0) {
|
|
return false
|
|
}
|
|
if !(c.Date == 0) {
|
|
return false
|
|
}
|
|
if !(c.BannedRights.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChannelParticipantBanned) String() string {
|
|
if c == nil {
|
|
return "ChannelParticipantBanned(nil)"
|
|
}
|
|
type Alias ChannelParticipantBanned
|
|
return fmt.Sprintf("ChannelParticipantBanned%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills ChannelParticipantBanned from given interface.
|
|
func (c *ChannelParticipantBanned) FillFrom(from interface {
|
|
GetLeft() (value bool)
|
|
GetPeer() (value PeerClass)
|
|
GetKickedBy() (value int64)
|
|
GetDate() (value int)
|
|
GetBannedRights() (value ChatBannedRights)
|
|
}) {
|
|
c.Left = from.GetLeft()
|
|
c.Peer = from.GetPeer()
|
|
c.KickedBy = from.GetKickedBy()
|
|
c.Date = from.GetDate()
|
|
c.BannedRights = from.GetBannedRights()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChannelParticipantBanned) TypeID() uint32 {
|
|
return ChannelParticipantBannedTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChannelParticipantBanned) TypeName() string {
|
|
return "channelParticipantBanned"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChannelParticipantBanned) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "channelParticipantBanned",
|
|
ID: ChannelParticipantBannedTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Left",
|
|
SchemaName: "left",
|
|
Null: !c.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "Peer",
|
|
SchemaName: "peer",
|
|
},
|
|
{
|
|
Name: "KickedBy",
|
|
SchemaName: "kicked_by",
|
|
},
|
|
{
|
|
Name: "Date",
|
|
SchemaName: "date",
|
|
},
|
|
{
|
|
Name: "BannedRights",
|
|
SchemaName: "banned_rights",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (c *ChannelParticipantBanned) SetFlags() {
|
|
if !(c.Left == false) {
|
|
c.Flags.Set(0)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChannelParticipantBanned) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantBanned#6df8014e as nil")
|
|
}
|
|
b.PutID(ChannelParticipantBannedTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChannelParticipantBanned) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantBanned#6df8014e as nil")
|
|
}
|
|
c.SetFlags()
|
|
if err := c.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipantBanned#6df8014e: field flags: %w", err)
|
|
}
|
|
if c.Peer == nil {
|
|
return fmt.Errorf("unable to encode channelParticipantBanned#6df8014e: field peer is nil")
|
|
}
|
|
if err := c.Peer.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipantBanned#6df8014e: field peer: %w", err)
|
|
}
|
|
b.PutLong(c.KickedBy)
|
|
b.PutInt(c.Date)
|
|
if err := c.BannedRights.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipantBanned#6df8014e: field banned_rights: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChannelParticipantBanned) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantBanned#6df8014e to nil")
|
|
}
|
|
if err := b.ConsumeID(ChannelParticipantBannedTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChannelParticipantBanned) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantBanned#6df8014e to nil")
|
|
}
|
|
{
|
|
if err := c.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field flags: %w", err)
|
|
}
|
|
}
|
|
c.Left = c.Flags.Has(0)
|
|
{
|
|
value, err := DecodePeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field peer: %w", err)
|
|
}
|
|
c.Peer = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field kicked_by: %w", err)
|
|
}
|
|
c.KickedBy = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field date: %w", err)
|
|
}
|
|
c.Date = value
|
|
}
|
|
{
|
|
if err := c.BannedRights.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field banned_rights: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetLeft sets value of Left conditional field.
|
|
func (c *ChannelParticipantBanned) SetLeft(value bool) {
|
|
if value {
|
|
c.Flags.Set(0)
|
|
c.Left = true
|
|
} else {
|
|
c.Flags.Unset(0)
|
|
c.Left = false
|
|
}
|
|
}
|
|
|
|
// GetLeft returns value of Left conditional field.
|
|
func (c *ChannelParticipantBanned) GetLeft() (value bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Flags.Has(0)
|
|
}
|
|
|
|
// GetPeer returns value of Peer field.
|
|
func (c *ChannelParticipantBanned) GetPeer() (value PeerClass) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Peer
|
|
}
|
|
|
|
// GetKickedBy returns value of KickedBy field.
|
|
func (c *ChannelParticipantBanned) GetKickedBy() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.KickedBy
|
|
}
|
|
|
|
// GetDate returns value of Date field.
|
|
func (c *ChannelParticipantBanned) GetDate() (value int) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Date
|
|
}
|
|
|
|
// GetBannedRights returns value of BannedRights field.
|
|
func (c *ChannelParticipantBanned) GetBannedRights() (value ChatBannedRights) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.BannedRights
|
|
}
|
|
|
|
// ChannelParticipantLeft represents TL type `channelParticipantLeft#1b03f006`.
|
|
// A participant that left the channel/supergroup
|
|
//
|
|
// See https://core.telegram.org/constructor/channelParticipantLeft for reference.
|
|
type ChannelParticipantLeft struct {
|
|
// The peer that left
|
|
Peer PeerClass
|
|
}
|
|
|
|
// ChannelParticipantLeftTypeID is TL type id of ChannelParticipantLeft.
|
|
const ChannelParticipantLeftTypeID = 0x1b03f006
|
|
|
|
// construct implements constructor of ChannelParticipantClass.
|
|
func (c ChannelParticipantLeft) construct() ChannelParticipantClass { return &c }
|
|
|
|
// Ensuring interfaces in compile-time for ChannelParticipantLeft.
|
|
var (
|
|
_ bin.Encoder = &ChannelParticipantLeft{}
|
|
_ bin.Decoder = &ChannelParticipantLeft{}
|
|
_ bin.BareEncoder = &ChannelParticipantLeft{}
|
|
_ bin.BareDecoder = &ChannelParticipantLeft{}
|
|
|
|
_ ChannelParticipantClass = &ChannelParticipantLeft{}
|
|
)
|
|
|
|
func (c *ChannelParticipantLeft) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.Peer == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChannelParticipantLeft) String() string {
|
|
if c == nil {
|
|
return "ChannelParticipantLeft(nil)"
|
|
}
|
|
type Alias ChannelParticipantLeft
|
|
return fmt.Sprintf("ChannelParticipantLeft%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills ChannelParticipantLeft from given interface.
|
|
func (c *ChannelParticipantLeft) FillFrom(from interface {
|
|
GetPeer() (value PeerClass)
|
|
}) {
|
|
c.Peer = from.GetPeer()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChannelParticipantLeft) TypeID() uint32 {
|
|
return ChannelParticipantLeftTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChannelParticipantLeft) TypeName() string {
|
|
return "channelParticipantLeft"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChannelParticipantLeft) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "channelParticipantLeft",
|
|
ID: ChannelParticipantLeftTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Peer",
|
|
SchemaName: "peer",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChannelParticipantLeft) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantLeft#1b03f006 as nil")
|
|
}
|
|
b.PutID(ChannelParticipantLeftTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChannelParticipantLeft) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode channelParticipantLeft#1b03f006 as nil")
|
|
}
|
|
if c.Peer == nil {
|
|
return fmt.Errorf("unable to encode channelParticipantLeft#1b03f006: field peer is nil")
|
|
}
|
|
if err := c.Peer.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channelParticipantLeft#1b03f006: field peer: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChannelParticipantLeft) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantLeft#1b03f006 to nil")
|
|
}
|
|
if err := b.ConsumeID(ChannelParticipantLeftTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantLeft#1b03f006: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChannelParticipantLeft) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode channelParticipantLeft#1b03f006 to nil")
|
|
}
|
|
{
|
|
value, err := DecodePeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channelParticipantLeft#1b03f006: field peer: %w", err)
|
|
}
|
|
c.Peer = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetPeer returns value of Peer field.
|
|
func (c *ChannelParticipantLeft) GetPeer() (value PeerClass) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Peer
|
|
}
|
|
|
|
// ChannelParticipantClassName is schema name of ChannelParticipantClass.
|
|
const ChannelParticipantClassName = "ChannelParticipant"
|
|
|
|
// ChannelParticipantClass represents ChannelParticipant generic type.
|
|
//
|
|
// See https://core.telegram.org/type/ChannelParticipant for reference.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tg.DecodeChannelParticipant(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tg.ChannelParticipant: // channelParticipant#cb397619
|
|
// case *tg.ChannelParticipantSelf: // channelParticipantSelf#4f607bef
|
|
// case *tg.ChannelParticipantCreator: // channelParticipantCreator#2fe601d3
|
|
// case *tg.ChannelParticipantAdmin: // channelParticipantAdmin#34c3bb53
|
|
// case *tg.ChannelParticipantBanned: // channelParticipantBanned#6df8014e
|
|
// case *tg.ChannelParticipantLeft: // channelParticipantLeft#1b03f006
|
|
// default: panic(v)
|
|
// }
|
|
type ChannelParticipantClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() ChannelParticipantClass
|
|
|
|
// 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
|
|
}
|
|
|
|
// DecodeChannelParticipant implements binary de-serialization for ChannelParticipantClass.
|
|
func DecodeChannelParticipant(buf *bin.Buffer) (ChannelParticipantClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case ChannelParticipantTypeID:
|
|
// Decoding channelParticipant#cb397619.
|
|
v := ChannelParticipant{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case ChannelParticipantSelfTypeID:
|
|
// Decoding channelParticipantSelf#4f607bef.
|
|
v := ChannelParticipantSelf{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case ChannelParticipantCreatorTypeID:
|
|
// Decoding channelParticipantCreator#2fe601d3.
|
|
v := ChannelParticipantCreator{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case ChannelParticipantAdminTypeID:
|
|
// Decoding channelParticipantAdmin#34c3bb53.
|
|
v := ChannelParticipantAdmin{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case ChannelParticipantBannedTypeID:
|
|
// Decoding channelParticipantBanned#6df8014e.
|
|
v := ChannelParticipantBanned{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case ChannelParticipantLeftTypeID:
|
|
// Decoding channelParticipantLeft#1b03f006.
|
|
v := ChannelParticipantLeft{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// ChannelParticipant boxes the ChannelParticipantClass providing a helper.
|
|
type ChannelParticipantBox struct {
|
|
ChannelParticipant ChannelParticipantClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for ChannelParticipantBox.
|
|
func (b *ChannelParticipantBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode ChannelParticipantBox to nil")
|
|
}
|
|
v, err := DecodeChannelParticipant(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.ChannelParticipant = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for ChannelParticipantBox.
|
|
func (b *ChannelParticipantBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.ChannelParticipant == nil {
|
|
return fmt.Errorf("unable to encode ChannelParticipantClass as nil")
|
|
}
|
|
return b.ChannelParticipant.Encode(buf)
|
|
}
|