// Code generated by gotdgen, DO NOT EDIT.

package tdapi

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// Supergroup represents TL type `supergroup#faa1463f`.
type Supergroup struct {
	// Supergroup or channel identifier
	ID int64
	// Usernames of the supergroup or channel; may be null
	Usernames Usernames
	// Point in time (Unix timestamp) when the current user joined, or the point in time when
	// the supergroup or channel was created, in case the user is not a member
	Date int32
	// Status of the current user in the supergroup or channel; custom title will always be
	// empty
	Status ChatMemberStatusClass
	// Number of members in the supergroup or channel; 0 if unknown. Currently, it is
	// guaranteed to be known only if the supergroup or channel was received through
	MemberCount int32
	// Approximate boost level for the chat
	BoostLevel int32
	// True, if automatic translation of messages is enabled in the channel
	HasAutomaticTranslation bool
	// True, if the channel has a discussion group, or the supergroup is the designated
	// discussion group for a channel
	HasLinkedChat bool
	// True, if the supergroup is connected to a location, i.e. the supergroup is a
	// location-based supergroup
	HasLocation bool
	// True, if messages sent to the channel contains name of the sender. This field is only
	// applicable to channels
	SignMessages bool
	// True, if messages sent to the channel have information about the sender user. This
	// field is only applicable to channels
	ShowMessageSender bool
	// True, if users need to join the supergroup before they can send messages. Always true
	// for channels and non-discussion supergroups
	JoinToSendMessages bool
	// True, if all users directly joining the supergroup need to be approved by supergroup
	// administrators. Always false for channels and supergroups without username, location,
	// or a linked chat
	JoinByRequest bool
	// True, if the slow mode is enabled in the supergroup
	IsSlowModeEnabled bool
	// True, if the supergroup is a channel
	IsChannel bool
	// True, if the supergroup is a broadcast group, i.e. only administrators can send
	// messages and there is no limit on the number of members
	IsBroadcastGroup bool
	// True, if the supergroup is a forum with topics
	IsForum bool
	// True, if the supergroup is a direct message group for a channel chat
	IsDirectMessagesGroup bool
	// True, if the supergroup is a direct messages group for a channel chat that is
	// administered by the current user
	IsAdministeredDirectMessagesGroup bool
	// Information about verification status of the supergroup or channel; may be null if
	// none
	VerificationStatus VerificationStatus
	// True, if the channel has direct messages group
	HasDirectMessagesGroup bool
	// True, if the supergroup is a forum, which topics are shown in the same way as in
	// channel direct messages groups
	HasForumTabs bool
	// True, if content of media messages in the supergroup or channel chat must be hidden
	// with 18+ spoiler
	HasSensitiveContent bool
	// If non-empty, contains a human-readable description of the reason why access to this
	// supergroup or channel must be restricted
	RestrictionReason string
	// Number of Telegram Stars that must be paid by non-administrator users of the
	// supergroup chat for each sent message
	PaidMessageStarCount int64
	// True, if the supergroup or channel has non-expired stories available to the current
	// user
	HasActiveStories bool
	// True, if the supergroup or channel has unread non-expired stories available to the
	// current user
	HasUnreadActiveStories bool
}

// SupergroupTypeID is TL type id of Supergroup.
const SupergroupTypeID = 0xfaa1463f

// Ensuring interfaces in compile-time for Supergroup.
var (
	_ bin.Encoder     = &Supergroup{}
	_ bin.Decoder     = &Supergroup{}
	_ bin.BareEncoder = &Supergroup{}
	_ bin.BareDecoder = &Supergroup{}
)

