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 MessagesAddChatUserRequest struct {
ChatID int64
UserID InputUserClass
FwdLimit int
}
const MessagesAddChatUserRequestTypeID = 0xcbc6d107
var (
_ bin .Encoder = &MessagesAddChatUserRequest {}
_ bin .Decoder = &MessagesAddChatUserRequest {}
_ bin .BareEncoder = &MessagesAddChatUserRequest {}
_ bin .BareDecoder = &MessagesAddChatUserRequest {}
)
func (a *MessagesAddChatUserRequest ) Zero () bool {
if a == nil {
return true
}
if !(a .ChatID == 0 ) {
return false
}
if !(a .UserID == nil ) {
return false
}
if !(a .FwdLimit == 0 ) {
return false
}
return true
}
func (a *MessagesAddChatUserRequest ) String () string {
if a == nil {
return "MessagesAddChatUserRequest(nil)"
}
type Alias MessagesAddChatUserRequest
return fmt .Sprintf ("MessagesAddChatUserRequest%+v" , Alias (*a ))
}
func (a *MessagesAddChatUserRequest ) FillFrom (from interface {
GetChatID () (value int64 )
GetUserID () (value InputUserClass )
GetFwdLimit () (value int )
}) {
a .ChatID = from .GetChatID ()
a .UserID = from .GetUserID ()
a .FwdLimit = from .GetFwdLimit ()
}
func (*MessagesAddChatUserRequest ) TypeID () uint32 {
return MessagesAddChatUserRequestTypeID
}
func (*MessagesAddChatUserRequest ) TypeName () string {
return "messages.addChatUser"
}
func (a *MessagesAddChatUserRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.addChatUser" ,
ID : MessagesAddChatUserRequestTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ChatID" ,
SchemaName : "chat_id" ,
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "FwdLimit" ,
SchemaName : "fwd_limit" ,
},
}
return typ
}
func (a *MessagesAddChatUserRequest ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode messages.addChatUser#cbc6d107 as nil" )
}
b .PutID (MessagesAddChatUserRequestTypeID )
return a .EncodeBare (b )
}
func (a *MessagesAddChatUserRequest ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode messages.addChatUser#cbc6d107 as nil" )
}
b .PutLong (a .ChatID )
if a .UserID == nil {
return fmt .Errorf ("unable to encode messages.addChatUser#cbc6d107: field user_id is nil" )
}
if err := a .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.addChatUser#cbc6d107: field user_id: %w" , err )
}
b .PutInt (a .FwdLimit )
return nil
}
func (a *MessagesAddChatUserRequest ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode messages.addChatUser#cbc6d107 to nil" )
}
if err := b .ConsumeID (MessagesAddChatUserRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.addChatUser#cbc6d107: %w" , err )
}
return a .DecodeBare (b )
}
func (a *MessagesAddChatUserRequest ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode messages.addChatUser#cbc6d107 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.addChatUser#cbc6d107: field chat_id: %w" , err )
}
a .ChatID = value
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.addChatUser#cbc6d107: field user_id: %w" , err )
}
a .UserID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.addChatUser#cbc6d107: field fwd_limit: %w" , err )
}
a .FwdLimit = value
}
return nil
}
func (a *MessagesAddChatUserRequest ) GetChatID () (value int64 ) {
if a == nil {
return
}
return a .ChatID
}
func (a *MessagesAddChatUserRequest ) GetUserID () (value InputUserClass ) {
if a == nil {
return
}
return a .UserID
}
func (a *MessagesAddChatUserRequest ) GetFwdLimit () (value int ) {
if a == nil {
return
}
return a .FwdLimit
}
func (c *Client ) MessagesAddChatUser (ctx context .Context , request *MessagesAddChatUserRequest ) (*MessagesInvitedUsers , error ) {
var result MessagesInvitedUsers
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , nil
}
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 .