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 BotCommand struct {
Command string
Description string
}
const BotCommandTypeID = 0xc27ac8c7
var (
_ bin .Encoder = &BotCommand {}
_ bin .Decoder = &BotCommand {}
_ bin .BareEncoder = &BotCommand {}
_ bin .BareDecoder = &BotCommand {}
)
func (b *BotCommand ) Zero () bool {
if b == nil {
return true
}
if !(b .Command == "" ) {
return false
}
if !(b .Description == "" ) {
return false
}
return true
}
func (b *BotCommand ) String () string {
if b == nil {
return "BotCommand(nil)"
}
type Alias BotCommand
return fmt .Sprintf ("BotCommand%+v" , Alias (*b ))
}
func (b *BotCommand ) FillFrom (from interface {
GetCommand () (value string )
GetDescription () (value string )
}) {
b .Command = from .GetCommand ()
b .Description = from .GetDescription ()
}
func (*BotCommand ) TypeID () uint32 {
return BotCommandTypeID
}
func (*BotCommand ) TypeName () string {
return "botCommand"
}
func (b *BotCommand ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "botCommand" ,
ID : BotCommandTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Command" ,
SchemaName : "command" ,
},
{
Name : "Description" ,
SchemaName : "description" ,
},
}
return typ
}
func (b *BotCommand ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botCommand#c27ac8c7 as nil" )
}
buf .PutID (BotCommandTypeID )
return b .EncodeBare (buf )
}
func (b *BotCommand ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botCommand#c27ac8c7 as nil" )
}
buf .PutString (b .Command )
buf .PutString (b .Description )
return nil
}
func (b *BotCommand ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botCommand#c27ac8c7 to nil" )
}
if err := buf .ConsumeID (BotCommandTypeID ); err != nil {
return fmt .Errorf ("unable to decode botCommand#c27ac8c7: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BotCommand ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botCommand#c27ac8c7 to nil" )
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botCommand#c27ac8c7: field command: %w" , err )
}
b .Command = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botCommand#c27ac8c7: field description: %w" , err )
}
b .Description = value
}
return nil
}
func (b *BotCommand ) GetCommand () (value string ) {
if b == nil {
return
}
return b .Command
}
func (b *BotCommand ) GetDescription () (value string ) {
if b == nil {
return
}
return b .Description
}
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 .