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 MessagesUploadImportedMediaRequest struct {
Peer InputPeerClass
ImportID int64
FileName string
Media InputMediaClass
}
const MessagesUploadImportedMediaRequestTypeID = 0x2a862092
var (
_ bin .Encoder = &MessagesUploadImportedMediaRequest {}
_ bin .Decoder = &MessagesUploadImportedMediaRequest {}
_ bin .BareEncoder = &MessagesUploadImportedMediaRequest {}
_ bin .BareDecoder = &MessagesUploadImportedMediaRequest {}
)
func (u *MessagesUploadImportedMediaRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Peer == nil ) {
return false
}
if !(u .ImportID == 0 ) {
return false
}
if !(u .FileName == "" ) {
return false
}
if !(u .Media == nil ) {
return false
}
return true
}
func (u *MessagesUploadImportedMediaRequest ) String () string {
if u == nil {
return "MessagesUploadImportedMediaRequest(nil)"
}
type Alias MessagesUploadImportedMediaRequest
return fmt .Sprintf ("MessagesUploadImportedMediaRequest%+v" , Alias (*u ))
}
func (u *MessagesUploadImportedMediaRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetImportID () (value int64 )
GetFileName () (value string )
GetMedia () (value InputMediaClass )
}) {
u .Peer = from .GetPeer ()
u .ImportID = from .GetImportID ()
u .FileName = from .GetFileName ()
u .Media = from .GetMedia ()
}
func (*MessagesUploadImportedMediaRequest ) TypeID () uint32 {
return MessagesUploadImportedMediaRequestTypeID
}
func (*MessagesUploadImportedMediaRequest ) TypeName () string {
return "messages.uploadImportedMedia"
}
func (u *MessagesUploadImportedMediaRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.uploadImportedMedia" ,
ID : MessagesUploadImportedMediaRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ImportID" ,
SchemaName : "import_id" ,
},
{
Name : "FileName" ,
SchemaName : "file_name" ,
},
{
Name : "Media" ,
SchemaName : "media" ,
},
}
return typ
}
func (u *MessagesUploadImportedMediaRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode messages.uploadImportedMedia#2a862092 as nil" )
}
b .PutID (MessagesUploadImportedMediaRequestTypeID )
return u .EncodeBare (b )
}
func (u *MessagesUploadImportedMediaRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode messages.uploadImportedMedia#2a862092 as nil" )
}
if u .Peer == nil {
return fmt .Errorf ("unable to encode messages.uploadImportedMedia#2a862092: field peer is nil" )
}
if err := u .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.uploadImportedMedia#2a862092: field peer: %w" , err )
}
b .PutLong (u .ImportID )
b .PutString (u .FileName )
if u .Media == nil {
return fmt .Errorf ("unable to encode messages.uploadImportedMedia#2a862092: field media is nil" )
}
if err := u .Media .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.uploadImportedMedia#2a862092: field media: %w" , err )
}
return nil
}
func (u *MessagesUploadImportedMediaRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode messages.uploadImportedMedia#2a862092 to nil" )
}
if err := b .ConsumeID (MessagesUploadImportedMediaRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.uploadImportedMedia#2a862092: %w" , err )
}
return u .DecodeBare (b )
}
func (u *MessagesUploadImportedMediaRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode messages.uploadImportedMedia#2a862092 to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.uploadImportedMedia#2a862092: field peer: %w" , err )
}
u .Peer = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.uploadImportedMedia#2a862092: field import_id: %w" , err )
}
u .ImportID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.uploadImportedMedia#2a862092: field file_name: %w" , err )
}
u .FileName = value
}
{
value , err := DecodeInputMedia (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.uploadImportedMedia#2a862092: field media: %w" , err )
}
u .Media = value
}
return nil
}
func (u *MessagesUploadImportedMediaRequest ) GetPeer () (value InputPeerClass ) {
if u == nil {
return
}
return u .Peer
}
func (u *MessagesUploadImportedMediaRequest ) GetImportID () (value int64 ) {
if u == nil {
return
}
return u .ImportID
}
func (u *MessagesUploadImportedMediaRequest ) GetFileName () (value string ) {
if u == nil {
return
}
return u .FileName
}
func (u *MessagesUploadImportedMediaRequest ) GetMedia () (value InputMediaClass ) {
if u == nil {
return
}
return u .Media
}
func (c *Client ) MessagesUploadImportedMedia (ctx context .Context , request *MessagesUploadImportedMediaRequest ) (MessageMediaClass , error ) {
var result MessageMediaBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .MessageMedia , 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 .