func (s *Supergroup) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.ID == 0) {
		return false
	}
	if !(s.Usernames.Zero()) {
		return false
	}
	if !(s.Date == 0) {
		return false
	}
	if !(s.Status == nil) {
		return false
	}
	if !(s.MemberCount == 0) {
		return false
	}
	if !(s.BoostLevel == 0) {
		return false
	}
	if !(s.HasAutomaticTranslation == false) {
		return false
	}
	if !(s.HasLinkedChat == false) {
		return false
	}
	if !(s.HasLocation == false) {
		return false
	}
	if !(s.SignMessages == false) {
		return false
	}
	if !(s.ShowMessageSender == false) {
		return false
	}
	if !(s.JoinToSendMessages == false) {
		return false
	}
	if !(s.JoinByRequest == false) {
		return false
	}
	if !(s.IsSlowModeEnabled == false) {
		return false
	}
	if !(s.IsChannel == false) {
		return false
	}
	if !(s.IsBroadcastGroup == false) {
		return false
	}
	if !(s.IsForum == false) {
		return false
	}
	if !(s.IsDirectMessagesGroup == false) {
		return false
	}
	if !(s.IsAdministeredDirectMessagesGroup == false) {
		return false
	}
	if !(s.VerificationStatus.Zero()) {
		return false
	}
	if !(s.HasDirectMessagesGroup == false) {
		return false
	}
	if !(s.HasForumTabs == false) {
		return false
	}
	if !(s.HasSensitiveContent == false) {
		return false
	}
	if !(s.RestrictionReason == "") {
		return false
	}
	if !(s.PaidMessageStarCount == 0) {
		return false
	}
	if !(s.HasActiveStories == false) {
		return false
	}
	if !(s.HasUnreadActiveStories == false) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func (s *Supergroup) String() string {
	if s == nil {
		return "Supergroup(nil)"
	}
	type Alias Supergroup
	return fmt.Sprintf("Supergroup%+v", Alias(*s))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*Supergroup) TypeID() uint32 {
	return SupergroupTypeID
}

// TypeName returns name of type in TL schema.
func (*Supergroup) TypeName() string {
	return "supergroup"
}

// TypeInfo returns info about TL type.
func (s *Supergroup) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "supergroup",
		ID:   SupergroupTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Usernames",
			SchemaName: "usernames",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Status",
			SchemaName: "status",
		},
		{
			Name:       "MemberCount",
			SchemaName: "member_count",
		},
		{
			Name:       "BoostLevel",
			SchemaName: "boost_level",
		},
		{
			Name:       "HasAutomaticTranslation",
			SchemaName: "has_automatic_translation",
		},
		{
			Name:       "HasLinkedChat",
			SchemaName: "has_linked_chat",
		},
		{
			Name:       "HasLocation",
			SchemaName: "has_location",
		},
		{
			Name:       "SignMessages",
			SchemaName: "sign_messages",
		},
		{
			Name:       "ShowMessageSender",
			SchemaName: "show_message_sender",
		},
		{
			Name:       "JoinToSendMessages",
			SchemaName: "join_to_send_messages",
		},
		{
			Name:       "JoinByRequest",
			SchemaName: "join_by_request",
		},
		{
			Name:       "IsSlowModeEnabled",
			SchemaName: "is_slow_mode_enabled",
		},
		{
			Name:       "IsChannel",
			SchemaName: "is_channel",
		},
		{
			Name:       "IsBroadcastGroup",
			SchemaName: "is_broadcast_group",
		},
		{
			Name:       "IsForum",
			SchemaName: "is_forum",
		},
		{
			Name:       "IsDirectMessagesGroup",
			SchemaName: "is_direct_messages_group",
		},
		{
			Name:       "IsAdministeredDirectMessagesGroup",
			SchemaName: "is_administered_direct_messages_group",
		},
		{
			Name:       "VerificationStatus",
			SchemaName: "verification_status",
		},
		{
			Name:       "HasDirectMessagesGroup",
			SchemaName: "has_direct_messages_group",
		},
		{
			Name:       "HasForumTabs",
			SchemaName: "has_forum_tabs",
		},
		{
			Name:       "HasSensitiveContent",
			SchemaName: "has_sensitive_content",
		},
		{
			Name:       "RestrictionReason",
			SchemaName: "restriction_reason",
		},
		{
			Name:       "PaidMessageStarCount",
			SchemaName: "paid_message_star_count",
		},
		{
			Name:       "HasActiveStories",
			SchemaName: "has_active_stories",
		},
		{
			Name:       "HasUnreadActiveStories",
			SchemaName: "has_unread_active_stories",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *Supergroup) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroup#faa1463f as nil")
	}
	b.PutID(SupergroupTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *Supergroup) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroup#faa1463f as nil")
	}
	b.PutInt53(s.ID)
	if err := s.Usernames.Encode(b); err != nil {
		return fmt.Errorf("unable to encode supergroup#faa1463f: field usernames: %w", err)
	}
	b.PutInt32(s.Date)
	if s.Status == nil {
		return fmt.Errorf("unable to encode supergroup#faa1463f: field status is nil")
	}
	if err := s.Status.Encode(b); err != nil {
		return fmt.Errorf("unable to encode supergroup#faa1463f: field status: %w", err)
	}
	b.PutInt32(s.MemberCount)
	b.PutInt32(s.BoostLevel)
	b.PutBool(s.HasAutomaticTranslation)
	b.PutBool(s.HasLinkedChat)
	b.PutBool(s.HasLocation)
	b.PutBool(s.SignMessages)
	b.PutBool(s.ShowMessageSender)
	b.PutBool(s.JoinToSendMessages)
	b.PutBool(s.JoinByRequest)
	b.PutBool(s.IsSlowModeEnabled)
	b.PutBool(s.IsChannel)
	b.PutBool(s.IsBroadcastGroup)
	b.PutBool(s.IsForum)
	b.PutBool(s.IsDirectMessagesGroup)
	b.PutBool(s.IsAdministeredDirectMessagesGroup)
	if err := s.VerificationStatus.Encode(b); err != nil {
		return fmt.Errorf("unable to encode supergroup#faa1463f: field verification_status: %w", err)
	}
	b.PutBool(s.HasDirectMessagesGroup)
	b.PutBool(s.HasForumTabs)
	b.PutBool(s.HasSensitiveContent)
	b.PutString(s.RestrictionReason)
	b.PutInt53(s.PaidMessageStarCount)
	b.PutBool(s.HasActiveStories)
	b.PutBool(s.HasUnreadActiveStories)
	return nil
}

