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 HelpEditUserInfoRequest struct {
UserID InputUserClass
Message string
Entities []MessageEntityClass
}
const HelpEditUserInfoRequestTypeID = 0x66b91b70
var (
_ bin .Encoder = &HelpEditUserInfoRequest {}
_ bin .Decoder = &HelpEditUserInfoRequest {}
_ bin .BareEncoder = &HelpEditUserInfoRequest {}
_ bin .BareDecoder = &HelpEditUserInfoRequest {}
)
func (e *HelpEditUserInfoRequest ) Zero () bool {
if e == nil {
return true
}
if !(e .UserID == nil ) {
return false
}
if !(e .Message == "" ) {
return false
}
if !(e .Entities == nil ) {
return false
}
return true
}
func (e *HelpEditUserInfoRequest ) String () string {
if e == nil {
return "HelpEditUserInfoRequest(nil)"
}
type Alias HelpEditUserInfoRequest
return fmt .Sprintf ("HelpEditUserInfoRequest%+v" , Alias (*e ))
}
func (e *HelpEditUserInfoRequest ) FillFrom (from interface {
GetUserID () (value InputUserClass )
GetMessage () (value string )
GetEntities () (value []MessageEntityClass )
}) {
e .UserID = from .GetUserID ()
e .Message = from .GetMessage ()
e .Entities = from .GetEntities ()
}
func (*HelpEditUserInfoRequest ) TypeID () uint32 {
return HelpEditUserInfoRequestTypeID
}
func (*HelpEditUserInfoRequest ) TypeName () string {
return "help.editUserInfo"
}
func (e *HelpEditUserInfoRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.editUserInfo" ,
ID : HelpEditUserInfoRequestTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
},
{
Name : "Entities" ,
SchemaName : "entities" ,
},
}
return typ
}
func (e *HelpEditUserInfoRequest ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode help.editUserInfo#66b91b70 as nil" )
}
b .PutID (HelpEditUserInfoRequestTypeID )
return e .EncodeBare (b )
}
func (e *HelpEditUserInfoRequest ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode help.editUserInfo#66b91b70 as nil" )
}
if e .UserID == nil {
return fmt .Errorf ("unable to encode help.editUserInfo#66b91b70: field user_id is nil" )
}
if err := e .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.editUserInfo#66b91b70: field user_id: %w" , err )
}
b .PutString (e .Message )
b .PutVectorHeader (len (e .Entities ))
for idx , v := range e .Entities {
if v == nil {
return fmt .Errorf ("unable to encode help.editUserInfo#66b91b70: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.editUserInfo#66b91b70: field entities element with index %d: %w" , idx , err )
}
}
return nil
}
func (e *HelpEditUserInfoRequest ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode help.editUserInfo#66b91b70 to nil" )
}
if err := b .ConsumeID (HelpEditUserInfoRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.editUserInfo#66b91b70: %w" , err )
}
return e .DecodeBare (b )
}
func (e *HelpEditUserInfoRequest ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode help.editUserInfo#66b91b70 to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode help.editUserInfo#66b91b70: field user_id: %w" , err )
}
e .UserID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode help.editUserInfo#66b91b70: field message: %w" , err )
}
e .Message = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.editUserInfo#66b91b70: field entities: %w" , err )
}
if headerLen > 0 {
e .Entities = make ([]MessageEntityClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessageEntity (b )
if err != nil {
return fmt .Errorf ("unable to decode help.editUserInfo#66b91b70: field entities: %w" , err )
}
e .Entities = append (e .Entities , value )
}
}
return nil
}
func (e *HelpEditUserInfoRequest ) GetUserID () (value InputUserClass ) {
if e == nil {
return
}
return e .UserID
}
func (e *HelpEditUserInfoRequest ) GetMessage () (value string ) {
if e == nil {
return
}
return e .Message
}
func (e *HelpEditUserInfoRequest ) GetEntities () (value []MessageEntityClass ) {
if e == nil {
return
}
return e .Entities
}
func (e *HelpEditUserInfoRequest ) MapEntities () (value MessageEntityClassArray ) {
return MessageEntityClassArray (e .Entities )
}
func (c *Client ) HelpEditUserInfo (ctx context .Context , request *HelpEditUserInfoRequest ) (HelpUserInfoClass , error ) {
var result HelpUserInfoBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .UserInfo , 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 .