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 MessagesEditInlineBotMessageRequest struct {
Flags bin .Fields
NoWebpage bool
InvertMedia bool
ID InputBotInlineMessageIDClass
Message string
Media InputMediaClass
ReplyMarkup ReplyMarkupClass
Entities []MessageEntityClass
}
const MessagesEditInlineBotMessageRequestTypeID = 0x83557dba
var (
_ bin .Encoder = &MessagesEditInlineBotMessageRequest {}
_ bin .Decoder = &MessagesEditInlineBotMessageRequest {}
_ bin .BareEncoder = &MessagesEditInlineBotMessageRequest {}
_ bin .BareDecoder = &MessagesEditInlineBotMessageRequest {}
)
func (e *MessagesEditInlineBotMessageRequest ) 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 .ID == nil ) {
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
}
return true
}
func (e *MessagesEditInlineBotMessageRequest ) String () string {
if e == nil {
return "MessagesEditInlineBotMessageRequest(nil)"
}
type Alias MessagesEditInlineBotMessageRequest
return fmt .Sprintf ("MessagesEditInlineBotMessageRequest%+v" , Alias (*e ))
}
func (e *MessagesEditInlineBotMessageRequest ) FillFrom (from interface {
GetNoWebpage () (value bool )
GetInvertMedia () (value bool )
GetID () (value InputBotInlineMessageIDClass )
GetMessage () (value string , ok bool )
GetMedia () (value InputMediaClass , ok bool )
GetReplyMarkup () (value ReplyMarkupClass , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
}) {
e .NoWebpage = from .GetNoWebpage ()
e .InvertMedia = from .GetInvertMedia ()
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
}
}
func (*MessagesEditInlineBotMessageRequest ) TypeID () uint32 {
return MessagesEditInlineBotMessageRequestTypeID
}
func (*MessagesEditInlineBotMessageRequest ) TypeName () string {
return "messages.editInlineBotMessage"
}
func (e *MessagesEditInlineBotMessageRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.editInlineBotMessage" ,
ID : MessagesEditInlineBotMessageRequestTypeID ,
}
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 : "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 ),
},
}
return typ
}
func (e *MessagesEditInlineBotMessageRequest ) 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 )
}
}
func (e *MessagesEditInlineBotMessageRequest ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.editInlineBotMessage#83557dba as nil" )
}
b .PutID (MessagesEditInlineBotMessageRequestTypeID )
return e .EncodeBare (b )
}
func (e *MessagesEditInlineBotMessageRequest ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.editInlineBotMessage#83557dba as nil" )
}
e .SetFlags ()
if err := e .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editInlineBotMessage#83557dba: field flags: %w" , err )
}
if e .ID == nil {
return fmt .Errorf ("unable to encode messages.editInlineBotMessage#83557dba: field id is nil" )
}
if err := e .ID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editInlineBotMessage#83557dba: field id: %w" , err )
}
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.editInlineBotMessage#83557dba: field media is nil" )
}
if err := e .Media .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editInlineBotMessage#83557dba: field media: %w" , err )
}
}
if e .Flags .Has (2 ) {
if e .ReplyMarkup == nil {
return fmt .Errorf ("unable to encode messages.editInlineBotMessage#83557dba: field reply_markup is nil" )
}
if err := e .ReplyMarkup .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editInlineBotMessage#83557dba: 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.editInlineBotMessage#83557dba: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.editInlineBotMessage#83557dba: field entities element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (e *MessagesEditInlineBotMessageRequest ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.editInlineBotMessage#83557dba to nil" )
}
if err := b .ConsumeID (MessagesEditInlineBotMessageRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.editInlineBotMessage#83557dba: %w" , err )
}
return e .DecodeBare (b )
}
func (e *MessagesEditInlineBotMessageRequest ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.editInlineBotMessage#83557dba to nil" )
}
{
if err := e .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.editInlineBotMessage#83557dba: field flags: %w" , err )
}
}
e .NoWebpage = e .Flags .Has (1 )
e .InvertMedia = e .Flags .Has (16 )
{
value , err := DecodeInputBotInlineMessageID (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.editInlineBotMessage#83557dba: 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.editInlineBotMessage#83557dba: 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.editInlineBotMessage#83557dba: 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.editInlineBotMessage#83557dba: 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.editInlineBotMessage#83557dba: 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.editInlineBotMessage#83557dba: field entities: %w" , err )
}
e .Entities = append (e .Entities , value )
}
}
return nil
}
func (e *MessagesEditInlineBotMessageRequest ) SetNoWebpage (value bool ) {
if value {
e .Flags .Set (1 )
e .NoWebpage = true
} else {
e .Flags .Unset (1 )
e .NoWebpage = false
}
}
func (e *MessagesEditInlineBotMessageRequest ) GetNoWebpage () (value bool ) {
if e == nil {
return
}
return e .Flags .Has (1 )
}
func (e *MessagesEditInlineBotMessageRequest ) SetInvertMedia (value bool ) {
if value {
e .Flags .Set (16 )
e .InvertMedia = true
} else {
e .Flags .Unset (16 )
e .InvertMedia = false
}
}
func (e *MessagesEditInlineBotMessageRequest ) GetInvertMedia () (value bool ) {
if e == nil {
return
}
return e .Flags .Has (16 )
}
func (e *MessagesEditInlineBotMessageRequest ) GetID () (value InputBotInlineMessageIDClass ) {
if e == nil {
return
}
return e .ID
}
func (e *MessagesEditInlineBotMessageRequest ) SetMessage (value string ) {
e .Flags .Set (11 )
e .Message = value
}
func (e *MessagesEditInlineBotMessageRequest ) GetMessage () (value string , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (11 ) {
return value , false
}
return e .Message , true
}
func (e *MessagesEditInlineBotMessageRequest ) SetMedia (value InputMediaClass ) {
e .Flags .Set (14 )
e .Media = value
}
func (e *MessagesEditInlineBotMessageRequest ) GetMedia () (value InputMediaClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (14 ) {
return value , false
}
return e .Media , true
}
func (e *MessagesEditInlineBotMessageRequest ) SetReplyMarkup (value ReplyMarkupClass ) {
e .Flags .Set (2 )
e .ReplyMarkup = value
}
func (e *MessagesEditInlineBotMessageRequest ) GetReplyMarkup () (value ReplyMarkupClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (2 ) {
return value , false
}
return e .ReplyMarkup , true
}
func (e *MessagesEditInlineBotMessageRequest ) SetEntities (value []MessageEntityClass ) {
e .Flags .Set (3 )
e .Entities = value
}
func (e *MessagesEditInlineBotMessageRequest ) GetEntities () (value []MessageEntityClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (3 ) {
return value , false
}
return e .Entities , true
}
func (e *MessagesEditInlineBotMessageRequest ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !e .Flags .Has (3 ) {
return value , false
}
return MessageEntityClassArray (e .Entities ), true
}
func (c *Client ) MessagesEditInlineBotMessage (ctx context .Context , request *MessagesEditInlineBotMessageRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , 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 .