// Decode implements bin.Decoder.
func (s *Supergroup) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroup#faa1463f to nil")
	}
	if err := b.ConsumeID(SupergroupTypeID); err != nil {
		return fmt.Errorf("unable to decode supergroup#faa1463f: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *Supergroup) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroup#faa1463f to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field id: %w", err)
		}
		s.ID = value
	}
	{
		if err := s.Usernames.Decode(b); err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field usernames: %w", err)
		}
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field date: %w", err)
		}
		s.Date = value
	}
	{
		value, err := DecodeChatMemberStatus(b)
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field status: %w", err)
		}
		s.Status = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field member_count: %w", err)
		}
		s.MemberCount = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field boost_level: %w", err)
		}
		s.BoostLevel = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field has_automatic_translation: %w", err)
		}
		s.HasAutomaticTranslation = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field has_linked_chat: %w", err)
		}
		s.HasLinkedChat = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field has_location: %w", err)
		}
		s.HasLocation = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field sign_messages: %w", err)
		}
		s.SignMessages = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field show_message_sender: %w", err)
		}
		s.ShowMessageSender = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field join_to_send_messages: %w", err)
		}
		s.JoinToSendMessages = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field join_by_request: %w", err)
		}
		s.JoinByRequest = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field is_slow_mode_enabled: %w", err)
		}
		s.IsSlowModeEnabled = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field is_channel: %w", err)
		}
		s.IsChannel = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field is_broadcast_group: %w", err)
		}
		s.IsBroadcastGroup = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field is_forum: %w", err)
		}
		s.IsForum = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field is_direct_messages_group: %w", err)
		}
		s.IsDirectMessagesGroup = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field is_administered_direct_messages_group: %w", err)
		}
		s.IsAdministeredDirectMessagesGroup = value
	}
	{
		if err := s.VerificationStatus.Decode(b); err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field verification_status: %w", err)
		}
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field has_direct_messages_group: %w", err)
		}
		s.HasDirectMessagesGroup = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field has_forum_tabs: %w", err)
		}
		s.HasForumTabs = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field has_sensitive_content: %w", err)
		}
		s.HasSensitiveContent = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field restriction_reason: %w", err)
		}
		s.RestrictionReason = value
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field paid_message_star_count: %w", err)
		}
		s.PaidMessageStarCount = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field has_active_stories: %w", err)
		}
		s.HasActiveStories = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode supergroup#faa1463f: field has_unread_active_stories: %w", err)
		}
		s.HasUnreadActiveStories = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *Supergroup) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroup#faa1463f as nil")
	}
	b.ObjStart()
	b.PutID("supergroup")
	b.Comma()
	b.FieldStart("id")
	b.PutInt53(s.ID)
	b.Comma()
	b.FieldStart("usernames")
	if err := s.Usernames.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode supergroup#faa1463f: field usernames: %w", err)
	}
	b.Comma()
	b.FieldStart("date")
	b.PutInt32(s.Date)
	b.Comma()
	b.FieldStart("status")
	if s.Status == nil {
		return fmt.Errorf("unable to encode supergroup#faa1463f: field status is nil")
	}
	if err := s.Status.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode supergroup#faa1463f: field status: %w", err)
	}
	b.Comma()
	b.FieldStart("member_count")
	b.PutInt32(s.MemberCount)
	b.Comma()
	b.FieldStart("boost_level")
	b.PutInt32(s.BoostLevel)
	b.Comma()
	b.FieldStart("has_automatic_translation")
	b.PutBool(s.HasAutomaticTranslation)
	b.Comma()
	b.FieldStart("has_linked_chat")
	b.PutBool(s.HasLinkedChat)
	b.Comma()
	b.FieldStart("has_location")
	b.PutBool(s.HasLocation)
	b.Comma()
	b.FieldStart("sign_messages")
	b.PutBool(s.SignMessages)
	b.Comma()
	b.FieldStart("show_message_sender")
	b.PutBool(s.ShowMessageSender)
	b.Comma()
	b.FieldStart("join_to_send_messages")
	b.PutBool(s.JoinToSendMessages)
	b.Comma()
	b.FieldStart("join_by_request")
	b.PutBool(s.JoinByRequest)
	b.Comma()
	b.FieldStart("is_slow_mode_enabled")
	b.PutBool(s.IsSlowModeEnabled)
	b.Comma()
	b.FieldStart("is_channel")
	b.PutBool(s.IsChannel)
	b.Comma()
	b.FieldStart("is_broadcast_group")
	b.PutBool(s.IsBroadcastGroup)
	b.Comma()
	b.FieldStart("is_forum")
	b.PutBool(s.IsForum)
	b.Comma()
	b.FieldStart("is_direct_messages_group")
	b.PutBool(s.IsDirectMessagesGroup)
	b.Comma()
	b.FieldStart("is_administered_direct_messages_group")
	b.PutBool(s.IsAdministeredDirectMessagesGroup)
	b.Comma()
	b.FieldStart("verification_status")
	if err := s.VerificationStatus.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode supergroup#faa1463f: field verification_status: %w", err)
	}
	b.Comma()
	b.FieldStart("has_direct_messages_group")
	b.PutBool(s.HasDirectMessagesGroup)
	b.Comma()
	b.FieldStart("has_forum_tabs")
	b.PutBool(s.HasForumTabs)
	b.Comma()
	b.FieldStart("has_sensitive_content")
	b.PutBool(s.HasSensitiveContent)
	b.Comma()
	b.FieldStart("restriction_reason")
	b.PutString(s.RestrictionReason)
	b.Comma()
	b.FieldStart("paid_message_star_count")
	b.PutInt53(s.PaidMessageStarCount)
	b.Comma()
	b.FieldStart("has_active_stories")
	b.PutBool(s.HasActiveStories)
	b.Comma()
	b.FieldStart("has_unread_active_stories")
	b.PutBool(s.HasUnreadActiveStories)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *Supergroup) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroup#faa1463f to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("supergroup"); err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: %w", err)
			}
		case "id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field id: %w", err)
			}
			s.ID = value
		case "usernames":
			if err := s.Usernames.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field usernames: %w", err)
			}
		case "date":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field date: %w", err)
			}
			s.Date = value
		case "status":
			value, err := DecodeTDLibJSONChatMemberStatus(b)
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field status: %w", err)
			}
			s.Status = value
		case "member_count":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field member_count: %w", err)
			}
			s.MemberCount = value
		case "boost_level":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field boost_level: %w", err)
			}
			s.BoostLevel = value
		case "has_automatic_translation":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field has_automatic_translation: %w", err)
			}
			s.HasAutomaticTranslation = value
		case "has_linked_chat":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field has_linked_chat: %w", err)
			}
			s.HasLinkedChat = value
		case "has_location":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field has_location: %w", err)
			}
			s.HasLocation = value
		case "sign_messages":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field sign_messages: %w", err)
			}
			s.SignMessages = value
		case "show_message_sender":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field show_message_sender: %w", err)
			}
			s.ShowMessageSender = value
		case "join_to_send_messages":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field join_to_send_messages: %w", err)
			}
			s.JoinToSendMessages = value
		case "join_by_request":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field join_by_request: %w", err)
			}
			s.JoinByRequest = value
		case "is_slow_mode_enabled":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field is_slow_mode_enabled: %w", err)
			}
			s.IsSlowModeEnabled = value
		case "is_channel":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field is_channel: %w", err)
			}
			s.IsChannel = value
		case "is_broadcast_group":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field is_broadcast_group: %w", err)
			}
			s.IsBroadcastGroup = value
		case "is_forum":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field is_forum: %w", err)
			}
			s.IsForum = value
		case "is_direct_messages_group":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field is_direct_messages_group: %w", err)
			}
			s.IsDirectMessagesGroup = value
		case "is_administered_direct_messages_group":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field is_administered_direct_messages_group: %w", err)
			}
			s.IsAdministeredDirectMessagesGroup = value
		case "verification_status":
			if err := s.VerificationStatus.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field verification_status: %w", err)
			}
		case "has_direct_messages_group":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field has_direct_messages_group: %w", err)
			}
			s.HasDirectMessagesGroup = value
		case "has_forum_tabs":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field has_forum_tabs: %w", err)
			}
			s.HasForumTabs = value
		case "has_sensitive_content":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field has_sensitive_content: %w", err)
			}
			s.HasSensitiveContent = value
		case "restriction_reason":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field restriction_reason: %w", err)
			}
			s.RestrictionReason = value
		case "paid_message_star_count":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field paid_message_star_count: %w", err)
			}
			s.PaidMessageStarCount = value
		case "has_active_stories":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field has_active_stories: %w", err)
			}
			s.HasActiveStories = value
		case "has_unread_active_stories":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode supergroup#faa1463f: field has_unread_active_stories: %w", err)
			}
			s.HasUnreadActiveStories = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetID returns value of ID field.
