You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2920 lines
64 KiB

// 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{}
)
// ChatEmpty represents TL type `chatEmpty#29562865`.
// Empty constructor, group doesn't exist
//
// See https://core.telegram.org/constructor/chatEmpty for reference.
type ChatEmpty struct {
// Group identifier
ID int64
}
// ChatEmptyTypeID is TL type id of ChatEmpty.
const ChatEmptyTypeID = 0x29562865
// construct implements constructor of ChatClass.
func (c ChatEmpty) construct() ChatClass { return &c }
// Ensuring interfaces in compile-time for ChatEmpty.
var (
_ bin.Encoder = &ChatEmpty{}
_ bin.Decoder = &ChatEmpty{}
_ bin.BareEncoder = &ChatEmpty{}
_ bin.BareDecoder = &ChatEmpty{}
_ ChatClass = &ChatEmpty{}
)
func (c *ChatEmpty) Zero() bool {
if c == nil {
return true
}
if !(c.ID == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *ChatEmpty) String() string {
if c == nil {
return "ChatEmpty(nil)"
}
type Alias ChatEmpty
return fmt.Sprintf("ChatEmpty%+v", Alias(*c))
}
// FillFrom fills ChatEmpty from given interface.
func (c *ChatEmpty) FillFrom(from interface {
GetID() (value int64)
}) {
c.ID = from.GetID()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChatEmpty) TypeID() uint32 {
return ChatEmptyTypeID
}
// TypeName returns name of type in TL schema.
func (*ChatEmpty) TypeName() string {
return "chatEmpty"
}
// TypeInfo returns info about TL type.
func (c *ChatEmpty) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "chatEmpty",
ID: ChatEmptyTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ID",
SchemaName: "id",
},
}
return typ
}
// Encode implements bin.Encoder.
func (c *ChatEmpty) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatEmpty#29562865 as nil")
}
b.PutID(ChatEmptyTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *ChatEmpty) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatEmpty#29562865 as nil")
}
b.PutLong(c.ID)
return nil
}
// Decode implements bin.Decoder.
func (c *ChatEmpty) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatEmpty#29562865 to nil")
}
if err := b.ConsumeID(ChatEmptyTypeID); err != nil {
return fmt.Errorf("unable to decode chatEmpty#29562865: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *ChatEmpty) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatEmpty#29562865 to nil")
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode chatEmpty#29562865: field id: %w", err)
}
c.ID = value
}
return nil
}
// GetID returns value of ID field.
func (c *ChatEmpty) GetID() (value int64) {
if c == nil {
return
}
return c.ID
}
// Chat represents TL type `chat#41cbf256`.
// Info about a group
//
// See https://core.telegram.org/constructor/chat for reference.
type Chat struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether the current user is the creator of the group
Creator bool
// Whether the current user was kicked from the group
Kicked bool
// Whether the current user has left the group
Left bool
// Whether the group was migrated¹
//
// Links:
// 1) https://core.telegram.org/api/channel
Deactivated bool
// Whether a group call is currently active
CallActive bool
// Whether there's anyone in the group call
CallNotEmpty bool
// Noforwards field of Chat.
Noforwards bool
// ID of the group
ID int64
// Title
Title string
// Chat photo
Photo ChatPhotoClass
// Participant count
ParticipantsCount int
// Date of creation of the group
Date int
// Used in basic groups to reorder updates and make sure that all of them were received.
Version int
// Means this chat was upgraded¹ to a supergroup
//
// Links:
// 1) https://core.telegram.org/api/channel
//
// Use SetMigratedTo and GetMigratedTo helpers.
MigratedTo InputChannelClass
// Admin rights¹ of the user in the group
//
// Links:
// 1) https://core.telegram.org/api/rights
//
// Use SetAdminRights and GetAdminRights helpers.
AdminRights ChatAdminRights
// Default banned rights¹ of all users in the group
//
// Links:
// 1) https://core.telegram.org/api/rights
//
// Use SetDefaultBannedRights and GetDefaultBannedRights helpers.
DefaultBannedRights ChatBannedRights
}
// ChatTypeID is TL type id of Chat.
const ChatTypeID = 0x41cbf256
// construct implements constructor of ChatClass.
func (c Chat) construct() ChatClass { return &c }
// Ensuring interfaces in compile-time for Chat.
var (
_ bin.Encoder = &Chat{}
_ bin.Decoder = &Chat{}
_ bin.BareEncoder = &Chat{}
_ bin.BareDecoder = &Chat{}
_ ChatClass = &Chat{}
)
func (c *Chat) Zero() bool {
if c == nil {
return true
}
if !(c.Flags.Zero()) {
return false
}
if !(c.Creator == false) {
return false
}
if !(c.Kicked == false) {
return false
}
if !(c.Left == false) {
return false
}
if !(c.Deactivated == false) {
return false
}
if !(c.CallActive == false) {
return false
}
if !(c.CallNotEmpty == false) {
return false
}
if !(c.Noforwards == false) {
return false
}
if !(c.ID == 0) {
return false
}
if !(c.Title == "") {
return false
}
if !(c.Photo == nil) {
return false
}
if !(c.ParticipantsCount == 0) {
return false
}
if !(c.Date == 0) {
return false
}
if !(c.Version == 0) {
return false
}
if !(c.MigratedTo == nil) {
return false
}
if !(c.AdminRights.Zero()) {
return false
}
if !(c.DefaultBannedRights.Zero()) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *Chat) String() string {
if c == nil {
return "Chat(nil)"
}
type Alias Chat
return fmt.Sprintf("Chat%+v", Alias(*c))
}
// FillFrom fills Chat from given interface.
func (c *Chat) FillFrom(from interface {
GetCreator() (value bool)
GetKicked() (value bool)
GetLeft() (value bool)
GetDeactivated() (value bool)
GetCallActive() (value bool)
GetCallNotEmpty() (value bool)
GetNoforwards() (value bool)
GetID() (value int64)
GetTitle() (value string)
GetPhoto() (value ChatPhotoClass)
GetParticipantsCount() (value int)
GetDate() (value int)
GetVersion() (value int)
GetMigratedTo() (value InputChannelClass, ok bool)
GetAdminRights() (value ChatAdminRights, ok bool)
GetDefaultBannedRights() (value ChatBannedRights, ok bool)
}) {
c.Creator = from.GetCreator()
c.Kicked = from.GetKicked()
c.Left = from.GetLeft()
c.Deactivated = from.GetDeactivated()
c.CallActive = from.GetCallActive()
c.CallNotEmpty = from.GetCallNotEmpty()
c.Noforwards = from.GetNoforwards()
c.ID = from.GetID()
c.Title = from.GetTitle()
c.Photo = from.GetPhoto()
c.ParticipantsCount = from.GetParticipantsCount()
c.Date = from.GetDate()
c.Version = from.GetVersion()
if val, ok := from.GetMigratedTo(); ok {
c.MigratedTo = val
}
if val, ok := from.GetAdminRights(); ok {
c.AdminRights = val
}
if val, ok := from.GetDefaultBannedRights(); ok {
c.DefaultBannedRights = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*Chat) TypeID() uint32 {
return ChatTypeID
}
// TypeName returns name of type in TL schema.
func (*Chat) TypeName() string {
return "chat"
}
// TypeInfo returns info about TL type.
func (c *Chat) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "chat",
ID: ChatTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Creator",
SchemaName: "creator",
Null: !c.Flags.Has(0),
},
{
Name: "Kicked",
SchemaName: "kicked",
Null: !c.Flags.Has(1),
},
{
Name: "Left",
SchemaName: "left",
Null: !c.Flags.Has(2),
},
{
Name: "Deactivated",
SchemaName: "deactivated",
Null: !c.Flags.Has(5),
},
{
Name: "CallActive",
SchemaName: "call_active",
Null: !c.Flags.Has(23),
},
{
Name: "CallNotEmpty",
SchemaName: "call_not_empty",
Null: !c.Flags.Has(24),
},
{
Name: "Noforwards",
SchemaName: "noforwards",
Null: !c.Flags.Has(25),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "Title",
SchemaName: "title",
},
{
Name: "Photo",
SchemaName: "photo",
},
{
Name: "ParticipantsCount",
SchemaName: "participants_count",
},
{
Name: "Date",
SchemaName: "date",
},
{
Name: "Version",
SchemaName: "version",
},
{
Name: "MigratedTo",
SchemaName: "migrated_to",
Null: !c.Flags.Has(6),
},
{
Name: "AdminRights",
SchemaName: "admin_rights",
Null: !c.Flags.Has(14),
},
{
Name: "DefaultBannedRights",
SchemaName: "default_banned_rights",
Null: !c.Flags.Has(18),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (c *Chat) SetFlags() {
if !(c.Creator == false) {
c.Flags.Set(0)
}
if !(c.Kicked == false) {
c.Flags.Set(1)
}
if !(c.Left == false) {
c.Flags.Set(2)
}
if !(c.Deactivated == false) {
c.Flags.Set(5)
}
if !(c.CallActive == false) {
c.Flags.Set(23)
}
if !(c.CallNotEmpty == false) {
c.Flags.Set(24)
}
if !(c.Noforwards == false) {
c.Flags.Set(25)
}
if !(c.MigratedTo == nil) {
c.Flags.Set(6)
}
if !(c.AdminRights.Zero()) {
c.Flags.Set(14)
}
if !(c.DefaultBannedRights.Zero()) {
c.Flags.Set(18)
}
}
// Encode implements bin.Encoder.
func (c *Chat) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chat#41cbf256 as nil")
}
b.PutID(ChatTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *Chat) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chat#41cbf256 as nil")
}
c.SetFlags()
if err := c.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode chat#41cbf256: field flags: %w", err)
}
b.PutLong(c.ID)
b.PutString(c.Title)
if c.Photo == nil {
return fmt.Errorf("unable to encode chat#41cbf256: field photo is nil")
}
if err := c.Photo.Encode(b); err != nil {
return fmt.Errorf("unable to encode chat#41cbf256: field photo: %w", err)
}
b.PutInt(c.ParticipantsCount)
b.PutInt(c.Date)
b.PutInt(c.Version)
if c.Flags.Has(6) {
if c.MigratedTo == nil {
return fmt.Errorf("unable to encode chat#41cbf256: field migrated_to is nil")
}
if err := c.MigratedTo.Encode(b); err != nil {
return fmt.Errorf("unable to encode chat#41cbf256: field migrated_to: %w", err)
}
}
if c.Flags.Has(14) {
if err := c.AdminRights.Encode(b); err != nil {
return fmt.Errorf("unable to encode chat#41cbf256: field admin_rights: %w", err)
}
}
if c.Flags.Has(18) {
if err := c.DefaultBannedRights.Encode(b); err != nil {
return fmt.Errorf("unable to encode chat#41cbf256: field default_banned_rights: %w", err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (c *Chat) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chat#41cbf256 to nil")
}
if err := b.ConsumeID(ChatTypeID); err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *Chat) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chat#41cbf256 to nil")
}
{
if err := c.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field flags: %w", err)
}
}
c.Creator = c.Flags.Has(0)
c.Kicked = c.Flags.Has(1)
c.Left = c.Flags.Has(2)
c.Deactivated = c.Flags.Has(5)
c.CallActive = c.Flags.Has(23)
c.CallNotEmpty = c.Flags.Has(24)
c.Noforwards = c.Flags.Has(25)
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field id: %w", err)
}
c.ID = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field title: %w", err)
}
c.Title = value
}
{
value, err := DecodeChatPhoto(b)
if err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field photo: %w", err)
}
c.Photo = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field participants_count: %w", err)
}
c.ParticipantsCount = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field date: %w", err)
}
c.Date = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field version: %w", err)
}
c.Version = value
}
if c.Flags.Has(6) {
value, err := DecodeInputChannel(b)
if err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field migrated_to: %w", err)
}
c.MigratedTo = value
}
if c.Flags.Has(14) {
if err := c.AdminRights.Decode(b); err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field admin_rights: %w", err)
}
}
if c.Flags.Has(18) {
if err := c.DefaultBannedRights.Decode(b); err != nil {
return fmt.Errorf("unable to decode chat#41cbf256: field default_banned_rights: %w", err)
}
}
return nil
}
// SetCreator sets value of Creator conditional field.
func (c *Chat) SetCreator(value bool) {
if value {
c.Flags.Set(0)
c.Creator = true
} else {
c.Flags.Unset(0)
c.Creator = false
}
}
// GetCreator returns value of Creator conditional field.
func (c *Chat) GetCreator() (value bool) {
if c == nil {
return
}
return c.Flags.Has(0)
}
// SetKicked sets value of Kicked conditional field.
func (c *Chat) SetKicked(value bool) {
if value {
c.Flags.Set(1)
c.Kicked = true
} else {
c.Flags.Unset(1)
c.Kicked = false
}
}
// GetKicked returns value of Kicked conditional field.
func (c *Chat) GetKicked() (value bool) {
if c == nil {
return
}
return c.Flags.Has(1)
}
// SetLeft sets value of Left conditional field.
func (c *Chat) SetLeft(value bool) {
if value {
c.Flags.Set(2)
c.Left = true
} else {
c.Flags.Unset(2)
c.Left = false
}
}
// GetLeft returns value of Left conditional field.
func (c *Chat) GetLeft() (value bool) {
if c == nil {
return
}
return c.Flags.Has(2)
}
// SetDeactivated sets value of Deactivated conditional field.
func (c *Chat) SetDeactivated(value bool) {
if value {
c.Flags.Set(5)
c.Deactivated = true
} else {
c.Flags.Unset(5)
c.Deactivated = false
}
}
// GetDeactivated returns value of Deactivated conditional field.
func (c *Chat) GetDeactivated() (value bool) {
if c == nil {
return
}
return c.Flags.Has(5)
}
// SetCallActive sets value of CallActive conditional field.
func (c *Chat) SetCallActive(value bool) {
if value {
c.Flags.Set(23)
c.CallActive = true
} else {
c.Flags.Unset(23)
c.CallActive = false
}
}
// GetCallActive returns value of CallActive conditional field.
func (c *Chat) GetCallActive() (value bool) {
if c == nil {
return
}
return c.Flags.Has(23)
}
// SetCallNotEmpty sets value of CallNotEmpty conditional field.
func (c *Chat) SetCallNotEmpty(value bool) {
if value {
c.Flags.Set(24)
c.CallNotEmpty = true
} else {
c.Flags.Unset(24)
c.CallNotEmpty = false
}
}
// GetCallNotEmpty returns value of CallNotEmpty conditional field.
func (c *Chat) GetCallNotEmpty() (value bool) {
if c == nil {
return
}
return c.Flags.Has(24)
}
// SetNoforwards sets value of Noforwards conditional field.
func (c *Chat) SetNoforwards(value bool) {
if value {
c.Flags.Set(25)
c.Noforwards = true
} else {
c.Flags.Unset(25)
c.Noforwards = false
}
}
// GetNoforwards returns value of Noforwards conditional field.
func (c *Chat) GetNoforwards() (value bool) {
if c == nil {
return
}
return c.Flags.Has(25)
}
// GetID returns value of ID field.
func (c *Chat) GetID() (value int64) {
if c == nil {
return
}
return c.ID
}
// GetTitle returns value of Title field.
func (c *Chat) GetTitle() (value string) {
if c == nil {
return
}
return c.Title
}
// GetPhoto returns value of Photo field.
func (c *Chat) GetPhoto() (value ChatPhotoClass) {
if c == nil {
return
}
return c.Photo
}
// GetParticipantsCount returns value of ParticipantsCount field.
func (c *Chat) GetParticipantsCount() (value int) {
if c == nil {
return
}
return c.ParticipantsCount
}
// GetDate returns value of Date field.
func (c *Chat) GetDate() (value int) {
if c == nil {
return
}
return c.Date
}
// GetVersion returns value of Version field.
func (c *Chat) GetVersion() (value int) {
if c == nil {
return
}
return c.Version
}
// SetMigratedTo sets value of MigratedTo conditional field.
func (c *Chat) SetMigratedTo(value InputChannelClass) {
c.Flags.Set(6)
c.MigratedTo = value
}
// GetMigratedTo returns value of MigratedTo conditional field and
// boolean which is true if field was set.
func (c *Chat) GetMigratedTo() (value InputChannelClass, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(6) {
return value, false
}
return c.MigratedTo, true
}
// SetAdminRights sets value of AdminRights conditional field.
func (c *Chat) SetAdminRights(value ChatAdminRights) {
c.Flags.Set(14)
c.AdminRights = value
}
// GetAdminRights returns value of AdminRights conditional field and
// boolean which is true if field was set.
func (c *Chat) GetAdminRights() (value ChatAdminRights, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(14) {
return value, false
}
return c.AdminRights, true
}
// SetDefaultBannedRights sets value of DefaultBannedRights conditional field.
func (c *Chat) SetDefaultBannedRights(value ChatBannedRights) {
c.Flags.Set(18)
c.DefaultBannedRights = value
}
// GetDefaultBannedRights returns value of DefaultBannedRights conditional field and
// boolean which is true if field was set.
func (c *Chat) GetDefaultBannedRights() (value ChatBannedRights, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(18) {
return value, false
}
return c.DefaultBannedRights, true
}
// ChatForbidden represents TL type `chatForbidden#6592a1a7`.
// A group to which the user has no access. E.g., because the user was kicked from the
// group.
//
// See https://core.telegram.org/constructor/chatForbidden for reference.
type ChatForbidden struct {
// User identifier
ID int64
// Group name
Title string
}
// ChatForbiddenTypeID is TL type id of ChatForbidden.
const ChatForbiddenTypeID = 0x6592a1a7
// construct implements constructor of ChatClass.
func (c ChatForbidden) construct() ChatClass { return &c }
// Ensuring interfaces in compile-time for ChatForbidden.
var (
_ bin.Encoder = &ChatForbidden{}
_ bin.Decoder = &ChatForbidden{}
_ bin.BareEncoder = &ChatForbidden{}
_ bin.BareDecoder = &ChatForbidden{}
_ ChatClass = &ChatForbidden{}
)
func (c *ChatForbidden) Zero() bool {
if c == nil {
return true
}
if !(c.ID == 0) {
return false
}
if !(c.Title == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *ChatForbidden) String() string {
if c == nil {
return "ChatForbidden(nil)"
}
type Alias ChatForbidden
return fmt.Sprintf("ChatForbidden%+v", Alias(*c))
}
// FillFrom fills ChatForbidden from given interface.
func (c *ChatForbidden) FillFrom(from interface {
GetID() (value int64)
GetTitle() (value string)
}) {
c.ID = from.GetID()
c.Title = from.GetTitle()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChatForbidden) TypeID() uint32 {
return ChatForbiddenTypeID
}
// TypeName returns name of type in TL schema.
func (*ChatForbidden) TypeName() string {
return "chatForbidden"
}
// TypeInfo returns info about TL type.
func (c *ChatForbidden) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "chatForbidden",
ID: ChatForbiddenTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ID",
SchemaName: "id",
},
{
Name: "Title",
SchemaName: "title",
},
}
return typ
}
// Encode implements bin.Encoder.
func (c *ChatForbidden) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatForbidden#6592a1a7 as nil")
}
b.PutID(ChatForbiddenTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *ChatForbidden) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatForbidden#6592a1a7 as nil")
}
b.PutLong(c.ID)
b.PutString(c.Title)
return nil
}
// Decode implements bin.Decoder.
func (c *ChatForbidden) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatForbidden#6592a1a7 to nil")
}
if err := b.ConsumeID(ChatForbiddenTypeID); err != nil {
return fmt.Errorf("unable to decode chatForbidden#6592a1a7: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *ChatForbidden) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatForbidden#6592a1a7 to nil")
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode chatForbidden#6592a1a7: field id: %w", err)
}
c.ID = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode chatForbidden#6592a1a7: field title: %w", err)
}
c.Title = value
}
return nil
}
// GetID returns value of ID field.
func (c *ChatForbidden) GetID() (value int64) {
if c == nil {
return
}
return c.ID
}
// GetTitle returns value of Title field.
func (c *ChatForbidden) GetTitle() (value string) {
if c == nil {
return
}
return c.Title
}
// Channel represents TL type `channel#8261ac61`.
// Channel/supergroup info
//
// See https://core.telegram.org/constructor/channel for reference.
type Channel struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether the current user is the creator of this channel
Creator bool
// Whether the current user has left this channel
Left bool
// Is this a channel?
Broadcast bool
// Is this channel verified by telegram?
Verified bool
// Is this a supergroup?
Megagroup bool
// Whether viewing/writing in this channel for a reason (see restriction_reason
Restricted bool
// Whether signatures are enabled (channels)
Signatures bool
// See min¹
//
// Links:
// 1) https://core.telegram.org/api/min
Min bool
// This channel/supergroup is probably a scam
Scam bool
// Whether this channel has a private join link
HasLink bool
// Whether this chanel has a geoposition
HasGeo bool
// Whether slow mode is enabled for groups to prevent flood in chat
SlowmodeEnabled bool
// Whether a group call or livestream is currently active
CallActive bool
// Whether there's anyone in the group call or livestream
CallNotEmpty bool
// If set, this supergroup/channel¹ was reported by many users as a fake or scam: be
// careful when interacting with it.
//
// Links:
// 1) https://core.telegram.org/api/channel
Fake bool
// Whether this supergroup¹ is a gigagroup
//
// Links:
// 1) https://core.telegram.org/api/channel
Gigagroup bool
// Noforwards field of Channel.
Noforwards bool
// ID of the channel
ID int64
// Access hash
//
// Use SetAccessHash and GetAccessHash helpers.
AccessHash int64
// Title
Title string
// Username
//
// Use SetUsername and GetUsername helpers.
Username string
// Profile photo
Photo ChatPhotoClass
// Date when the user joined the supergroup/channel, or if the user isn't a member, its
// creation date
Date int
// Contains the reason why access to this channel must be restricted.
//
// Use SetRestrictionReason and GetRestrictionReason helpers.
RestrictionReason []RestrictionReason
// Admin rights of the user in this channel (see rights¹)
//
// Links:
// 1) https://core.telegram.org/api/rights
//
// Use SetAdminRights and GetAdminRights helpers.
AdminRights ChatAdminRights
// Banned rights of the user in this channel (see rights¹)
//
// Links:
// 1) https://core.telegram.org/api/rights
//
// Use SetBannedRights and GetBannedRights helpers.
BannedRights ChatBannedRights
// Default chat rights (see rights¹)
//
// Links:
// 1) https://core.telegram.org/api/rights
//
// Use SetDefaultBannedRights and GetDefaultBannedRights helpers.
DefaultBannedRights ChatBannedRights
// Participant count
//
// Use SetParticipantsCount and GetParticipantsCount helpers.
ParticipantsCount int
}
// ChannelTypeID is TL type id of Channel.
const ChannelTypeID = 0x8261ac61
// construct implements constructor of ChatClass.
func (c Channel) construct() ChatClass { return &c }
// Ensuring interfaces in compile-time for Channel.
var (
_ bin.Encoder = &Channel{}
_ bin.Decoder = &Channel{}
_ bin.BareEncoder = &Channel{}
_ bin.BareDecoder = &Channel{}
_ ChatClass = &Channel{}
)
func (c *Channel) Zero() bool {
if c == nil {
return true
}
if !(c.Flags.Zero()) {
return false
}
if !(c.Creator == false) {
return false
}
if !(c.Left == false) {
return false
}
if !(c.Broadcast == false) {
return false
}
if !(c.Verified == false) {
return false
}
if !(c.Megagroup == false) {
return false
}
if !(c.Restricted == false) {
return false
}
if !(c.Signatures == false) {
return false
}
if !(c.Min == false) {
return false
}
if !(c.Scam == false) {
return false
}
if !(c.HasLink == false) {
return false
}
if !(c.HasGeo == false) {
return false
}
if !(c.SlowmodeEnabled == false) {
return false
}
if !(c.CallActive == false) {
return false
}
if !(c.CallNotEmpty == false) {
return false
}
if !(c.Fake == false) {
return false
}
if !(c.Gigagroup == false) {
return false
}
if !(c.Noforwards == false) {
return false
}
if !(c.ID == 0) {
return false
}
if !(c.AccessHash == 0) {
return false
}
if !(c.Title == "") {
return false
}
if !(c.Username == "") {
return false
}
if !(c.Photo == nil) {
return false
}
if !(c.Date == 0) {
return false
}
if !(c.RestrictionReason == nil) {
return false
}
if !(c.AdminRights.Zero()) {
return false
}
if !(c.BannedRights.Zero()) {
return false
}
if !(c.DefaultBannedRights.Zero()) {
return false
}
if !(c.ParticipantsCount == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *Channel) String() string {
if c == nil {
return "Channel(nil)"
}
type Alias Channel
return fmt.Sprintf("Channel%+v", Alias(*c))
}
// FillFrom fills Channel from given interface.
func (c *Channel) FillFrom(from interface {
GetCreator() (value bool)
GetLeft() (value bool)
GetBroadcast() (value bool)
GetVerified() (value bool)
GetMegagroup() (value bool)
GetRestricted() (value bool)
GetSignatures() (value bool)
GetMin() (value bool)
GetScam() (value bool)
GetHasLink() (value bool)
GetHasGeo() (value bool)
GetSlowmodeEnabled() (value bool)
GetCallActive() (value bool)
GetCallNotEmpty() (value bool)
GetFake() (value bool)
GetGigagroup() (value bool)
GetNoforwards() (value bool)
GetID() (value int64)
GetAccessHash() (value int64, ok bool)
GetTitle() (value string)
GetUsername() (value string, ok bool)
GetPhoto() (value ChatPhotoClass)
GetDate() (value int)
GetRestrictionReason() (value []RestrictionReason, ok bool)
GetAdminRights() (value ChatAdminRights, ok bool)
GetBannedRights() (value ChatBannedRights, ok bool)
GetDefaultBannedRights() (value ChatBannedRights, ok bool)
GetParticipantsCount() (value int, ok bool)
}) {
c.Creator = from.GetCreator()
c.Left = from.GetLeft()
c.Broadcast = from.GetBroadcast()
c.Verified = from.GetVerified()
c.Megagroup = from.GetMegagroup()
c.Restricted = from.GetRestricted()
c.Signatures = from.GetSignatures()
c.Min = from.GetMin()
c.Scam = from.GetScam()
c.HasLink = from.GetHasLink()
c.HasGeo = from.GetHasGeo()
c.SlowmodeEnabled = from.GetSlowmodeEnabled()
c.CallActive = from.GetCallActive()
c.CallNotEmpty = from.GetCallNotEmpty()
c.Fake = from.GetFake()
c.Gigagroup = from.GetGigagroup()
c.Noforwards = from.GetNoforwards()
c.ID = from.GetID()
if val, ok := from.GetAccessHash(); ok {
c.AccessHash = val
}
c.Title = from.GetTitle()
if val, ok := from.GetUsername(); ok {
c.Username = val
}
c.Photo = from.GetPhoto()
c.Date = from.GetDate()
if val, ok := from.GetRestrictionReason(); ok {
c.RestrictionReason = val
}
if val, ok := from.GetAdminRights(); ok {
c.AdminRights = val
}
if val, ok := from.GetBannedRights(); ok {
c.BannedRights = val
}
if val, ok := from.GetDefaultBannedRights(); ok {
c.DefaultBannedRights = val
}
if val, ok := from.GetParticipantsCount(); ok {
c.ParticipantsCount = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*Channel) TypeID() uint32 {
return ChannelTypeID
}
// TypeName returns name of type in TL schema.
func (*Channel) TypeName() string {
return "channel"
}
// TypeInfo returns info about TL type.
func (c *Channel) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "channel",
ID: ChannelTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Creator",
SchemaName: "creator",
Null: !c.Flags.Has(0),
},
{
Name: "Left",
SchemaName: "left",
Null: !c.Flags.Has(2),
},
{
Name: "Broadcast",
SchemaName: "broadcast",
Null: !c.Flags.Has(5),
},
{
Name: "Verified",
SchemaName: "verified",
Null: !c.Flags.Has(7),
},
{
Name: "Megagroup",
SchemaName: "megagroup",
Null: !c.Flags.Has(8),
},
{
Name: "Restricted",
SchemaName: "restricted",
Null: !c.Flags.Has(9),
},
{
Name: "Signatures",
SchemaName: "signatures",
Null: !c.Flags.Has(11),
},
{
Name: "Min",
SchemaName: "min",
Null: !c.Flags.Has(12),
},
{
Name: "Scam",
SchemaName: "scam",
Null: !c.Flags.Has(19),
},
{
Name: "HasLink",
SchemaName: "has_link",
Null: !c.Flags.Has(20),
},
{
Name: "HasGeo",
SchemaName: "has_geo",
Null: !c.Flags.Has(21),
},
{
Name: "SlowmodeEnabled",
SchemaName: "slowmode_enabled",
Null: !c.Flags.Has(22),
},
{
Name: "CallActive",
SchemaName: "call_active",
Null: !c.Flags.Has(23),
},
{
Name: "CallNotEmpty",
SchemaName: "call_not_empty",
Null: !c.Flags.Has(24),
},
{
Name: "Fake",
SchemaName: "fake",
Null: !c.Flags.Has(25),
},
{
Name: "Gigagroup",
SchemaName: "gigagroup",
Null: !c.Flags.Has(26),
},
{
Name: "Noforwards",
SchemaName: "noforwards",
Null: !c.Flags.Has(27),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "AccessHash",
SchemaName: "access_hash",
Null: !c.Flags.Has(13),
},
{
Name: "Title",
SchemaName: "title",
},
{
Name: "Username",
SchemaName: "username",
Null: !c.Flags.Has(6),
},
{
Name: "Photo",
SchemaName: "photo",
},
{
Name: "Date",
SchemaName: "date",
},
{
Name: "RestrictionReason",
SchemaName: "restriction_reason",
Null: !c.Flags.Has(9),
},
{
Name: "AdminRights",
SchemaName: "admin_rights",
Null: !c.Flags.Has(14),
},
{
Name: "BannedRights",
SchemaName: "banned_rights",
Null: !c.Flags.Has(15),
},
{
Name: "DefaultBannedRights",
SchemaName: "default_banned_rights",
Null: !c.Flags.Has(18),
},
{
Name: "ParticipantsCount",
SchemaName: "participants_count",
Null: !c.Flags.Has(17),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (c *Channel) SetFlags() {
if !(c.Creator == false) {
c.Flags.Set(0)
}
if !(c.Left == false) {
c.Flags.Set(2)
}
if !(c.Broadcast == false) {
c.Flags.Set(5)
}
if !(c.Verified == false) {
c.Flags.Set(7)
}
if !(c.Megagroup == false) {
c.Flags.Set(8)
}
if !(c.Restricted == false) {
c.Flags.Set(9)
}
if !(c.Signatures == false) {
c.Flags.Set(11)
}
if !(c.Min == false) {
c.Flags.Set(12)
}
if !(c.Scam == false) {
c.Flags.Set(19)
}
if !(c.HasLink == false) {
c.Flags.Set(20)
}
if !(c.HasGeo == false) {
c.Flags.Set(21)
}
if !(c.SlowmodeEnabled == false) {
c.Flags.Set(22)
}
if !(c.CallActive == false) {
c.Flags.Set(23)
}
if !(c.CallNotEmpty == false) {
c.Flags.Set(24)
}
if !(c.Fake == false) {
c.Flags.Set(25)
}
if !(c.Gigagroup == false) {
c.Flags.Set(26)
}
if !(c.Noforwards == false) {
c.Flags.Set(27)
}
if !(c.AccessHash == 0) {
c.Flags.Set(13)
}
if !(c.Username == "") {
c.Flags.Set(6)
}
if !(c.RestrictionReason == nil) {
c.Flags.Set(9)
}
if !(c.AdminRights.Zero()) {
c.Flags.Set(14)
}
if !(c.BannedRights.Zero()) {
c.Flags.Set(15)
}
if !(c.DefaultBannedRights.Zero()) {
c.Flags.Set(18)
}
if !(c.ParticipantsCount == 0) {
c.Flags.Set(17)
}
}
// Encode implements bin.Encoder.
func (c *Channel) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode channel#8261ac61 as nil")
}
b.PutID(ChannelTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *Channel) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode channel#8261ac61 as nil")
}
c.SetFlags()
if err := c.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode channel#8261ac61: field flags: %w", err)
}
b.PutLong(c.ID)
if c.Flags.Has(13) {
b.PutLong(c.AccessHash)
}
b.PutString(c.Title)
if c.Flags.Has(6) {
b.PutString(c.Username)
}
if c.Photo == nil {
return fmt.Errorf("unable to encode channel#8261ac61: field photo is nil")
}
if err := c.Photo.Encode(b); err != nil {
return fmt.Errorf("unable to encode channel#8261ac61: field photo: %w", err)
}
b.PutInt(c.Date)
if c.Flags.Has(9) {
b.PutVectorHeader(len(c.RestrictionReason))
for idx, v := range c.RestrictionReason {
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode channel#8261ac61: field restriction_reason element with index %d: %w", idx, err)
}
}
}
if c.Flags.Has(14) {
if err := c.AdminRights.Encode(b); err != nil {
return fmt.Errorf("unable to encode channel#8261ac61: field admin_rights: %w", err)
}
}
if c.Flags.Has(15) {
if err := c.BannedRights.Encode(b); err != nil {
return fmt.Errorf("unable to encode channel#8261ac61: field banned_rights: %w", err)
}
}
if c.Flags.Has(18) {
if err := c.DefaultBannedRights.Encode(b); err != nil {
return fmt.Errorf("unable to encode channel#8261ac61: field default_banned_rights: %w", err)
}
}
if c.Flags.Has(17) {
b.PutInt(c.ParticipantsCount)
}
return nil
}
// Decode implements bin.Decoder.
func (c *Channel) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode channel#8261ac61 to nil")
}
if err := b.ConsumeID(ChannelTypeID); err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *Channel) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode channel#8261ac61 to nil")
}
{
if err := c.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field flags: %w", err)
}
}
c.Creator = c.Flags.Has(0)
c.Left = c.Flags.Has(2)
c.Broadcast = c.Flags.Has(5)
c.Verified = c.Flags.Has(7)
c.Megagroup = c.Flags.Has(8)
c.Restricted = c.Flags.Has(9)
c.Signatures = c.Flags.Has(11)
c.Min = c.Flags.Has(12)
c.Scam = c.Flags.Has(19)
c.HasLink = c.Flags.Has(20)
c.HasGeo = c.Flags.Has(21)
c.SlowmodeEnabled = c.Flags.Has(22)
c.CallActive = c.Flags.Has(23)
c.CallNotEmpty = c.Flags.Has(24)
c.Fake = c.Flags.Has(25)
c.Gigagroup = c.Flags.Has(26)
c.Noforwards = c.Flags.Has(27)
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field id: %w", err)
}
c.ID = value
}
if c.Flags.Has(13) {
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field access_hash: %w", err)
}
c.AccessHash = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field title: %w", err)
}
c.Title = value
}
if c.Flags.Has(6) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field username: %w", err)
}
c.Username = value
}
{
value, err := DecodeChatPhoto(b)
if err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field photo: %w", err)
}
c.Photo = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field date: %w", err)
}
c.Date = value
}
if c.Flags.Has(9) {
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field restriction_reason: %w", err)
}
if headerLen > 0 {
c.RestrictionReason = make([]RestrictionReason, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
var value RestrictionReason
if err := value.Decode(b); err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field restriction_reason: %w", err)
}
c.RestrictionReason = append(c.RestrictionReason, value)
}
}
if c.Flags.Has(14) {
if err := c.AdminRights.Decode(b); err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field admin_rights: %w", err)
}
}
if c.Flags.Has(15) {
if err := c.BannedRights.Decode(b); err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field banned_rights: %w", err)
}
}
if c.Flags.Has(18) {
if err := c.DefaultBannedRights.Decode(b); err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field default_banned_rights: %w", err)
}
}
if c.Flags.Has(17) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode channel#8261ac61: field participants_count: %w", err)
}
c.ParticipantsCount = value
}
return nil
}
// SetCreator sets value of Creator conditional field.
func (c *Channel) SetCreator(value bool) {
if value {
c.Flags.Set(0)
c.Creator = true
} else {
c.Flags.Unset(0)
c.Creator = false
}
}
// GetCreator returns value of Creator conditional field.
func (c *Channel) GetCreator() (value bool) {
if c == nil {
return
}
return c.Flags.Has(0)
}
// SetLeft sets value of Left conditional field.
func (c *Channel) SetLeft(value bool) {
if value {
c.Flags.Set(2)
c.Left = true
} else {
c.Flags.Unset(2)
c.Left = false
}
}
// GetLeft returns value of Left conditional field.
func (c *Channel) GetLeft() (value bool) {
if c == nil {
return
}
return c.Flags.Has(2)
}
// SetBroadcast sets value of Broadcast conditional field.
func (c *Channel) SetBroadcast(value bool) {
if value {
c.Flags.Set(5)
c.Broadcast = true
} else {
c.Flags.Unset(5)
c.Broadcast = false
}
}
// GetBroadcast returns value of Broadcast conditional field.
func (c *Channel) GetBroadcast() (value bool) {
if c == nil {
return
}
return c.Flags.Has(5)
}
// SetVerified sets value of Verified conditional field.
func (c *Channel) SetVerified(value bool) {
if value {
c.Flags.Set(7)
c.Verified = true
} else {
c.Flags.Unset(7)
c.Verified = false
}
}
// GetVerified returns value of Verified conditional field.
func (c *Channel) GetVerified() (value bool) {
if c == nil {
return
}
return c.Flags.Has(7)
}
// SetMegagroup sets value of Megagroup conditional field.
func (c *Channel) SetMegagroup(value bool) {
if value {
c.Flags.Set(8)
c.Megagroup = true
} else {
c.Flags.Unset(8)
c.Megagroup = false
}
}
// GetMegagroup returns value of Megagroup conditional field.
func (c *Channel) GetMegagroup() (value bool) {
if c == nil {
return
}
return c.Flags.Has(8)
}
// SetRestricted sets value of Restricted conditional field.
func (c *Channel) SetRestricted(value bool) {
if value {
c.Flags.Set(9)
c.Restricted = true
} else {
c.Flags.Unset(9)
c.Restricted = false
}
}
// GetRestricted returns value of Restricted conditional field.
func (c *Channel) GetRestricted() (value bool) {
if c == nil {
return
}
return c.Flags.Has(9)
}
// SetSignatures sets value of Signatures conditional field.
func (c *Channel) SetSignatures(value bool) {
if value {
c.Flags.Set(11)
c.Signatures = true
} else {
c.Flags.Unset(11)
c.Signatures = false
}
}
// GetSignatures returns value of Signatures conditional field.
func (c *Channel) GetSignatures() (value bool) {
if c == nil {
return
}
return c.Flags.Has(11)
}
// SetMin sets value of Min conditional field.
func (c *Channel) SetMin(value bool) {
if value {
c.Flags.Set(12)
c.Min = true
} else {
c.Flags.Unset(12)
c.Min = false
}
}
// GetMin returns value of Min conditional field.
func (c *Channel) GetMin() (value bool) {
if c == nil {
return
}
return c.Flags.Has(12)
}
// SetScam sets value of Scam conditional field.
func (c *Channel) SetScam(value bool) {
if value {
c.Flags.Set(19)
c.Scam = true
} else {
c.Flags.Unset(19)
c.Scam = false
}
}
// GetScam returns value of Scam conditional field.
func (c *Channel) GetScam() (value bool) {
if c == nil {
return
}
return c.Flags.Has(19)
}
// SetHasLink sets value of HasLink conditional field.
func (c *Channel) SetHasLink(value bool) {
if value {
c.Flags.Set(20)
c.HasLink = true
} else {
c.Flags.Unset(20)
c.HasLink = false
}
}
// GetHasLink returns value of HasLink conditional field.
func (c *Channel) GetHasLink() (value bool) {
if c == nil {
return
}
return c.Flags.Has(20)
}
// SetHasGeo sets value of HasGeo conditional field.
func (c *Channel) SetHasGeo(value bool) {
if value {
c.Flags.Set(21)
c.HasGeo = true
} else {
c.Flags.Unset(21)
c.HasGeo = false
}
}
// GetHasGeo returns value of HasGeo conditional field.
func (c *Channel) GetHasGeo() (value bool) {
if c == nil {
return
}
return c.Flags.Has(21)
}
// SetSlowmodeEnabled sets value of SlowmodeEnabled conditional field.
func (c *Channel) SetSlowmodeEnabled(value bool) {
if value {
c.Flags.Set(22)
c.SlowmodeEnabled = true
} else {
c.Flags.Unset(22)
c.SlowmodeEnabled = false
}
}
// GetSlowmodeEnabled returns value of SlowmodeEnabled conditional field.
func (c *Channel) GetSlowmodeEnabled() (value bool) {
if c == nil {
return
}
return c.Flags.Has(22)
}
// SetCallActive sets value of CallActive conditional field.
func (c *Channel) SetCallActive(value bool) {
if value {
c.Flags.Set(23)
c.CallActive = true
} else {
c.Flags.Unset(23)
c.CallActive = false
}
}
// GetCallActive returns value of CallActive conditional field.
func (c *Channel) GetCallActive() (value bool) {
if c == nil {
return
}
return c.Flags.Has(23)
}
// SetCallNotEmpty sets value of CallNotEmpty conditional field.
func (c *Channel) SetCallNotEmpty(value bool) {
if value {
c.Flags.Set(24)
c.CallNotEmpty = true
} else {
c.Flags.Unset(24)
c.CallNotEmpty = false
}
}
// GetCallNotEmpty returns value of CallNotEmpty conditional field.
func (c *Channel) GetCallNotEmpty() (value bool) {
if c == nil {
return
}
return c.Flags.Has(24)
}
// SetFake sets value of Fake conditional field.
func (c *Channel) SetFake(value bool) {
if value {
c.Flags.Set(25)
c.Fake = true
} else {
c.Flags.Unset(25)
c.Fake = false
}
}
// GetFake returns value of Fake conditional field.
func (c *Channel) GetFake() (value bool) {
if c == nil {
return
}
return c.Flags.Has(25)
}
// SetGigagroup sets value of Gigagroup conditional field.
func (c *Channel) SetGigagroup(value bool) {
if value {
c.Flags.Set(26)
c.Gigagroup = true
} else {
c.Flags.Unset(26)
c.Gigagroup = false
}
}
// GetGigagroup returns value of Gigagroup conditional field.
func (c *Channel) GetGigagroup() (value bool) {
if c == nil {
return
}
return c.Flags.Has(26)
}
// SetNoforwards sets value of Noforwards conditional field.
func (c *Channel) SetNoforwards(value bool) {
if value {
c.Flags.Set(27)
c.Noforwards = true
} else {
c.Flags.Unset(27)
c.Noforwards = false
}
}
// GetNoforwards returns value of Noforwards conditional field.
func (c *Channel) GetNoforwards() (value bool) {
if c == nil {
return
}
return c.Flags.Has(27)
}
// GetID returns value of ID field.
func (c *Channel) GetID() (value int64) {
if c == nil {
return
}
return c.ID
}
// SetAccessHash sets value of AccessHash conditional field.
func (c *Channel) SetAccessHash(value int64) {
c.Flags.Set(13)
c.AccessHash = value
}
// GetAccessHash returns value of AccessHash conditional field and
// boolean which is true if field was set.
func (c *Channel) GetAccessHash() (value int64, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(13) {
return value, false
}
return c.AccessHash, true
}
// GetTitle returns value of Title field.
func (c *Channel) GetTitle() (value string) {
if c == nil {
return
}
return c.Title
}
// SetUsername sets value of Username conditional field.
func (c *Channel) SetUsername(value string) {
c.Flags.Set(6)
c.Username = value
}
// GetUsername returns value of Username conditional field and
// boolean which is true if field was set.
func (c *Channel) GetUsername() (value string, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(6) {
return value, false
}
return c.Username, true
}
// GetPhoto returns value of Photo field.
func (c *Channel) GetPhoto() (value ChatPhotoClass) {
if c == nil {
return
}
return c.Photo
}
// GetDate returns value of Date field.
func (c *Channel) GetDate() (value int) {
if c == nil {
return
}
return c.Date
}
// SetRestrictionReason sets value of RestrictionReason conditional field.
func (c *Channel) SetRestrictionReason(value []RestrictionReason) {
c.Flags.Set(9)
c.RestrictionReason = value
}
// GetRestrictionReason returns value of RestrictionReason conditional field and
// boolean which is true if field was set.
func (c *Channel) GetRestrictionReason() (value []RestrictionReason, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(9) {
return value, false
}
return c.RestrictionReason, true
}
// SetAdminRights sets value of AdminRights conditional field.
func (c *Channel) SetAdminRights(value ChatAdminRights) {
c.Flags.Set(14)
c.AdminRights = value
}
// GetAdminRights returns value of AdminRights conditional field and
// boolean which is true if field was set.
func (c *Channel) GetAdminRights() (value ChatAdminRights, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(14) {
return value, false
}
return c.AdminRights, true
}
// SetBannedRights sets value of BannedRights conditional field.
func (c *Channel) SetBannedRights(value ChatBannedRights) {
c.Flags.Set(15)
c.BannedRights = value
}
// GetBannedRights returns value of BannedRights conditional field and
// boolean which is true if field was set.
func (c *Channel) GetBannedRights() (value ChatBannedRights, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(15) {
return value, false
}
return c.BannedRights, true
}
// SetDefaultBannedRights sets value of DefaultBannedRights conditional field.
func (c *Channel) SetDefaultBannedRights(value ChatBannedRights) {
c.Flags.Set(18)
c.DefaultBannedRights = value
}
// GetDefaultBannedRights returns value of DefaultBannedRights conditional field and
// boolean which is true if field was set.
func (c *Channel) GetDefaultBannedRights() (value ChatBannedRights, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(18) {
return value, false
}
return c.DefaultBannedRights, true
}
// SetParticipantsCount sets value of ParticipantsCount conditional field.
func (c *Channel) SetParticipantsCount(value int) {
c.Flags.Set(17)
c.ParticipantsCount = value
}
// GetParticipantsCount returns value of ParticipantsCount conditional field and
// boolean which is true if field was set.
func (c *Channel) GetParticipantsCount() (value int, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(17) {
return value, false
}
return c.ParticipantsCount, true
}
// ChannelForbidden represents TL type `channelForbidden#17d493d5`.
// Indicates a channel/supergroup we can't access because we were banned, or for some
// other reason.
//
// See https://core.telegram.org/constructor/channelForbidden for reference.
type ChannelForbidden struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Is this a channel
Broadcast bool
// Is this a supergroup
Megagroup bool
// Channel ID
ID int64
// Access hash
AccessHash int64
// Title
Title string
// The ban is valid until the specified date
//
// Use SetUntilDate and GetUntilDate helpers.
UntilDate int
}
// ChannelForbiddenTypeID is TL type id of ChannelForbidden.
const ChannelForbiddenTypeID = 0x17d493d5
// construct implements constructor of ChatClass.
func (c ChannelForbidden) construct() ChatClass { return &c }
// Ensuring interfaces in compile-time for ChannelForbidden.
var (
_ bin.Encoder = &ChannelForbidden{}
_ bin.Decoder = &ChannelForbidden{}
_ bin.BareEncoder = &ChannelForbidden{}
_ bin.BareDecoder = &ChannelForbidden{}
_ ChatClass = &ChannelForbidden{}
)
func (c *ChannelForbidden) Zero() bool {
if c == nil {
return true
}
if !(c.Flags.Zero()) {
return false
}
if !(c.Broadcast == false) {
return false
}
if !(c.Megagroup == false) {
return false
}
if !(c.ID == 0) {
return false
}
if !(c.AccessHash == 0) {
return false
}
if !(c.Title == "") {
return false
}
if !(c.UntilDate == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *ChannelForbidden) String() string {
if c == nil {
return "ChannelForbidden(nil)"
}
type Alias ChannelForbidden
return fmt.Sprintf("ChannelForbidden%+v", Alias(*c))
}
// FillFrom fills ChannelForbidden from given interface.
func (c *ChannelForbidden) FillFrom(from interface {
GetBroadcast() (value bool)
GetMegagroup() (value bool)
GetID() (value int64)
GetAccessHash() (value int64)
GetTitle() (value string)
GetUntilDate() (value int, ok bool)
}) {
c.Broadcast = from.GetBroadcast()
c.Megagroup = from.GetMegagroup()
c.ID = from.GetID()
c.AccessHash = from.GetAccessHash()
c.Title = from.GetTitle()
if val, ok := from.GetUntilDate(); ok {
c.UntilDate = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChannelForbidden) TypeID() uint32 {
return ChannelForbiddenTypeID
}
// TypeName returns name of type in TL schema.
func (*ChannelForbidden) TypeName() string {
return "channelForbidden"
}
// TypeInfo returns info about TL type.
func (c *ChannelForbidden) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "channelForbidden",
ID: ChannelForbiddenTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Broadcast",
SchemaName: "broadcast",
Null: !c.Flags.Has(5),
},
{
Name: "Megagroup",
SchemaName: "megagroup",
Null: !c.Flags.Has(8),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "AccessHash",
SchemaName: "access_hash",
},
{
Name: "Title",
SchemaName: "title",
},
{
Name: "UntilDate",
SchemaName: "until_date",
Null: !c.Flags.Has(16),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (c *ChannelForbidden) SetFlags() {
if !(c.Broadcast == false) {
c.Flags.Set(5)
}
if !(c.Megagroup == false) {
c.Flags.Set(8)
}
if !(c.UntilDate == 0) {
c.Flags.Set(16)
}
}
// Encode implements bin.Encoder.
func (c *ChannelForbidden) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode channelForbidden#17d493d5 as nil")
}
b.PutID(ChannelForbiddenTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *ChannelForbidden) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode channelForbidden#17d493d5 as nil")
}
c.SetFlags()
if err := c.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode channelForbidden#17d493d5: field flags: %w", err)
}
b.PutLong(c.ID)
b.PutLong(c.AccessHash)
b.PutString(c.Title)
if c.Flags.Has(16) {
b.PutInt(c.UntilDate)
}
return nil
}
// Decode implements bin.Decoder.
func (c *ChannelForbidden) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode channelForbidden#17d493d5 to nil")
}
if err := b.ConsumeID(ChannelForbiddenTypeID); err != nil {
return fmt.Errorf("unable to decode channelForbidden#17d493d5: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *ChannelForbidden) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode channelForbidden#17d493d5 to nil")
}
{
if err := c.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode channelForbidden#17d493d5: field flags: %w", err)
}
}
c.Broadcast = c.Flags.Has(5)
c.Megagroup = c.Flags.Has(8)
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode channelForbidden#17d493d5: field id: %w", err)
}
c.ID = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode channelForbidden#17d493d5: field access_hash: %w", err)
}
c.AccessHash = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode channelForbidden#17d493d5: field title: %w", err)
}
c.Title = value
}
if c.Flags.Has(16) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode channelForbidden#17d493d5: field until_date: %w", err)
}
c.UntilDate = value
}
return nil
}
// SetBroadcast sets value of Broadcast conditional field.
func (c *ChannelForbidden) SetBroadcast(value bool) {
if value {
c.Flags.Set(5)
c.Broadcast = true
} else {
c.Flags.Unset(5)
c.Broadcast = false
}
}
// GetBroadcast returns value of Broadcast conditional field.
func (c *ChannelForbidden) GetBroadcast() (value bool) {
if c == nil {
return
}
return c.Flags.Has(5)
}
// SetMegagroup sets value of Megagroup conditional field.
func (c *ChannelForbidden) SetMegagroup(value bool) {
if value {
c.Flags.Set(8)
c.Megagroup = true
} else {
c.Flags.Unset(8)
c.Megagroup = false
}
}
// GetMegagroup returns value of Megagroup conditional field.
func (c *ChannelForbidden) GetMegagroup() (value bool) {
if c == nil {
return
}
return c.Flags.Has(8)
}
// GetID returns value of ID field.
func (c *ChannelForbidden) GetID() (value int64) {
if c == nil {
return
}
return c.ID
}
// GetAccessHash returns value of AccessHash field.
func (c *ChannelForbidden) GetAccessHash() (value int64) {
if c == nil {
return
}
return c.AccessHash
}
// GetTitle returns value of Title field.
func (c *ChannelForbidden) GetTitle() (value string) {
if c == nil {
return
}
return c.Title
}
// SetUntilDate sets value of UntilDate conditional field.
func (c *ChannelForbidden) SetUntilDate(value int) {
c.Flags.Set(16)
c.UntilDate = value
}
// GetUntilDate returns value of UntilDate conditional field and
// boolean which is true if field was set.
func (c *ChannelForbidden) GetUntilDate() (value int, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(16) {
return value, false
}
return c.UntilDate, true
}
// ChatClassName is schema name of ChatClass.
const ChatClassName = "Chat"
// ChatClass represents Chat generic type.
//
// See https://core.telegram.org/type/Chat for reference.
//
// Example:
// g, err := tg.DecodeChat(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.ChatEmpty: // chatEmpty#29562865
// case *tg.Chat: // chat#41cbf256
// case *tg.ChatForbidden: // chatForbidden#6592a1a7
// case *tg.Channel: // channel#8261ac61
// case *tg.ChannelForbidden: // channelForbidden#17d493d5
// default: panic(v)
// }
type ChatClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() ChatClass
// 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
// Group identifier
GetID() (value int64)
// AsNotEmpty tries to map ChatClass to NotEmptyChat.
AsNotEmpty() (NotEmptyChat, bool)
// AsNotForbidden tries to map ChatClass to NotForbiddenChat.
AsNotForbidden() (NotForbiddenChat, bool)
// AsFull tries to map ChatClass to FullChat.
AsFull() (FullChat, bool)
}
// AsInputPeer tries to map Chat to InputPeerChat.
func (c *Chat) AsInputPeer() *InputPeerChat {
value := new(InputPeerChat)
value.ChatID = c.GetID()
return value
}
// AsInputPeer tries to map Channel to InputPeerChannel.
func (c *Channel) AsInputPeer() *InputPeerChannel {
value := new(InputPeerChannel)
value.ChannelID = c.GetID()
if fieldValue, ok := c.GetAccessHash(); ok {
value.AccessHash = fieldValue
}
return value
}
// AsInput tries to map Channel to InputChannel.
func (c *Channel) AsInput() *InputChannel {
value := new(InputChannel)
value.ChannelID = c.GetID()
if fieldValue, ok := c.GetAccessHash(); ok {
value.AccessHash = fieldValue
}
return value
}
// NotEmptyChat represents NotEmpty subset of ChatClass.
type NotEmptyChat interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() ChatClass
// 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
// ID of the group
GetID() (value int64)
// Title
GetTitle() (value string)
}
// AsNotEmpty tries to map ChatEmpty to NotEmptyChat.
func (c *ChatEmpty) AsNotEmpty() (NotEmptyChat, bool) {
value, ok := (ChatClass(c)).(NotEmptyChat)
return value, ok
}
// AsNotEmpty tries to map Chat to NotEmptyChat.
func (c *Chat) AsNotEmpty() (NotEmptyChat, bool) {
value, ok := (ChatClass(c)).(NotEmptyChat)
return value, ok
}
// AsNotEmpty tries to map ChatForbidden to NotEmptyChat.
func (c *ChatForbidden) AsNotEmpty() (NotEmptyChat, bool) {
value, ok := (ChatClass(c)).(NotEmptyChat)
return value, ok
}
// AsNotEmpty tries to map Channel to NotEmptyChat.
func (c *Channel) AsNotEmpty() (NotEmptyChat, bool) {
value, ok := (ChatClass(c)).(NotEmptyChat)
return value, ok
}
// AsNotEmpty tries to map ChannelForbidden to NotEmptyChat.
func (c *ChannelForbidden) AsNotEmpty() (NotEmptyChat, bool) {
value, ok := (ChatClass(c)).(NotEmptyChat)
return value, ok
}
// NotForbiddenChat represents NotForbidden subset of ChatClass.
type NotForbiddenChat interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() ChatClass
// 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
// Group identifier
GetID() (value int64)
}
// AsNotForbidden tries to map ChatEmpty to NotForbiddenChat.
func (c *ChatEmpty) AsNotForbidden() (NotForbiddenChat, bool) {
value, ok := (ChatClass(c)).(NotForbiddenChat)
return value, ok
}
// AsNotForbidden tries to map Chat to NotForbiddenChat.
func (c *Chat) AsNotForbidden() (NotForbiddenChat, bool) {
value, ok := (ChatClass(c)).(NotForbiddenChat)
return value, ok
}
// AsNotForbidden tries to map ChatForbidden to NotForbiddenChat.
func (c *ChatForbidden) AsNotForbidden() (NotForbiddenChat, bool) {
value, ok := (ChatClass(c)).(NotForbiddenChat)
return value, ok
}
// AsNotForbidden tries to map Channel to NotForbiddenChat.
func (c *Channel) AsNotForbidden() (NotForbiddenChat, bool) {
value, ok := (ChatClass(c)).(NotForbiddenChat)
return value, ok
}
// AsNotForbidden tries to map ChannelForbidden to NotForbiddenChat.
func (c *ChannelForbidden) AsNotForbidden() (NotForbiddenChat, bool) {
value, ok := (ChatClass(c)).(NotForbiddenChat)
return value, ok
}
// FullChat represents Full subset of ChatClass.
type FullChat interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() ChatClass
// 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
// Whether the current user is the creator of the group
GetCreator() (value bool)
// Whether the current user has left the group
GetLeft() (value bool)
// Whether a group call is currently active
GetCallActive() (value bool)
// Whether there's anyone in the group call
GetCallNotEmpty() (value bool)
// Noforwards field of Chat.
GetNoforwards() (value bool)
// ID of the group
GetID() (value int64)
// Title
GetTitle() (value string)
// Chat photo
GetPhoto() (value ChatPhotoClass)
// Date of creation of the group
GetDate() (value int)
// Admin rights¹ of the user in the group
//
// Links:
// 1) https://core.telegram.org/api/rights
GetAdminRights() (value ChatAdminRights, ok bool)
// Default banned rights¹ of all users in the group
//
// Links:
// 1) https://core.telegram.org/api/rights
GetDefaultBannedRights() (value ChatBannedRights, ok bool)
}
// AsFull tries to map ChatEmpty to FullChat.
func (c *ChatEmpty) AsFull() (FullChat, bool) {
value, ok := (ChatClass(c)).(FullChat)
return value, ok
}
// AsFull tries to map Chat to FullChat.
func (c *Chat) AsFull() (FullChat, bool) {
value, ok := (ChatClass(c)).(FullChat)
return value, ok
}
// AsFull tries to map ChatForbidden to FullChat.
func (c *ChatForbidden) AsFull() (FullChat, bool) {
value, ok := (ChatClass(c)).(FullChat)
return value, ok
}
// AsFull tries to map Channel to FullChat.
func (c *Channel) AsFull() (FullChat, bool) {
value, ok := (ChatClass(c)).(FullChat)
return value, ok
}
// AsFull tries to map ChannelForbidden to FullChat.
func (c *ChannelForbidden) AsFull() (FullChat, bool) {
value, ok := (ChatClass(c)).(FullChat)
return value, ok
}
// DecodeChat implements binary de-serialization for ChatClass.
func DecodeChat(buf *bin.Buffer) (ChatClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case ChatEmptyTypeID:
// Decoding chatEmpty#29562865.
v := ChatEmpty{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode ChatClass: %w", err)
}
return &v, nil
case ChatTypeID:
// Decoding chat#41cbf256.
v := Chat{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode ChatClass: %w", err)
}
return &v, nil
case ChatForbiddenTypeID:
// Decoding chatForbidden#6592a1a7.
v := ChatForbidden{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode ChatClass: %w", err)
}
return &v, nil
case ChannelTypeID:
// Decoding channel#8261ac61.
v := Channel{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode ChatClass: %w", err)
}
return &v, nil
case ChannelForbiddenTypeID:
// Decoding channelForbidden#17d493d5.
v := ChannelForbidden{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode ChatClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode ChatClass: %w", bin.NewUnexpectedID(id))
}
}
// Chat boxes the ChatClass providing a helper.
type ChatBox struct {
Chat ChatClass
}
// Decode implements bin.Decoder for ChatBox.
func (b *ChatBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode ChatBox to nil")
}
v, err := DecodeChat(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.Chat = v
return nil
}
// Encode implements bin.Encode for ChatBox.
func (b *ChatBox) Encode(buf *bin.Buffer) error {
if b == nil || b.Chat == nil {
return fmt.Errorf("unable to encode ChatClass as nil")
}
return b.Chat.Encode(buf)
}