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 MessagesEditMessageRequest struct {
Flags bin .Fields
NoWebpage bool
InvertMedia bool
Peer InputPeerClass
ID int
Message string
Media InputMediaClass
ReplyMarkup ReplyMarkupClass
Entities []MessageEntityClass
ScheduleDate int
}
const MessagesEditMessageRequestTypeID = 0x48f71778
var (
_ bin .Encoder = &MessagesEditMessageRequest {}
_ bin .Decoder = &MessagesEditMessageRequest {}
_ bin .BareEncoder = &MessagesEditMessageRequest {}
_ bin .BareDecoder = &MessagesEditMessageRequest {}
)
func (e *MessagesEditMessageRequest ) Zero () bool {
if e == nil {
return true
}
if !(e .Flags .Zero ()) {
return false
}
if !(e .NoWebpage == false ) {
return false
}
if !(e .InvertMedia == false ) {
return false
}
if !(e .Peer == nil ) {
return false
}
if !(e .ID == 0 ) {
return false
}
if !(e .Message == "" ) {
return false
}
if !(e .Media == nil ) {
return false
}
if !(e .ReplyMarkup == nil ) {
return false
}
if !(e .Entities == nil ) {
return false
}
if !(e .ScheduleDate == 0 ) {
return false
}
return true
}
func (e *MessagesEditMessageRequest ) String () string {
if e == nil {
return "MessagesEditMessageRequest(nil)"
}
type Alias MessagesEditMessageRequest
return fmt .Sprintf ("MessagesEditMessageRequest%+v" , Alias (*e ))
}
func (e *MessagesEditMessageRequest ) FillFrom (from interface {
GetNoWebpage () (value bool )
GetInvertMedia () (value bool )
GetPeer () (value InputPeerClass )
GetID () (value int )
GetMessage () (value string , ok bool )
GetMedia () (value InputMediaClass , ok bool )
GetReplyMarkup () (value ReplyMarkupClass , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
GetScheduleDate () (value int , ok bool )
}) {
e .NoWebpage = from .GetNoWebpage ()
e .InvertMedia = from .GetInvertMedia ()
e .Peer = from .GetPeer ()
e .ID = from .GetID ()
if val , ok := from .GetMessage (); ok {
e .Message = val
}
if val , ok := from .GetMedia (); ok {
e .Media = val
}
if val , ok := from .GetReplyMarkup (); ok {
e .ReplyMarkup = val
}
if val , ok := from .GetEntities (); ok {
e .Entities = val
}
if val , ok := from .GetScheduleDate (); ok {
e .ScheduleDate = val
}
}
func (*MessagesEditMessageRequest ) TypeID () uint32 {
return MessagesEditMessageRequestTypeID
}
func (*MessagesEditMessageRequest ) TypeName () string {
return "messages.editMessage"
}
func (e *MessagesEditMessageRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.editMessage" ,
ID : MessagesEditMessageRequestTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "NoWebpage" ,
SchemaName : "no_webpage" ,
Null : !e .Flags .Has (1 ),
},
{
Name : "InvertMedia" ,
SchemaName : "invert_media" ,
Null : !e .Flags .Has (16 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
Null : !e .Flags .Has (11 ),
},
{
Name : "Media" ,
SchemaName : "media" ,
Null : !e .Flags .Has (14 ),
},
{
Name : "ReplyMarkup" ,
SchemaName : "reply_markup" ,
Null : !e .Flags .Has (2 ),
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !e .Flags .Has (3 ),
},
{
Name : "ScheduleDate" ,
SchemaName : "schedule_date" ,
Null : !e .Flags .Has (15 ),
},
}
return typ
}
func (e *MessagesEditMessageRequest ) SetFlags () {
if !(e .NoWebpage == false ) {
e .Flags .Set (1 )
}
if !(e .InvertMedia == false ) {
e .Flags .Set (16 )
}
if !(e .Message == "" ) {
e .Flags .Set (11 )
}
if !(e .Media == nil ) {
e .Flags .Set (14 )
}
if !(e .ReplyMarkup == nil ) {
e .Flags .Set (2 )
}
if !(e .Entities == nil ) {
e .Flags .Set (3 )
}
if !(e .ScheduleDate == 0 ) {
e .Flags .Set (15 )
}
}
func (e *MessagesEditMessageRequest ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.editMessage#48f71778 as nil" )
}
b .PutID (MessagesEditMessageRequestTypeID )
return e .EncodeBare (b )
}
func (e *MessagesEditMessageRequest ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.editMessage#48f71778 as nil" )
}
e .SetFlags ()
if err := e .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editMessage#48f71778: field flags: %w" , err )
}
if e .Peer == nil {
return fmt .Errorf ("unable to encode messages.editMessage#48f71778: field peer is nil" )
}
if err := e .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editMessage#48f71778: field peer: %w" , err )
}
b .PutInt (e .ID )
if e .Flags .Has (11 ) {
b .PutString (e .Message )
}
if e .Flags .Has (14 ) {
if e .Media == nil {
return fmt .Errorf ("unable to encode messages.editMessage#48f71778: field media is nil" )
}
if err := e .Media .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editMessage#48f71778: field media: %w" , err )
}
}
if e .Flags .Has (2 ) {
if e .ReplyMarkup == nil {
return fmt .Errorf ("unable to encode messages.editMessage#48f71778: field reply_markup is nil" )
}
if err := e .ReplyMarkup .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editMessage#48f71778: field reply_markup: %w" , err )
}
}
if e .Flags .Has (3 ) {
b .PutVectorHeader (len (e .Entities ))
for idx , v := range e .Entities {
if v == nil {
return fmt .Errorf ("unable to encode messages.editMessage#48f71778: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editMessage#48f71778: field entities element with index %d: %w" , idx , err )
}
}
}
if e .Flags .Has (15 ) {
b .PutInt (e .ScheduleDate )
}
return nil
}
func (e *MessagesEditMessageRequest ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.editMessage#48f71778 to nil" )
}
if err := b .ConsumeID (MessagesEditMessageRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.editMessage#48f71778: %w" , err )
}
return e .DecodeBare (b )
}
func (e *MessagesEditMessageRequest ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.editMessage#48f71778 to nil" )
}
{
if err := e .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.editMessage#48f71778: field flags: %w" , err )
}
}
e .NoWebpage = e .Flags .Has (1 )
e .InvertMedia = e .Flags .Has (16 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.editMessage#48f71778: field peer: %w" , err )
}
e .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.editMessage#48f71778: field id: %w" , err )
}
e .ID = value
}
if e .Flags .Has (11 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.editMessage#48f71778: field message: %w" , err )
}
e .Message = value
}
if e .Flags .Has (14 ) {
value , err := DecodeInputMedia (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.editMessage#48f71778: field media: %w" , err )
}
e .Media = value
}
if e .Flags .Has (2 ) {
value , err := DecodeReplyMarkup (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.editMessage#48f71778: field reply_markup: %w" , err )
}
e .ReplyMarkup = value
}
if e .Flags .Has (3 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.editMessage#48f71778: 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 messages.editMessage#48f71778: field entities: %w" , err )
}
e .Entities = append (e .Entities , value )
}
}
if e .Flags .Has (15 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.editMessage#48f71778: field schedule_date: %w" , err )
}
e .ScheduleDate = value
}
return nil
}
func (e *MessagesEditMessageRequest ) SetNoWebpage (value bool ) {
if value {
e .Flags .Set (1 )
e .NoWebpage = true
} else {
e .Flags .Unset (1 )
e .NoWebpage = false
}
}
func (e *MessagesEditMessageRequest ) GetNoWebpage () (value bool ) {
if e == nil {
return
}
return e .Flags .Has (1 )
}
func (e *MessagesEditMessageRequest ) SetInvertMedia (value bool ) {
if value {
e .Flags .Set (16 )
e .InvertMedia = true
} else {
e .Flags .Unset (16 )
e .InvertMedia = false
}
}
func (e *MessagesEditMessageRequest ) GetInvertMedia () (value bool ) {
if e == nil {
return
}
return e .Flags .Has (16 )
}
func (e *MessagesEditMessageRequest ) GetPeer () (value InputPeerClass ) {
if e == nil {
return
}
return e .Peer
}
func (e *MessagesEditMessageRequest ) GetID () (value int ) {
if e == nil {
return
}
return e .ID
}
func (e *MessagesEditMessageRequest ) SetMessage (value string ) {
e .Flags .Set (11 )
e .Message = value
}
func (e *MessagesEditMessageRequest ) GetMessage () (value string , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (11 ) {
return value , false
}
return e .Message , true
}
func (e *MessagesEditMessageRequest ) SetMedia (value InputMediaClass ) {
e .Flags .Set (14 )
e .Media = value
}
func (e *MessagesEditMessageRequest ) GetMedia () (value InputMediaClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (14 ) {
return value , false
}
return e .Media , true
}
func (e *MessagesEditMessageRequest ) SetReplyMarkup (value ReplyMarkupClass ) {
e .Flags .Set (2 )
e .ReplyMarkup = value
}
func (e *MessagesEditMessageRequest ) GetReplyMarkup () (value ReplyMarkupClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (2 ) {
return value , false
}
return e .ReplyMarkup , true
}
func (e *MessagesEditMessageRequest ) SetEntities (value []MessageEntityClass ) {
e .Flags .Set (3 )
e .Entities = value
}
func (e *MessagesEditMessageRequest ) GetEntities () (value []MessageEntityClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (3 ) {
return value , false
}
return e .Entities , true
}
func (e *MessagesEditMessageRequest ) SetScheduleDate (value int ) {
e .Flags .Set (15 )
e .ScheduleDate = value
}
func (e *MessagesEditMessageRequest ) GetScheduleDate () (value int , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (15 ) {
return value , false
}
return e .ScheduleDate , true
}
func (e *MessagesEditMessageRequest ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !e .Flags .Has (3 ) {
return value , false
}
return MessageEntityClassArray (e .Entities ), true
}
func (c *Client ) MessagesEditMessage (ctx context .Context , request *MessagesEditMessageRequest ) (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 .