func (s *Supergroup) GetID() (value int64) {
	if s == nil {
		return
	}
	return s.ID
}

// GetUsernames returns value of Usernames field.
func (s *Supergroup) GetUsernames() (value Usernames) {
	if s == nil {
		return
	}
	return s.Usernames
}

// GetDate returns value of Date field.
func (s *Supergroup) GetDate() (value int32) {
	if s == nil {
		return
	}
	return s.Date
}

// GetStatus returns value of Status field.
func (s *Supergroup) GetStatus() (value ChatMemberStatusClass) {
	if s == nil {
		return
	}
	return s.Status
}

// GetMemberCount returns value of MemberCount field.
func (s *Supergroup) GetMemberCount() (value int32) {
	if s == nil {
		return
	}
	return s.MemberCount
}

// GetBoostLevel returns value of BoostLevel field.
func (s *Supergroup) GetBoostLevel() (value int32) {
	if s == nil {
		return
	}
	return s.BoostLevel
}

// GetHasAutomaticTranslation returns value of HasAutomaticTranslation field.
func (s *Supergroup) GetHasAutomaticTranslation() (value bool) {
	if s == nil {
		return
	}
	return s.HasAutomaticTranslation
}

// GetHasLinkedChat returns value of HasLinkedChat field.
func (s *Supergroup) GetHasLinkedChat() (value bool) {
	if s == nil {
		return
	}
	return s.HasLinkedChat
}

