245 lines
5.5 KiB
Go
Generated
245 lines
5.5 KiB
Go
Generated
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tg
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"go.uber.org/multierr"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
|
|
)
|
|
|
|
// No-op definition for keeping imports.
|
|
var (
|
|
_ = bin.Buffer{}
|
|
_ = context.Background()
|
|
_ = fmt.Stringer(nil)
|
|
_ = strings.Builder{}
|
|
_ = errors.Is
|
|
_ = multierr.AppendInto
|
|
_ = sort.Ints
|
|
_ = tdp.Format
|
|
_ = tgerr.Error{}
|
|
_ = tdjson.Encoder{}
|
|
)
|
|
|
|
// ConnectedBot represents TL type `connectedBot#cd64636c`.
|
|
// Contains info about a connected business bot »¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/bots/connected-business-bots
|
|
//
|
|
// See https://core.telegram.org/constructor/connectedBot for reference.
|
|
type ConnectedBot struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// ID of the connected bot
|
|
BotID int64
|
|
// Specifies the private chats that a connected business bot »¹ may receive messages
|
|
// and interact with.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/bots/connected-business-bots
|
|
Recipients BusinessBotRecipients
|
|
// Business bot rights.
|
|
Rights BusinessBotRights
|
|
}
|
|
|
|
// ConnectedBotTypeID is TL type id of ConnectedBot.
|
|
const ConnectedBotTypeID = 0xcd64636c
|
|
|
|
// Ensuring interfaces in compile-time for ConnectedBot.
|
|
var (
|
|
_ bin.Encoder = &ConnectedBot{}
|
|
_ bin.Decoder = &ConnectedBot{}
|
|
_ bin.BareEncoder = &ConnectedBot{}
|
|
_ bin.BareDecoder = &ConnectedBot{}
|
|
)
|
|
|
|
func (c *ConnectedBot) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.BotID == 0) {
|
|
return false
|
|
}
|
|
if !(c.Recipients.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.Rights.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ConnectedBot) String() string {
|
|
if c == nil {
|
|
return "ConnectedBot(nil)"
|
|
}
|
|
type Alias ConnectedBot
|
|
return fmt.Sprintf("ConnectedBot%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills ConnectedBot from given interface.
|
|
func (c *ConnectedBot) FillFrom(from interface {
|
|
GetBotID() (value int64)
|
|
GetRecipients() (value BusinessBotRecipients)
|
|
GetRights() (value BusinessBotRights)
|
|
}) {
|
|
c.BotID = from.GetBotID()
|
|
c.Recipients = from.GetRecipients()
|
|
c.Rights = from.GetRights()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ConnectedBot) TypeID() uint32 {
|
|
return ConnectedBotTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ConnectedBot) TypeName() string {
|
|
return "connectedBot"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ConnectedBot) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "connectedBot",
|
|
ID: ConnectedBotTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "BotID",
|
|
SchemaName: "bot_id",
|
|
},
|
|
{
|
|
Name: "Recipients",
|
|
SchemaName: "recipients",
|
|
},
|
|
{
|
|
Name: "Rights",
|
|
SchemaName: "rights",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (c *ConnectedBot) SetFlags() {
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ConnectedBot) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode connectedBot#cd64636c as nil")
|
|
}
|
|
b.PutID(ConnectedBotTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ConnectedBot) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode connectedBot#cd64636c as nil")
|
|
}
|
|
c.SetFlags()
|
|
if err := c.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode connectedBot#cd64636c: field flags: %w", err)
|
|
}
|
|
b.PutLong(c.BotID)
|
|
if err := c.Recipients.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode connectedBot#cd64636c: field recipients: %w", err)
|
|
}
|
|
if err := c.Rights.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode connectedBot#cd64636c: field rights: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ConnectedBot) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode connectedBot#cd64636c to nil")
|
|
}
|
|
if err := b.ConsumeID(ConnectedBotTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode connectedBot#cd64636c: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ConnectedBot) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode connectedBot#cd64636c to nil")
|
|
}
|
|
{
|
|
if err := c.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode connectedBot#cd64636c: field flags: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode connectedBot#cd64636c: field bot_id: %w", err)
|
|
}
|
|
c.BotID = value
|
|
}
|
|
{
|
|
if err := c.Recipients.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode connectedBot#cd64636c: field recipients: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := c.Rights.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode connectedBot#cd64636c: field rights: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetBotID returns value of BotID field.
|
|
func (c *ConnectedBot) GetBotID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.BotID
|
|
}
|
|
|
|
// GetRecipients returns value of Recipients field.
|
|
func (c *ConnectedBot) GetRecipients() (value BusinessBotRecipients) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Recipients
|
|
}
|
|
|
|
// GetRights returns value of Rights field.
|
|
func (c *ConnectedBot) GetRights() (value BusinessBotRights) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Rights
|
|
}
|