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 MessagesForwardMessagesRequest struct {
Flags bin .Fields
Silent bool
Background bool
WithMyScore bool
DropAuthor bool
DropMediaCaptions bool
Noforwards bool
FromPeer InputPeerClass
ID []int
RandomID []int64
ToPeer InputPeerClass
TopMsgID int
ScheduleDate int
SendAs InputPeerClass
}
const MessagesForwardMessagesRequestTypeID = 0xc661bbc4
var (
_ bin .Encoder = &MessagesForwardMessagesRequest {}
_ bin .Decoder = &MessagesForwardMessagesRequest {}
_ bin .BareEncoder = &MessagesForwardMessagesRequest {}
_ bin .BareDecoder = &MessagesForwardMessagesRequest {}
)
func (f *MessagesForwardMessagesRequest ) Zero () bool {
if f == nil {
return true
}
if !(f .Flags .Zero ()) {
return false
}
if !(f .Silent == false ) {
return false
}
if !(f .Background == false ) {
return false
}
if !(f .WithMyScore == false ) {
return false
}
if !(f .DropAuthor == false ) {
return false
}
if !(f .DropMediaCaptions == false ) {
return false
}
if !(f .Noforwards == false ) {
return false
}
if !(f .FromPeer == nil ) {
return false
}
if !(f .ID == nil ) {
return false
}
if !(f .RandomID == nil ) {
return false
}
if !(f .ToPeer == nil ) {
return false
}
if !(f .TopMsgID == 0 ) {
return false
}
if !(f .ScheduleDate == 0 ) {
return false
}
if !(f .SendAs == nil ) {
return false
}
return true
}
func (f *MessagesForwardMessagesRequest ) String () string {
if f == nil {
return "MessagesForwardMessagesRequest(nil)"
}
type Alias MessagesForwardMessagesRequest
return fmt .Sprintf ("MessagesForwardMessagesRequest%+v" , Alias (*f ))
}
func (f *MessagesForwardMessagesRequest ) FillFrom (from interface {
GetSilent () (value bool )
GetBackground () (value bool )
GetWithMyScore () (value bool )
GetDropAuthor () (value bool )
GetDropMediaCaptions () (value bool )
GetNoforwards () (value bool )
GetFromPeer () (value InputPeerClass )
GetID () (value []int )
GetRandomID () (value []int64 )
GetToPeer () (value InputPeerClass )
GetTopMsgID () (value int , ok bool )
GetScheduleDate () (value int , ok bool )
GetSendAs () (value InputPeerClass , ok bool )
}) {
f .Silent = from .GetSilent ()
f .Background = from .GetBackground ()
f .WithMyScore = from .GetWithMyScore ()
f .DropAuthor = from .GetDropAuthor ()
f .DropMediaCaptions = from .GetDropMediaCaptions ()
f .Noforwards = from .GetNoforwards ()
f .FromPeer = from .GetFromPeer ()
f .ID = from .GetID ()
f .RandomID = from .GetRandomID ()
f .ToPeer = from .GetToPeer ()
if val , ok := from .GetTopMsgID (); ok {
f .TopMsgID = val
}
if val , ok := from .GetScheduleDate (); ok {
f .ScheduleDate = val
}
if val , ok := from .GetSendAs (); ok {
f .SendAs = val
}
}
func (*MessagesForwardMessagesRequest ) TypeID () uint32 {
return MessagesForwardMessagesRequestTypeID
}
func (*MessagesForwardMessagesRequest ) TypeName () string {
return "messages.forwardMessages"
}
func (f *MessagesForwardMessagesRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.forwardMessages" ,
ID : MessagesForwardMessagesRequestTypeID ,
}
if f == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Silent" ,
SchemaName : "silent" ,
Null : !f .Flags .Has (5 ),
},
{
Name : "Background" ,
SchemaName : "background" ,
Null : !f .Flags .Has (6 ),
},
{
Name : "WithMyScore" ,
SchemaName : "with_my_score" ,
Null : !f .Flags .Has (8 ),
},
{
Name : "DropAuthor" ,
SchemaName : "drop_author" ,
Null : !f .Flags .Has (11 ),
},
{
Name : "DropMediaCaptions" ,
SchemaName : "drop_media_captions" ,
Null : !f .Flags .Has (12 ),
},
{
Name : "Noforwards" ,
SchemaName : "noforwards" ,
Null : !f .Flags .Has (14 ),
},
{
Name : "FromPeer" ,
SchemaName : "from_peer" ,
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "ToPeer" ,
SchemaName : "to_peer" ,
},
{
Name : "TopMsgID" ,
SchemaName : "top_msg_id" ,
Null : !f .Flags .Has (9 ),
},
{
Name : "ScheduleDate" ,
SchemaName : "schedule_date" ,
Null : !f .Flags .Has (10 ),
},
{
Name : "SendAs" ,
SchemaName : "send_as" ,
Null : !f .Flags .Has (13 ),
},
}
return typ
}
func (f *MessagesForwardMessagesRequest ) SetFlags () {
if !(f .Silent == false ) {
f .Flags .Set (5 )
}
if !(f .Background == false ) {
f .Flags .Set (6 )
}
if !(f .WithMyScore == false ) {
f .Flags .Set (8 )
}
if !(f .DropAuthor == false ) {
f .Flags .Set (11 )
}
if !(f .DropMediaCaptions == false ) {
f .Flags .Set (12 )
}
if !(f .Noforwards == false ) {
f .Flags .Set (14 )
}
if !(f .TopMsgID == 0 ) {
f .Flags .Set (9 )
}
if !(f .ScheduleDate == 0 ) {
f .Flags .Set (10 )
}
if !(f .SendAs == nil ) {
f .Flags .Set (13 )
}
}
func (f *MessagesForwardMessagesRequest ) Encode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode messages.forwardMessages#c661bbc4 as nil" )
}
b .PutID (MessagesForwardMessagesRequestTypeID )
return f .EncodeBare (b )
}
func (f *MessagesForwardMessagesRequest ) EncodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode messages.forwardMessages#c661bbc4 as nil" )
}
f .SetFlags ()
if err := f .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.forwardMessages#c661bbc4: field flags: %w" , err )
}
if f .FromPeer == nil {
return fmt .Errorf ("unable to encode messages.forwardMessages#c661bbc4: field from_peer is nil" )
}
if err := f .FromPeer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.forwardMessages#c661bbc4: field from_peer: %w" , err )
}
b .PutVectorHeader (len (f .ID ))
for _ , v := range f .ID {
b .PutInt (v )
}
b .PutVectorHeader (len (f .RandomID ))
for _ , v := range f .RandomID {
b .PutLong (v )
}
if f .ToPeer == nil {
return fmt .Errorf ("unable to encode messages.forwardMessages#c661bbc4: field to_peer is nil" )
}
if err := f .ToPeer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.forwardMessages#c661bbc4: field to_peer: %w" , err )
}
if f .Flags .Has (9 ) {
b .PutInt (f .TopMsgID )
}
if f .Flags .Has (10 ) {
b .PutInt (f .ScheduleDate )
}
if f .Flags .Has (13 ) {
if f .SendAs == nil {
return fmt .Errorf ("unable to encode messages.forwardMessages#c661bbc4: field send_as is nil" )
}
if err := f .SendAs .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.forwardMessages#c661bbc4: field send_as: %w" , err )
}
}
return nil
}
func (f *MessagesForwardMessagesRequest ) Decode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode messages.forwardMessages#c661bbc4 to nil" )
}
if err := b .ConsumeID (MessagesForwardMessagesRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: %w" , err )
}
return f .DecodeBare (b )
}
func (f *MessagesForwardMessagesRequest ) DecodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode messages.forwardMessages#c661bbc4 to nil" )
}
{
if err := f .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field flags: %w" , err )
}
}
f .Silent = f .Flags .Has (5 )
f .Background = f .Flags .Has (6 )
f .WithMyScore = f .Flags .Has (8 )
f .DropAuthor = f .Flags .Has (11 )
f .DropMediaCaptions = f .Flags .Has (12 )
f .Noforwards = f .Flags .Has (14 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field from_peer: %w" , err )
}
f .FromPeer = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field id: %w" , err )
}
if headerLen > 0 {
f .ID = make ([]int , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field id: %w" , err )
}
f .ID = append (f .ID , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field random_id: %w" , err )
}
if headerLen > 0 {
f .RandomID = make ([]int64 , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field random_id: %w" , err )
}
f .RandomID = append (f .RandomID , value )
}
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field to_peer: %w" , err )
}
f .ToPeer = value
}
if f .Flags .Has (9 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field top_msg_id: %w" , err )
}
f .TopMsgID = value
}
if f .Flags .Has (10 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field schedule_date: %w" , err )
}
f .ScheduleDate = value
}
if f .Flags .Has (13 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.forwardMessages#c661bbc4: field send_as: %w" , err )
}
f .SendAs = value
}
return nil
}
func (f *MessagesForwardMessagesRequest ) SetSilent (value bool ) {
if value {
f .Flags .Set (5 )
f .Silent = true
} else {
f .Flags .Unset (5 )
f .Silent = false
}
}
func (f *MessagesForwardMessagesRequest ) GetSilent () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (5 )
}
func (f *MessagesForwardMessagesRequest ) SetBackground (value bool ) {
if value {
f .Flags .Set (6 )
f .Background = true
} else {
f .Flags .Unset (6 )
f .Background = false
}
}
func (f *MessagesForwardMessagesRequest ) GetBackground () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (6 )
}
func (f *MessagesForwardMessagesRequest ) SetWithMyScore (value bool ) {
if value {
f .Flags .Set (8 )
f .WithMyScore = true
} else {
f .Flags .Unset (8 )
f .WithMyScore = false
}
}
func (f *MessagesForwardMessagesRequest ) GetWithMyScore () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (8 )
}
func (f *MessagesForwardMessagesRequest ) SetDropAuthor (value bool ) {
if value {
f .Flags .Set (11 )
f .DropAuthor = true
} else {
f .Flags .Unset (11 )
f .DropAuthor = false
}
}
func (f *MessagesForwardMessagesRequest ) GetDropAuthor () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (11 )
}
func (f *MessagesForwardMessagesRequest ) SetDropMediaCaptions (value bool ) {
if value {
f .Flags .Set (12 )
f .DropMediaCaptions = true
} else {
f .Flags .Unset (12 )
f .DropMediaCaptions = false
}
}
func (f *MessagesForwardMessagesRequest ) GetDropMediaCaptions () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (12 )
}
func (f *MessagesForwardMessagesRequest ) SetNoforwards (value bool ) {
if value {
f .Flags .Set (14 )
f .Noforwards = true
} else {
f .Flags .Unset (14 )
f .Noforwards = false
}
}
func (f *MessagesForwardMessagesRequest ) GetNoforwards () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (14 )
}
func (f *MessagesForwardMessagesRequest ) GetFromPeer () (value InputPeerClass ) {
if f == nil {
return
}
return f .FromPeer
}
func (f *MessagesForwardMessagesRequest ) GetID () (value []int ) {
if f == nil {
return
}
return f .ID
}
func (f *MessagesForwardMessagesRequest ) GetRandomID () (value []int64 ) {
if f == nil {
return
}
return f .RandomID
}
func (f *MessagesForwardMessagesRequest ) GetToPeer () (value InputPeerClass ) {
if f == nil {
return
}
return f .ToPeer
}
func (f *MessagesForwardMessagesRequest ) SetTopMsgID (value int ) {
f .Flags .Set (9 )
f .TopMsgID = value
}
func (f *MessagesForwardMessagesRequest ) GetTopMsgID () (value int , ok bool ) {
if f == nil {
return
}
if !f .Flags .Has (9 ) {
return value , false
}
return f .TopMsgID , true
}
func (f *MessagesForwardMessagesRequest ) SetScheduleDate (value int ) {
f .Flags .Set (10 )
f .ScheduleDate = value
}
func (f *MessagesForwardMessagesRequest ) GetScheduleDate () (value int , ok bool ) {
if f == nil {
return
}
if !f .Flags .Has (10 ) {
return value , false
}
return f .ScheduleDate , true
}
func (f *MessagesForwardMessagesRequest ) SetSendAs (value InputPeerClass ) {
f .Flags .Set (13 )
f .SendAs = value
}
func (f *MessagesForwardMessagesRequest ) GetSendAs () (value InputPeerClass , ok bool ) {
if f == nil {
return
}
if !f .Flags .Has (13 ) {
return value , false
}
return f .SendAs , true
}
func (c *Client ) MessagesForwardMessages (ctx context .Context , request *MessagesForwardMessagesRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , 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 .