// GetHasLocation returns value of HasLocation field.
func (s *Supergroup) GetHasLocation() (value bool) {
	if s == nil {
		return
	}
	return s.HasLocation
}

// GetSignMessages returns value of SignMessages field.
func (s *Supergroup) GetSignMessages() (value bool) {
	if s == nil {
		return
	}
	return s.SignMessages
}

// GetShowMessageSender returns value of ShowMessageSender field.
func (s *Supergroup) GetShowMessageSender() (value bool) {
	if s == nil {
		return
	}
	return s.ShowMessageSender
}

// GetJoinToSendMessages returns value of JoinToSendMessages field.
func (s *Supergroup) GetJoinToSendMessages() (value bool) {
	if s == nil {
		return
	}
	return s.JoinToSendMessages
}

// GetJoinByRequest returns value of JoinByRequest field.
func (s *Supergroup) GetJoinByRequest() (value bool) {
	if s == nil {
		return
	}
	return s.JoinByRequest
}

// GetIsSlowModeEnabled returns value of IsSlowModeEnabled field.
func (s *Supergroup) GetIsSlowModeEnabled() (value bool) {
	if s == nil {
		return
	}
	return s.IsSlowModeEnabled
}

// GetIsChannel returns value of IsChannel field.
func (s *Supergroup) GetIsChannel() (value bool) {
	if s == nil {
		return
	}
	return s.IsChannel
}

// GetIsBroadcastGroup returns value of IsBroadcastGroup field.
func (s *Supergroup) GetIsBroadcastGroup() (value bool) {
	if s == nil {
		return
	}
	return s.IsBroadcastGroup
}

// GetIsForum returns value of IsForum field.
func (s *Supergroup) GetIsForum() (value bool) {
	if s == nil {
		return
	}
	return s.IsForum
}

// GetIsDirectMessagesGroup returns value of IsDirectMessagesGroup field.
func (s *Supergroup) GetIsDirectMessagesGroup() (value bool) {
	if s == nil {
		return
	}
	return s.IsDirectMessagesGroup
}

// GetIsAdministeredDirectMessagesGroup returns value of IsAdministeredDirectMessagesGroup field.
func (s *Supergroup) GetIsAdministeredDirectMessagesGroup() (value bool) {
	if s == nil {
		return
	}
	return s.IsAdministeredDirectMessagesGroup
}

// GetVerificationStatus returns value of VerificationStatus field.
func (s *Supergroup) GetVerificationStatus() (value VerificationStatus) {
	if s == nil {
		return
	}
	return s.VerificationStatus
}

// GetHasDirectMessagesGroup returns value of HasDirectMessagesGroup field.
func (s *Supergroup) GetHasDirectMessagesGroup() (value bool) {
	if s == nil {
		return
	}
	return s.HasDirectMessagesGroup
}

// GetHasForumTabs returns value of HasForumTabs field.
func (s *Supergroup) GetHasForumTabs() (value bool) {
	if s == nil {
		return
	}
	return s.HasForumTabs
}

// GetHasSensitiveContent returns value of HasSensitiveContent field.
func (s *Supergroup) GetHasSensitiveContent() (value bool) {
	if s == nil {
		return
	}
	return s.HasSensitiveContent
}

// GetRestrictionReason returns value of RestrictionReason field.
func (s *Supergroup) GetRestrictionReason() (value string) {
	if s == nil {
		return
	}
	return s.RestrictionReason
}

// GetPaidMessageStarCount returns value of PaidMessageStarCount field.
func (s *Supergroup) GetPaidMessageStarCount() (value int64) {
	if s == nil {
		return
	}
	return s.PaidMessageStarCount
}

// GetHasActiveStories returns value of HasActiveStories field.
func (s *Supergroup) GetHasActiveStories() (value bool) {
	if s == nil {
		return
	}
	return s.HasActiveStories
}

// GetHasUnreadActiveStories returns value of HasUnreadActiveStories field.
func (s *Supergroup) GetHasUnreadActiveStories() (value bool) {
	if s == nil {
		return
	}
	return s.HasUnreadActiveStories
}
