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 ContactsSetBlockedRequest struct {
Flags bin .Fields
MyStoriesFrom bool
ID []InputPeerClass
Limit int
}
const ContactsSetBlockedRequestTypeID = 0x94c65c76
var (
_ bin .Encoder = &ContactsSetBlockedRequest {}
_ bin .Decoder = &ContactsSetBlockedRequest {}
_ bin .BareEncoder = &ContactsSetBlockedRequest {}
_ bin .BareDecoder = &ContactsSetBlockedRequest {}
)
func (s *ContactsSetBlockedRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .MyStoriesFrom == false ) {
return false
}
if !(s .ID == nil ) {
return false
}
if !(s .Limit == 0 ) {
return false
}
return true
}
func (s *ContactsSetBlockedRequest ) String () string {
if s == nil {
return "ContactsSetBlockedRequest(nil)"
}
type Alias ContactsSetBlockedRequest
return fmt .Sprintf ("ContactsSetBlockedRequest%+v" , Alias (*s ))
}
func (s *ContactsSetBlockedRequest ) FillFrom (from interface {
GetMyStoriesFrom () (value bool )
GetID () (value []InputPeerClass )
GetLimit () (value int )
}) {
s .MyStoriesFrom = from .GetMyStoriesFrom ()
s .ID = from .GetID ()
s .Limit = from .GetLimit ()
}
func (*ContactsSetBlockedRequest ) TypeID () uint32 {
return ContactsSetBlockedRequestTypeID
}
func (*ContactsSetBlockedRequest ) TypeName () string {
return "contacts.setBlocked"
}
func (s *ContactsSetBlockedRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.setBlocked" ,
ID : ContactsSetBlockedRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "MyStoriesFrom" ,
SchemaName : "my_stories_from" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
}
return typ
}
func (s *ContactsSetBlockedRequest ) SetFlags () {
if !(s .MyStoriesFrom == false ) {
s .Flags .Set (0 )
}
}
func (s *ContactsSetBlockedRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode contacts.setBlocked#94c65c76 as nil" )
}
b .PutID (ContactsSetBlockedRequestTypeID )
return s .EncodeBare (b )
}
func (s *ContactsSetBlockedRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode contacts.setBlocked#94c65c76 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.setBlocked#94c65c76: field flags: %w" , err )
}
b .PutVectorHeader (len (s .ID ))
for idx , v := range s .ID {
if v == nil {
return fmt .Errorf ("unable to encode contacts.setBlocked#94c65c76: field id element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.setBlocked#94c65c76: field id element with index %d: %w" , idx , err )
}
}
b .PutInt (s .Limit )
return nil
}
func (s *ContactsSetBlockedRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode contacts.setBlocked#94c65c76 to nil" )
}
if err := b .ConsumeID (ContactsSetBlockedRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.setBlocked#94c65c76: %w" , err )
}
return s .DecodeBare (b )
}
func (s *ContactsSetBlockedRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode contacts.setBlocked#94c65c76 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode contacts.setBlocked#94c65c76: field flags: %w" , err )
}
}
s .MyStoriesFrom = s .Flags .Has (0 )
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.setBlocked#94c65c76: field id: %w" , err )
}
if headerLen > 0 {
s .ID = make ([]InputPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode contacts.setBlocked#94c65c76: field id: %w" , err )
}
s .ID = append (s .ID , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.setBlocked#94c65c76: field limit: %w" , err )
}
s .Limit = value
}
return nil
}
func (s *ContactsSetBlockedRequest ) SetMyStoriesFrom (value bool ) {
if value {
s .Flags .Set (0 )
s .MyStoriesFrom = true
} else {
s .Flags .Unset (0 )
s .MyStoriesFrom = false
}
}
func (s *ContactsSetBlockedRequest ) GetMyStoriesFrom () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *ContactsSetBlockedRequest ) GetID () (value []InputPeerClass ) {
if s == nil {
return
}
return s .ID
}
func (s *ContactsSetBlockedRequest ) GetLimit () (value int ) {
if s == nil {
return
}
return s .Limit
}
func (s *ContactsSetBlockedRequest ) MapID () (value InputPeerClassArray ) {
return InputPeerClassArray (s .ID )
}
func (c *Client ) ContactsSetBlocked (ctx context .Context , request *ContactsSetBlockedRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , nil
}
The pages are generated with Golds v0.6.7 . (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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .