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 MessagesInitHistoryImportRequest struct {
Peer InputPeerClass
File InputFileClass
MediaCount int
}
const MessagesInitHistoryImportRequestTypeID = 0x34090c3b
var (
_ bin .Encoder = &MessagesInitHistoryImportRequest {}
_ bin .Decoder = &MessagesInitHistoryImportRequest {}
_ bin .BareEncoder = &MessagesInitHistoryImportRequest {}
_ bin .BareDecoder = &MessagesInitHistoryImportRequest {}
)
func (i *MessagesInitHistoryImportRequest ) Zero () bool {
if i == nil {
return true
}
if !(i .Peer == nil ) {
return false
}
if !(i .File == nil ) {
return false
}
if !(i .MediaCount == 0 ) {
return false
}
return true
}
func (i *MessagesInitHistoryImportRequest ) String () string {
if i == nil {
return "MessagesInitHistoryImportRequest(nil)"
}
type Alias MessagesInitHistoryImportRequest
return fmt .Sprintf ("MessagesInitHistoryImportRequest%+v" , Alias (*i ))
}
func (i *MessagesInitHistoryImportRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetFile () (value InputFileClass )
GetMediaCount () (value int )
}) {
i .Peer = from .GetPeer ()
i .File = from .GetFile ()
i .MediaCount = from .GetMediaCount ()
}
func (*MessagesInitHistoryImportRequest ) TypeID () uint32 {
return MessagesInitHistoryImportRequestTypeID
}
func (*MessagesInitHistoryImportRequest ) TypeName () string {
return "messages.initHistoryImport"
}
func (i *MessagesInitHistoryImportRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.initHistoryImport" ,
ID : MessagesInitHistoryImportRequestTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "File" ,
SchemaName : "file" ,
},
{
Name : "MediaCount" ,
SchemaName : "media_count" ,
},
}
return typ
}
func (i *MessagesInitHistoryImportRequest ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode messages.initHistoryImport#34090c3b as nil" )
}
b .PutID (MessagesInitHistoryImportRequestTypeID )
return i .EncodeBare (b )
}
func (i *MessagesInitHistoryImportRequest ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode messages.initHistoryImport#34090c3b as nil" )
}
if i .Peer == nil {
return fmt .Errorf ("unable to encode messages.initHistoryImport#34090c3b: field peer is nil" )
}
if err := i .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.initHistoryImport#34090c3b: field peer: %w" , err )
}
if i .File == nil {
return fmt .Errorf ("unable to encode messages.initHistoryImport#34090c3b: field file is nil" )
}
if err := i .File .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.initHistoryImport#34090c3b: field file: %w" , err )
}
b .PutInt (i .MediaCount )
return nil
}
func (i *MessagesInitHistoryImportRequest ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode messages.initHistoryImport#34090c3b to nil" )
}
if err := b .ConsumeID (MessagesInitHistoryImportRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.initHistoryImport#34090c3b: %w" , err )
}
return i .DecodeBare (b )
}
func (i *MessagesInitHistoryImportRequest ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode messages.initHistoryImport#34090c3b to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.initHistoryImport#34090c3b: field peer: %w" , err )
}
i .Peer = value
}
{
value , err := DecodeInputFile (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.initHistoryImport#34090c3b: field file: %w" , err )
}
i .File = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.initHistoryImport#34090c3b: field media_count: %w" , err )
}
i .MediaCount = value
}
return nil
}
func (i *MessagesInitHistoryImportRequest ) GetPeer () (value InputPeerClass ) {
if i == nil {
return
}
return i .Peer
}
func (i *MessagesInitHistoryImportRequest ) GetFile () (value InputFileClass ) {
if i == nil {
return
}
return i .File
}
func (i *MessagesInitHistoryImportRequest ) GetMediaCount () (value int ) {
if i == nil {
return
}
return i .MediaCount
}
func (c *Client ) MessagesInitHistoryImport (ctx context .Context , request *MessagesInitHistoryImportRequest ) (*MessagesHistoryImport , error ) {
var result MessagesHistoryImport
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .