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 ContactsBlockRequest struct {
Flags bin .Fields
MyStoriesFrom bool
ID InputPeerClass
}
const ContactsBlockRequestTypeID = 0x2e2e8734
var (
_ bin .Encoder = &ContactsBlockRequest {}
_ bin .Decoder = &ContactsBlockRequest {}
_ bin .BareEncoder = &ContactsBlockRequest {}
_ bin .BareDecoder = &ContactsBlockRequest {}
)
func (b *ContactsBlockRequest ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .MyStoriesFrom == false ) {
return false
}
if !(b .ID == nil ) {
return false
}
return true
}
func (b *ContactsBlockRequest ) String () string {
if b == nil {
return "ContactsBlockRequest(nil)"
}
type Alias ContactsBlockRequest
return fmt .Sprintf ("ContactsBlockRequest%+v" , Alias (*b ))
}
func (b *ContactsBlockRequest ) FillFrom (from interface {
GetMyStoriesFrom () (value bool )
GetID () (value InputPeerClass )
}) {
b .MyStoriesFrom = from .GetMyStoriesFrom ()
b .ID = from .GetID ()
}
func (*ContactsBlockRequest ) TypeID () uint32 {
return ContactsBlockRequestTypeID
}
func (*ContactsBlockRequest ) TypeName () string {
return "contacts.block"
}
func (b *ContactsBlockRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.block" ,
ID : ContactsBlockRequestTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "MyStoriesFrom" ,
SchemaName : "my_stories_from" ,
Null : !b .Flags .Has (0 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (b *ContactsBlockRequest ) SetFlags () {
if !(b .MyStoriesFrom == false ) {
b .Flags .Set (0 )
}
}
func (b *ContactsBlockRequest ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode contacts.block#2e2e8734 as nil" )
}
buf .PutID (ContactsBlockRequestTypeID )
return b .EncodeBare (buf )
}
func (b *ContactsBlockRequest ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode contacts.block#2e2e8734 as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode contacts.block#2e2e8734: field flags: %w" , err )
}
if b .ID == nil {
return fmt .Errorf ("unable to encode contacts.block#2e2e8734: field id is nil" )
}
if err := b .ID .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode contacts.block#2e2e8734: field id: %w" , err )
}
return nil
}
func (b *ContactsBlockRequest ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode contacts.block#2e2e8734 to nil" )
}
if err := buf .ConsumeID (ContactsBlockRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.block#2e2e8734: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *ContactsBlockRequest ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode contacts.block#2e2e8734 to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode contacts.block#2e2e8734: field flags: %w" , err )
}
}
b .MyStoriesFrom = b .Flags .Has (0 )
{
value , err := DecodeInputPeer (buf )
if err != nil {
return fmt .Errorf ("unable to decode contacts.block#2e2e8734: field id: %w" , err )
}
b .ID = value
}
return nil
}
func (b *ContactsBlockRequest ) SetMyStoriesFrom (value bool ) {
if value {
b .Flags .Set (0 )
b .MyStoriesFrom = true
} else {
b .Flags .Unset (0 )
b .MyStoriesFrom = false
}
}
func (b *ContactsBlockRequest ) GetMyStoriesFrom () (value bool ) {
if b == nil {
return
}
return b .Flags .Has (0 )
}
func (b *ContactsBlockRequest ) GetID () (value InputPeerClass ) {
if b == nil {
return
}
return b .ID
}
func (c *Client ) ContactsBlock (ctx context .Context , request *ContactsBlockRequest ) (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 .