// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// 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{}
)

// StatsGroupTopPoster represents TL type `statsGroupTopPoster#9d04af9b`.
// Information about an active user in a supergroup
//
// See https://core.telegram.org/constructor/statsGroupTopPoster for reference.
type StatsGroupTopPoster struct {
	// User ID
	UserID int64
	// Number of messages for statisticsĀ¹ period in consideration
	//
	// Links:
	//  1) https://core.telegram.org/api/stats
	Messages int
	// Average number of characters per message
	AvgChars int
}

// StatsGroupTopPosterTypeID is TL type id of StatsGroupTopPoster.
const StatsGroupTopPosterTypeID = 0x9d04af9b

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

func ( *StatsGroupTopPoster) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.Messages == 0) {
		return false
	}
	if !(.AvgChars == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StatsGroupTopPoster from given interface.
func ( *StatsGroupTopPoster) ( interface {
	() ( int64)
	() ( int)
	() ( int)
}) {
	.UserID = .()
	.Messages = .()
	.AvgChars = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StatsGroupTopPoster) () tdp.Type {
	 := tdp.Type{
		Name: "statsGroupTopPoster",
		ID:   StatsGroupTopPosterTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Messages",
			SchemaName: "messages",
		},
		{
			Name:       "AvgChars",
			SchemaName: "avg_chars",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StatsGroupTopPoster) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode statsGroupTopPoster#9d04af9b as nil")
	}
	.PutID(StatsGroupTopPosterTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsGroupTopPoster) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode statsGroupTopPoster#9d04af9b as nil")
	}
	.PutLong(.UserID)
	.PutInt(.Messages)
	.PutInt(.AvgChars)
	return nil
}

// Decode implements bin.Decoder.
func ( *StatsGroupTopPoster) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode statsGroupTopPoster#9d04af9b to nil")
	}
	if  := .ConsumeID(StatsGroupTopPosterTypeID);  != nil {
		return fmt.Errorf("unable to decode statsGroupTopPoster#9d04af9b: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StatsGroupTopPoster) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode statsGroupTopPoster#9d04af9b to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode statsGroupTopPoster#9d04af9b: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode statsGroupTopPoster#9d04af9b: field messages: %w", )
		}
		.Messages = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode statsGroupTopPoster#9d04af9b: field avg_chars: %w", )
		}
		.AvgChars = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *StatsGroupTopPoster) () ( int64) {
	if  == nil {
		return
	}
	return .UserID
}

// GetMessages returns value of Messages field.
func ( *StatsGroupTopPoster) () ( int) {
	if  == nil {
		return
	}
	return .Messages
}

// GetAvgChars returns value of AvgChars field.
func ( *StatsGroupTopPoster) () ( int) {
	if  == nil {
		return
	}
	return .AvgChars
}