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 BotsCanSendMessageRequest struct {
Bot InputUserClass
}
const BotsCanSendMessageRequestTypeID = 0x1359f4e6
var (
_ bin .Encoder = &BotsCanSendMessageRequest {}
_ bin .Decoder = &BotsCanSendMessageRequest {}
_ bin .BareEncoder = &BotsCanSendMessageRequest {}
_ bin .BareDecoder = &BotsCanSendMessageRequest {}
)
func (c *BotsCanSendMessageRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Bot == nil ) {
return false
}
return true
}
func (c *BotsCanSendMessageRequest ) String () string {
if c == nil {
return "BotsCanSendMessageRequest(nil)"
}
type Alias BotsCanSendMessageRequest
return fmt .Sprintf ("BotsCanSendMessageRequest%+v" , Alias (*c ))
}
func (c *BotsCanSendMessageRequest ) FillFrom (from interface {
GetBot () (value InputUserClass )
}) {
c .Bot = from .GetBot ()
}
func (*BotsCanSendMessageRequest ) TypeID () uint32 {
return BotsCanSendMessageRequestTypeID
}
func (*BotsCanSendMessageRequest ) TypeName () string {
return "bots.canSendMessage"
}
func (c *BotsCanSendMessageRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.canSendMessage" ,
ID : BotsCanSendMessageRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Bot" ,
SchemaName : "bot" ,
},
}
return typ
}
func (c *BotsCanSendMessageRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode bots.canSendMessage#1359f4e6 as nil" )
}
b .PutID (BotsCanSendMessageRequestTypeID )
return c .EncodeBare (b )
}
func (c *BotsCanSendMessageRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode bots.canSendMessage#1359f4e6 as nil" )
}
if c .Bot == nil {
return fmt .Errorf ("unable to encode bots.canSendMessage#1359f4e6: field bot is nil" )
}
if err := c .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.canSendMessage#1359f4e6: field bot: %w" , err )
}
return nil
}
func (c *BotsCanSendMessageRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode bots.canSendMessage#1359f4e6 to nil" )
}
if err := b .ConsumeID (BotsCanSendMessageRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.canSendMessage#1359f4e6: %w" , err )
}
return c .DecodeBare (b )
}
func (c *BotsCanSendMessageRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode bots.canSendMessage#1359f4e6 to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.canSendMessage#1359f4e6: field bot: %w" , err )
}
c .Bot = value
}
return nil
}
func (c *BotsCanSendMessageRequest ) GetBot () (value InputUserClass ) {
if c == nil {
return
}
return c .Bot
}
func (c *Client ) BotsCanSendMessage (ctx context .Context , bot InputUserClass ) (bool , error ) {
var result BoolBox
request := &BotsCanSendMessageRequest {
Bot : bot ,
}
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 .