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 CommunityPeer struct {
Flags bin .Fields
CanViewHistory bool
Visible bool
Peer PeerClass
}
const CommunityPeerTypeID = 0x76141ebd
var (
_ bin .Encoder = &CommunityPeer {}
_ bin .Decoder = &CommunityPeer {}
_ bin .BareEncoder = &CommunityPeer {}
_ bin .BareDecoder = &CommunityPeer {}
)
func (c *CommunityPeer ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .CanViewHistory == false ) {
return false
}
if !(c .Visible == false ) {
return false
}
if !(c .Peer == nil ) {
return false
}
return true
}
func (c *CommunityPeer ) String () string {
if c == nil {
return "CommunityPeer(nil)"
}
type Alias CommunityPeer
return fmt .Sprintf ("CommunityPeer%+v" , Alias (*c ))
}
func (c *CommunityPeer ) FillFrom (from interface {
GetCanViewHistory () (value bool )
GetVisible () (value bool , ok bool )
GetPeer () (value PeerClass )
}) {
c .CanViewHistory = from .GetCanViewHistory ()
if val , ok := from .GetVisible (); ok {
c .Visible = val
}
c .Peer = from .GetPeer ()
}
func (*CommunityPeer ) TypeID () uint32 {
return CommunityPeerTypeID
}
func (*CommunityPeer ) TypeName () string {
return "communityPeer"
}
func (c *CommunityPeer ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "communityPeer" ,
ID : CommunityPeerTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CanViewHistory" ,
SchemaName : "can_view_history" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Visible" ,
SchemaName : "visible" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
}
return typ
}
func (c *CommunityPeer ) SetFlags () {
if !(c .CanViewHistory == false ) {
c .Flags .Set (2 )
}
if !(c .Visible == false ) {
c .Flags .Set (0 )
}
}
func (c *CommunityPeer ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode communityPeer#76141ebd as nil" )
}
b .PutID (CommunityPeerTypeID )
return c .EncodeBare (b )
}
func (c *CommunityPeer ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode communityPeer#76141ebd as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode communityPeer#76141ebd: field flags: %w" , err )
}
if c .Flags .Has (0 ) {
b .PutBool (c .Visible )
}
if c .Peer == nil {
return fmt .Errorf ("unable to encode communityPeer#76141ebd: field peer is nil" )
}
if err := c .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode communityPeer#76141ebd: field peer: %w" , err )
}
return nil
}
func (c *CommunityPeer ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode communityPeer#76141ebd to nil" )
}
if err := b .ConsumeID (CommunityPeerTypeID ); err != nil {
return fmt .Errorf ("unable to decode communityPeer#76141ebd: %w" , err )
}
return c .DecodeBare (b )
}
func (c *CommunityPeer ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode communityPeer#76141ebd to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode communityPeer#76141ebd: field flags: %w" , err )
}
}
c .CanViewHistory = c .Flags .Has (2 )
if c .Flags .Has (0 ) {
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode communityPeer#76141ebd: field visible: %w" , err )
}
c .Visible = value
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode communityPeer#76141ebd: field peer: %w" , err )
}
c .Peer = value
}
return nil
}
func (c *CommunityPeer ) SetCanViewHistory (value bool ) {
if value {
c .Flags .Set (2 )
c .CanViewHistory = true
} else {
c .Flags .Unset (2 )
c .CanViewHistory = false
}
}
func (c *CommunityPeer ) GetCanViewHistory () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (2 )
}
func (c *CommunityPeer ) SetVisible (value bool ) {
c .Flags .Set (0 )
c .Visible = value
}
func (c *CommunityPeer ) GetVisible () (value bool , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .Visible , true
}
func (c *CommunityPeer ) GetPeer () (value PeerClass ) {
if c == nil {
return
}
return c .Peer
}
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 .