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 MessagesEditChatAdminRequest struct {
ChatID int64
UserID InputUserClass
IsAdmin bool
}
const MessagesEditChatAdminRequestTypeID = 0xa85bd1c2
var (
_ bin .Encoder = &MessagesEditChatAdminRequest {}
_ bin .Decoder = &MessagesEditChatAdminRequest {}
_ bin .BareEncoder = &MessagesEditChatAdminRequest {}
_ bin .BareDecoder = &MessagesEditChatAdminRequest {}
)
func (e *MessagesEditChatAdminRequest ) Zero () bool {
if e == nil {
return true
}
if !(e .ChatID == 0 ) {
return false
}
if !(e .UserID == nil ) {
return false
}
if !(e .IsAdmin == false ) {
return false
}
return true
}
func (e *MessagesEditChatAdminRequest ) String () string {
if e == nil {
return "MessagesEditChatAdminRequest(nil)"
}
type Alias MessagesEditChatAdminRequest
return fmt .Sprintf ("MessagesEditChatAdminRequest%+v" , Alias (*e ))
}
func (e *MessagesEditChatAdminRequest ) FillFrom (from interface {
GetChatID () (value int64 )
GetUserID () (value InputUserClass )
GetIsAdmin () (value bool )
}) {
e .ChatID = from .GetChatID ()
e .UserID = from .GetUserID ()
e .IsAdmin = from .GetIsAdmin ()
}
func (*MessagesEditChatAdminRequest ) TypeID () uint32 {
return MessagesEditChatAdminRequestTypeID
}
func (*MessagesEditChatAdminRequest ) TypeName () string {
return "messages.editChatAdmin"
}
func (e *MessagesEditChatAdminRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.editChatAdmin" ,
ID : MessagesEditChatAdminRequestTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ChatID" ,
SchemaName : "chat_id" ,
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "IsAdmin" ,
SchemaName : "is_admin" ,
},
}
return typ
}
func (e *MessagesEditChatAdminRequest ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.editChatAdmin#a85bd1c2 as nil" )
}
b .PutID (MessagesEditChatAdminRequestTypeID )
return e .EncodeBare (b )
}
func (e *MessagesEditChatAdminRequest ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.editChatAdmin#a85bd1c2 as nil" )
}
b .PutLong (e .ChatID )
if e .UserID == nil {
return fmt .Errorf ("unable to encode messages.editChatAdmin#a85bd1c2: field user_id is nil" )
}
if err := e .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editChatAdmin#a85bd1c2: field user_id: %w" , err )
}
b .PutBool (e .IsAdmin )
return nil
}
func (e *MessagesEditChatAdminRequest ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.editChatAdmin#a85bd1c2 to nil" )
}
if err := b .ConsumeID (MessagesEditChatAdminRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.editChatAdmin#a85bd1c2: %w" , err )
}
return e .DecodeBare (b )
}
func (e *MessagesEditChatAdminRequest ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.editChatAdmin#a85bd1c2 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.editChatAdmin#a85bd1c2: field chat_id: %w" , err )
}
e .ChatID = value
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.editChatAdmin#a85bd1c2: field user_id: %w" , err )
}
e .UserID = value
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode messages.editChatAdmin#a85bd1c2: field is_admin: %w" , err )
}
e .IsAdmin = value
}
return nil
}
func (e *MessagesEditChatAdminRequest ) GetChatID () (value int64 ) {
if e == nil {
return
}
return e .ChatID
}
func (e *MessagesEditChatAdminRequest ) GetUserID () (value InputUserClass ) {
if e == nil {
return
}
return e .UserID
}
func (e *MessagesEditChatAdminRequest ) GetIsAdmin () (value bool ) {
if e == nil {
return
}
return e .IsAdmin
}
func (c *Client ) MessagesEditChatAdmin (ctx context .Context , request *MessagesEditChatAdminRequest ) (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 .