Files
mautrix-telegram/pkg/gotd/tg/tl_bots_set_custom_verification_gen.go
T
2025-06-27 20:03:37 -07:00

334 lines
8.6 KiB
Go

// 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{}
)
// BotsSetCustomVerificationRequest represents TL type `bots.setCustomVerification#8b89dfbd`.
//
// See https://core.telegram.org/method/bots.setCustomVerification for reference.
type BotsSetCustomVerificationRequest struct {
// Flags field of BotsSetCustomVerificationRequest.
Flags bin.Fields
// Enabled field of BotsSetCustomVerificationRequest.
Enabled bool
// Bot field of BotsSetCustomVerificationRequest.
//
// Use SetBot and GetBot helpers.
Bot InputUserClass
// Peer field of BotsSetCustomVerificationRequest.
Peer InputPeerClass
// CustomDescription field of BotsSetCustomVerificationRequest.
//
// Use SetCustomDescription and GetCustomDescription helpers.
CustomDescription string
}
// BotsSetCustomVerificationRequestTypeID is TL type id of BotsSetCustomVerificationRequest.
const BotsSetCustomVerificationRequestTypeID = 0x8b89dfbd
// Ensuring interfaces in compile-time for BotsSetCustomVerificationRequest.
var (
_ bin.Encoder = &BotsSetCustomVerificationRequest{}
_ bin.Decoder = &BotsSetCustomVerificationRequest{}
_ bin.BareEncoder = &BotsSetCustomVerificationRequest{}
_ bin.BareDecoder = &BotsSetCustomVerificationRequest{}
)
func (s *BotsSetCustomVerificationRequest) Zero() bool {
if s == nil {
return true
}
if !(s.Flags.Zero()) {
return false
}
if !(s.Enabled == false) {
return false
}
if !(s.Bot == nil) {
return false
}
if !(s.Peer == nil) {
return false
}
if !(s.CustomDescription == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *BotsSetCustomVerificationRequest) String() string {
if s == nil {
return "BotsSetCustomVerificationRequest(nil)"
}
type Alias BotsSetCustomVerificationRequest
return fmt.Sprintf("BotsSetCustomVerificationRequest%+v", Alias(*s))
}
// FillFrom fills BotsSetCustomVerificationRequest from given interface.
func (s *BotsSetCustomVerificationRequest) FillFrom(from interface {
GetEnabled() (value bool)
GetBot() (value InputUserClass, ok bool)
GetPeer() (value InputPeerClass)
GetCustomDescription() (value string, ok bool)
}) {
s.Enabled = from.GetEnabled()
if val, ok := from.GetBot(); ok {
s.Bot = val
}
s.Peer = from.GetPeer()
if val, ok := from.GetCustomDescription(); ok {
s.CustomDescription = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BotsSetCustomVerificationRequest) TypeID() uint32 {
return BotsSetCustomVerificationRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*BotsSetCustomVerificationRequest) TypeName() string {
return "bots.setCustomVerification"
}
// TypeInfo returns info about TL type.
func (s *BotsSetCustomVerificationRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "bots.setCustomVerification",
ID: BotsSetCustomVerificationRequestTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Enabled",
SchemaName: "enabled",
Null: !s.Flags.Has(1),
},
{
Name: "Bot",
SchemaName: "bot",
Null: !s.Flags.Has(0),
},
{
Name: "Peer",
SchemaName: "peer",
},
{
Name: "CustomDescription",
SchemaName: "custom_description",
Null: !s.Flags.Has(2),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (s *BotsSetCustomVerificationRequest) SetFlags() {
if !(s.Enabled == false) {
s.Flags.Set(1)
}
if !(s.Bot == nil) {
s.Flags.Set(0)
}
if !(s.CustomDescription == "") {
s.Flags.Set(2)
}
}
// Encode implements bin.Encoder.
func (s *BotsSetCustomVerificationRequest) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode bots.setCustomVerification#8b89dfbd as nil")
}
b.PutID(BotsSetCustomVerificationRequestTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *BotsSetCustomVerificationRequest) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode bots.setCustomVerification#8b89dfbd as nil")
}
s.SetFlags()
if err := s.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field flags: %w", err)
}
if s.Flags.Has(0) {
if s.Bot == nil {
return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field bot is nil")
}
if err := s.Bot.Encode(b); err != nil {
return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field bot: %w", err)
}
}
if s.Peer == nil {
return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field peer is nil")
}
if err := s.Peer.Encode(b); err != nil {
return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field peer: %w", err)
}
if s.Flags.Has(2) {
b.PutString(s.CustomDescription)
}
return nil
}
// Decode implements bin.Decoder.
func (s *BotsSetCustomVerificationRequest) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode bots.setCustomVerification#8b89dfbd to nil")
}
if err := b.ConsumeID(BotsSetCustomVerificationRequestTypeID); err != nil {
return fmt.Errorf("unable to decode bots.setCustomVerification#8b89dfbd: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *BotsSetCustomVerificationRequest) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode bots.setCustomVerification#8b89dfbd to nil")
}
{
if err := s.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode bots.setCustomVerification#8b89dfbd: field flags: %w", err)
}
}
s.Enabled = s.Flags.Has(1)
if s.Flags.Has(0) {
value, err := DecodeInputUser(b)
if err != nil {
return fmt.Errorf("unable to decode bots.setCustomVerification#8b89dfbd: field bot: %w", err)
}
s.Bot = value
}
{
value, err := DecodeInputPeer(b)
if err != nil {
return fmt.Errorf("unable to decode bots.setCustomVerification#8b89dfbd: field peer: %w", err)
}
s.Peer = value
}
if s.Flags.Has(2) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode bots.setCustomVerification#8b89dfbd: field custom_description: %w", err)
}
s.CustomDescription = value
}
return nil
}
// SetEnabled sets value of Enabled conditional field.
func (s *BotsSetCustomVerificationRequest) SetEnabled(value bool) {
if value {
s.Flags.Set(1)
s.Enabled = true
} else {
s.Flags.Unset(1)
s.Enabled = false
}
}
// GetEnabled returns value of Enabled conditional field.
func (s *BotsSetCustomVerificationRequest) GetEnabled() (value bool) {
if s == nil {
return
}
return s.Flags.Has(1)
}
// SetBot sets value of Bot conditional field.
func (s *BotsSetCustomVerificationRequest) SetBot(value InputUserClass) {
s.Flags.Set(0)
s.Bot = value
}
// GetBot returns value of Bot conditional field and
// boolean which is true if field was set.
func (s *BotsSetCustomVerificationRequest) GetBot() (value InputUserClass, ok bool) {
if s == nil {
return
}
if !s.Flags.Has(0) {
return value, false
}
return s.Bot, true
}
// GetPeer returns value of Peer field.
func (s *BotsSetCustomVerificationRequest) GetPeer() (value InputPeerClass) {
if s == nil {
return
}
return s.Peer
}
// SetCustomDescription sets value of CustomDescription conditional field.
func (s *BotsSetCustomVerificationRequest) SetCustomDescription(value string) {
s.Flags.Set(2)
s.CustomDescription = value
}
// GetCustomDescription returns value of CustomDescription conditional field and
// boolean which is true if field was set.
func (s *BotsSetCustomVerificationRequest) GetCustomDescription() (value string, ok bool) {
if s == nil {
return
}
if !s.Flags.Has(2) {
return value, false
}
return s.CustomDescription, true
}
// BotsSetCustomVerification invokes method bots.setCustomVerification#8b89dfbd returning error if any.
//
// See https://core.telegram.org/method/bots.setCustomVerification for reference.
func (c *Client) BotsSetCustomVerification(ctx context.Context, request *BotsSetCustomVerificationRequest) (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
}