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 MessagesSendMessageRequest struct {
Flags bin .Fields
NoWebpage bool
Silent bool
Background bool
ClearDraft bool
Noforwards bool
UpdateStickersetsOrder bool
InvertMedia bool
Peer InputPeerClass
ReplyTo InputReplyToClass
Message string
RandomID int64
ReplyMarkup ReplyMarkupClass
Entities []MessageEntityClass
ScheduleDate int
SendAs InputPeerClass
}
const MessagesSendMessageRequestTypeID = 0x280d096f
var (
_ bin .Encoder = &MessagesSendMessageRequest {}
_ bin .Decoder = &MessagesSendMessageRequest {}
_ bin .BareEncoder = &MessagesSendMessageRequest {}
_ bin .BareDecoder = &MessagesSendMessageRequest {}
)
func (s *MessagesSendMessageRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .NoWebpage == false ) {
return false
}
if !(s .Silent == false ) {
return false
}
if !(s .Background == false ) {
return false
}
if !(s .ClearDraft == false ) {
return false
}
if !(s .Noforwards == false ) {
return false
}
if !(s .UpdateStickersetsOrder == false ) {
return false
}
if !(s .InvertMedia == false ) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .ReplyTo == nil ) {
return false
}
if !(s .Message == "" ) {
return false
}
if !(s .RandomID == 0 ) {
return false
}
if !(s .ReplyMarkup == nil ) {
return false
}
if !(s .Entities == nil ) {
return false
}
if !(s .ScheduleDate == 0 ) {
return false
}
if !(s .SendAs == nil ) {
return false
}
return true
}
func (s *MessagesSendMessageRequest ) String () string {
if s == nil {
return "MessagesSendMessageRequest(nil)"
}
type Alias MessagesSendMessageRequest
return fmt .Sprintf ("MessagesSendMessageRequest%+v" , Alias (*s ))
}
func (s *MessagesSendMessageRequest ) FillFrom (from interface {
GetNoWebpage () (value bool )
GetSilent () (value bool )
GetBackground () (value bool )
GetClearDraft () (value bool )
GetNoforwards () (value bool )
GetUpdateStickersetsOrder () (value bool )
GetInvertMedia () (value bool )
GetPeer () (value InputPeerClass )
GetReplyTo () (value InputReplyToClass , ok bool )
GetMessage () (value string )
GetRandomID () (value int64 )
GetReplyMarkup () (value ReplyMarkupClass , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
GetScheduleDate () (value int , ok bool )
GetSendAs () (value InputPeerClass , ok bool )
}) {
s .NoWebpage = from .GetNoWebpage ()
s .Silent = from .GetSilent ()
s .Background = from .GetBackground ()
s .ClearDraft = from .GetClearDraft ()
s .Noforwards = from .GetNoforwards ()
s .UpdateStickersetsOrder = from .GetUpdateStickersetsOrder ()
s .InvertMedia = from .GetInvertMedia ()
s .Peer = from .GetPeer ()
if val , ok := from .GetReplyTo (); ok {
s .ReplyTo = val
}
s .Message = from .GetMessage ()
s .RandomID = from .GetRandomID ()
if val , ok := from .GetReplyMarkup (); ok {
s .ReplyMarkup = val
}
if val , ok := from .GetEntities (); ok {
s .Entities = val
}
if val , ok := from .GetScheduleDate (); ok {
s .ScheduleDate = val
}
if val , ok := from .GetSendAs (); ok {
s .SendAs = val
}
}
func (*MessagesSendMessageRequest ) TypeID () uint32 {
return MessagesSendMessageRequestTypeID
}
func (*MessagesSendMessageRequest ) TypeName () string {
return "messages.sendMessage"
}
func (s *MessagesSendMessageRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.sendMessage" ,
ID : MessagesSendMessageRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "NoWebpage" ,
SchemaName : "no_webpage" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Silent" ,
SchemaName : "silent" ,
Null : !s .Flags .Has (5 ),
},
{
Name : "Background" ,
SchemaName : "background" ,
Null : !s .Flags .Has (6 ),
},
{
Name : "ClearDraft" ,
SchemaName : "clear_draft" ,
Null : !s .Flags .Has (7 ),
},
{
Name : "Noforwards" ,
SchemaName : "noforwards" ,
Null : !s .Flags .Has (14 ),
},
{
Name : "UpdateStickersetsOrder" ,
SchemaName : "update_stickersets_order" ,
Null : !s .Flags .Has (15 ),
},
{
Name : "InvertMedia" ,
SchemaName : "invert_media" ,
Null : !s .Flags .Has (16 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ReplyTo" ,
SchemaName : "reply_to" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Message" ,
SchemaName : "message" ,
},
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "ReplyMarkup" ,
SchemaName : "reply_markup" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !s .Flags .Has (3 ),
},
{
Name : "ScheduleDate" ,
SchemaName : "schedule_date" ,
Null : !s .Flags .Has (10 ),
},
{
Name : "SendAs" ,
SchemaName : "send_as" ,
Null : !s .Flags .Has (13 ),
},
}
return typ
}
func (s *MessagesSendMessageRequest ) SetFlags () {
if !(s .NoWebpage == false ) {
s .Flags .Set (1 )
}
if !(s .Silent == false ) {
s .Flags .Set (5 )
}
if !(s .Background == false ) {
s .Flags .Set (6 )
}
if !(s .ClearDraft == false ) {
s .Flags .Set (7 )
}
if !(s .Noforwards == false ) {
s .Flags .Set (14 )
}
if !(s .UpdateStickersetsOrder == false ) {
s .Flags .Set (15 )
}
if !(s .InvertMedia == false ) {
s .Flags .Set (16 )
}
if !(s .ReplyTo == nil ) {
s .Flags .Set (0 )
}
if !(s .ReplyMarkup == nil ) {
s .Flags .Set (2 )
}
if !(s .Entities == nil ) {
s .Flags .Set (3 )
}
if !(s .ScheduleDate == 0 ) {
s .Flags .Set (10 )
}
if !(s .SendAs == nil ) {
s .Flags .Set (13 )
}
}
func (s *MessagesSendMessageRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendMessage#280d096f as nil" )
}
b .PutID (MessagesSendMessageRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSendMessageRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendMessage#280d096f as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field flags: %w" , err )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field peer: %w" , err )
}
if s .Flags .Has (0 ) {
if s .ReplyTo == nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field reply_to is nil" )
}
if err := s .ReplyTo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field reply_to: %w" , err )
}
}
b .PutString (s .Message )
b .PutLong (s .RandomID )
if s .Flags .Has (2 ) {
if s .ReplyMarkup == nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field reply_markup is nil" )
}
if err := s .ReplyMarkup .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field reply_markup: %w" , err )
}
}
if s .Flags .Has (3 ) {
b .PutVectorHeader (len (s .Entities ))
for idx , v := range s .Entities {
if v == nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field entities element with index %d: %w" , idx , err )
}
}
}
if s .Flags .Has (10 ) {
b .PutInt (s .ScheduleDate )
}
if s .Flags .Has (13 ) {
if s .SendAs == nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field send_as is nil" )
}
if err := s .SendAs .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMessage#280d096f: field send_as: %w" , err )
}
}
return nil
}
func (s *MessagesSendMessageRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendMessage#280d096f to nil" )
}
if err := b .ConsumeID (MessagesSendMessageRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSendMessageRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendMessage#280d096f to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: field flags: %w" , err )
}
}
s .NoWebpage = s .Flags .Has (1 )
s .Silent = s .Flags .Has (5 )
s .Background = s .Flags .Has (6 )
s .ClearDraft = s .Flags .Has (7 )
s .Noforwards = s .Flags .Has (14 )
s .UpdateStickersetsOrder = s .Flags .Has (15 )
s .InvertMedia = s .Flags .Has (16 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: field peer: %w" , err )
}
s .Peer = value
}
if s .Flags .Has (0 ) {
value , err := DecodeInputReplyTo (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: field reply_to: %w" , err )
}
s .ReplyTo = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: field message: %w" , err )
}
s .Message = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: field random_id: %w" , err )
}
s .RandomID = value
}
if s .Flags .Has (2 ) {
value , err := DecodeReplyMarkup (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: field reply_markup: %w" , err )
}
s .ReplyMarkup = value
}
if s .Flags .Has (3 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: field entities: %w" , err )
}
if headerLen > 0 {
s .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 messages.sendMessage#280d096f: field entities: %w" , err )
}
s .Entities = append (s .Entities , value )
}
}
if s .Flags .Has (10 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: field schedule_date: %w" , err )
}
s .ScheduleDate = value
}
if s .Flags .Has (13 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMessage#280d096f: field send_as: %w" , err )
}
s .SendAs = value
}
return nil
}
func (s *MessagesSendMessageRequest ) SetNoWebpage (value bool ) {
if value {
s .Flags .Set (1 )
s .NoWebpage = true
} else {
s .Flags .Unset (1 )
s .NoWebpage = false
}
}
func (s *MessagesSendMessageRequest ) GetNoWebpage () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *MessagesSendMessageRequest ) SetSilent (value bool ) {
if value {
s .Flags .Set (5 )
s .Silent = true
} else {
s .Flags .Unset (5 )
s .Silent = false
}
}
func (s *MessagesSendMessageRequest ) GetSilent () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (5 )
}
func (s *MessagesSendMessageRequest ) SetBackground (value bool ) {
if value {
s .Flags .Set (6 )
s .Background = true
} else {
s .Flags .Unset (6 )
s .Background = false
}
}
func (s *MessagesSendMessageRequest ) GetBackground () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (6 )
}
func (s *MessagesSendMessageRequest ) SetClearDraft (value bool ) {
if value {
s .Flags .Set (7 )
s .ClearDraft = true
} else {
s .Flags .Unset (7 )
s .ClearDraft = false
}
}
func (s *MessagesSendMessageRequest ) GetClearDraft () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (7 )
}
func (s *MessagesSendMessageRequest ) SetNoforwards (value bool ) {
if value {
s .Flags .Set (14 )
s .Noforwards = true
} else {
s .Flags .Unset (14 )
s .Noforwards = false
}
}
func (s *MessagesSendMessageRequest ) GetNoforwards () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (14 )
}
func (s *MessagesSendMessageRequest ) SetUpdateStickersetsOrder (value bool ) {
if value {
s .Flags .Set (15 )
s .UpdateStickersetsOrder = true
} else {
s .Flags .Unset (15 )
s .UpdateStickersetsOrder = false
}
}
func (s *MessagesSendMessageRequest ) GetUpdateStickersetsOrder () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (15 )
}
func (s *MessagesSendMessageRequest ) SetInvertMedia (value bool ) {
if value {
s .Flags .Set (16 )
s .InvertMedia = true
} else {
s .Flags .Unset (16 )
s .InvertMedia = false
}
}
func (s *MessagesSendMessageRequest ) GetInvertMedia () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (16 )
}
func (s *MessagesSendMessageRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSendMessageRequest ) SetReplyTo (value InputReplyToClass ) {
s .Flags .Set (0 )
s .ReplyTo = value
}
func (s *MessagesSendMessageRequest ) GetReplyTo () (value InputReplyToClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .ReplyTo , true
}
func (s *MessagesSendMessageRequest ) GetMessage () (value string ) {
if s == nil {
return
}
return s .Message
}
func (s *MessagesSendMessageRequest ) GetRandomID () (value int64 ) {
if s == nil {
return
}
return s .RandomID
}
func (s *MessagesSendMessageRequest ) SetReplyMarkup (value ReplyMarkupClass ) {
s .Flags .Set (2 )
s .ReplyMarkup = value
}
func (s *MessagesSendMessageRequest ) GetReplyMarkup () (value ReplyMarkupClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .ReplyMarkup , true
}
func (s *MessagesSendMessageRequest ) SetEntities (value []MessageEntityClass ) {
s .Flags .Set (3 )
s .Entities = value
}
func (s *MessagesSendMessageRequest ) GetEntities () (value []MessageEntityClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (3 ) {
return value , false
}
return s .Entities , true
}
func (s *MessagesSendMessageRequest ) SetScheduleDate (value int ) {
s .Flags .Set (10 )
s .ScheduleDate = value
}
func (s *MessagesSendMessageRequest ) GetScheduleDate () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (10 ) {
return value , false
}
return s .ScheduleDate , true
}
func (s *MessagesSendMessageRequest ) SetSendAs (value InputPeerClass ) {
s .Flags .Set (13 )
s .SendAs = value
}
func (s *MessagesSendMessageRequest ) GetSendAs () (value InputPeerClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (13 ) {
return value , false
}
return s .SendAs , true
}
func (s *MessagesSendMessageRequest ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !s .Flags .Has (3 ) {
return value , false
}
return MessageEntityClassArray (s .Entities ), true
}
func (c *Client ) MessagesSendMessage (ctx context .Context , request *MessagesSendMessageRequest ) (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 .