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"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type ConnectedBotStarRef struct {
Flags bin .Fields
Revoked bool
URL string
Date int
BotID int64
CommissionPermille int
DurationMonths int
Participants int64
Revenue int64
}
const ConnectedBotStarRefTypeID = 0x19a13f71
var (
_ bin .Encoder = &ConnectedBotStarRef {}
_ bin .Decoder = &ConnectedBotStarRef {}
_ bin .BareEncoder = &ConnectedBotStarRef {}
_ bin .BareDecoder = &ConnectedBotStarRef {}
)
func (c *ConnectedBotStarRef ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Revoked == false ) {
return false
}
if !(c .URL == "" ) {
return false
}
if !(c .Date == 0 ) {
return false
}
if !(c .BotID == 0 ) {
return false
}
if !(c .CommissionPermille == 0 ) {
return false
}
if !(c .DurationMonths == 0 ) {
return false
}
if !(c .Participants == 0 ) {
return false
}
if !(c .Revenue == 0 ) {
return false
}
return true
}
func (c *ConnectedBotStarRef ) String () string {
if c == nil {
return "ConnectedBotStarRef(nil)"
}
type Alias ConnectedBotStarRef
return fmt .Sprintf ("ConnectedBotStarRef%+v" , Alias (*c ))
}
func (c *ConnectedBotStarRef ) FillFrom (from interface {
GetRevoked () (value bool )
GetURL () (value string )
GetDate () (value int )
GetBotID () (value int64 )
GetCommissionPermille () (value int )
GetDurationMonths () (value int , ok bool )
GetParticipants () (value int64 )
GetRevenue () (value int64 )
}) {
c .Revoked = from .GetRevoked ()
c .URL = from .GetURL ()
c .Date = from .GetDate ()
c .BotID = from .GetBotID ()
c .CommissionPermille = from .GetCommissionPermille ()
if val , ok := from .GetDurationMonths (); ok {
c .DurationMonths = val
}
c .Participants = from .GetParticipants ()
c .Revenue = from .GetRevenue ()
}
func (*ConnectedBotStarRef ) TypeID () uint32 {
return ConnectedBotStarRefTypeID
}
func (*ConnectedBotStarRef ) TypeName () string {
return "connectedBotStarRef"
}
func (c *ConnectedBotStarRef ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "connectedBotStarRef" ,
ID : ConnectedBotStarRefTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Revoked" ,
SchemaName : "revoked" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "URL" ,
SchemaName : "url" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "BotID" ,
SchemaName : "bot_id" ,
},
{
Name : "CommissionPermille" ,
SchemaName : "commission_permille" ,
},
{
Name : "DurationMonths" ,
SchemaName : "duration_months" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Participants" ,
SchemaName : "participants" ,
},
{
Name : "Revenue" ,
SchemaName : "revenue" ,
},
}
return typ
}
func (c *ConnectedBotStarRef ) SetFlags () {
if !(c .Revoked == false ) {
c .Flags .Set (1 )
}
if !(c .DurationMonths == 0 ) {
c .Flags .Set (0 )
}
}
func (c *ConnectedBotStarRef ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode connectedBotStarRef#19a13f71 as nil" )
}
b .PutID (ConnectedBotStarRefTypeID )
return c .EncodeBare (b )
}
func (c *ConnectedBotStarRef ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode connectedBotStarRef#19a13f71 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode connectedBotStarRef#19a13f71: field flags: %w" , err )
}
b .PutString (c .URL )
b .PutInt (c .Date )
b .PutLong (c .BotID )
b .PutInt (c .CommissionPermille )
if c .Flags .Has (0 ) {
b .PutInt (c .DurationMonths )
}
b .PutLong (c .Participants )
b .PutLong (c .Revenue )
return nil
}
func (c *ConnectedBotStarRef ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode connectedBotStarRef#19a13f71 to nil" )
}
if err := b .ConsumeID (ConnectedBotStarRefTypeID ); err != nil {
return fmt .Errorf ("unable to decode connectedBotStarRef#19a13f71: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ConnectedBotStarRef ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode connectedBotStarRef#19a13f71 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode connectedBotStarRef#19a13f71: field flags: %w" , err )
}
}
c .Revoked = c .Flags .Has (1 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBotStarRef#19a13f71: field url: %w" , err )
}
c .URL = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBotStarRef#19a13f71: field date: %w" , err )
}
c .Date = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBotStarRef#19a13f71: field bot_id: %w" , err )
}
c .BotID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBotStarRef#19a13f71: field commission_permille: %w" , err )
}
c .CommissionPermille = value
}
if c .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBotStarRef#19a13f71: field duration_months: %w" , err )
}
c .DurationMonths = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBotStarRef#19a13f71: field participants: %w" , err )
}
c .Participants = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBotStarRef#19a13f71: field revenue: %w" , err )
}
c .Revenue = value
}
return nil
}
func (c *ConnectedBotStarRef ) SetRevoked (value bool ) {
if value {
c .Flags .Set (1 )
c .Revoked = true
} else {
c .Flags .Unset (1 )
c .Revoked = false
}
}
func (c *ConnectedBotStarRef ) GetRevoked () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (1 )
}
func (c *ConnectedBotStarRef ) GetURL () (value string ) {
if c == nil {
return
}
return c .URL
}
func (c *ConnectedBotStarRef ) GetDate () (value int ) {
if c == nil {
return
}
return c .Date
}
func (c *ConnectedBotStarRef ) GetBotID () (value int64 ) {
if c == nil {
return
}
return c .BotID
}
func (c *ConnectedBotStarRef ) GetCommissionPermille () (value int ) {
if c == nil {
return
}
return c .CommissionPermille
}
func (c *ConnectedBotStarRef ) SetDurationMonths (value int ) {
c .Flags .Set (0 )
c .DurationMonths = value
}
func (c *ConnectedBotStarRef ) GetDurationMonths () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .DurationMonths , true
}
func (c *ConnectedBotStarRef ) GetParticipants () (value int64 ) {
if c == nil {
return
}
return c .Participants
}
func (c *ConnectedBotStarRef ) GetRevenue () (value int64 ) {
if c == nil {
return
}
return c .Revenue
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .