223 lines
6.2 KiB
Go
Generated
223 lines
6.2 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{}
|
|
)
|
|
|
|
// ChannelsToggleAutotranslationRequest represents TL type `channels.toggleAutotranslation#167fc0a1`.
|
|
// Toggle autotranslation in a channel, for all users: see here »¹ for more info.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/translation#autotranslation-for-channels
|
|
//
|
|
// See https://core.telegram.org/method/channels.toggleAutotranslation for reference.
|
|
type ChannelsToggleAutotranslationRequest struct {
|
|
// The channel where to toggle autotranslation.
|
|
Channel InputChannelClass
|
|
// Whether to enable or disable autotranslation.
|
|
Enabled bool
|
|
}
|
|
|
|
// ChannelsToggleAutotranslationRequestTypeID is TL type id of ChannelsToggleAutotranslationRequest.
|
|
const ChannelsToggleAutotranslationRequestTypeID = 0x167fc0a1
|
|
|
|
// Ensuring interfaces in compile-time for ChannelsToggleAutotranslationRequest.
|
|
var (
|
|
_ bin.Encoder = &ChannelsToggleAutotranslationRequest{}
|
|
_ bin.Decoder = &ChannelsToggleAutotranslationRequest{}
|
|
_ bin.BareEncoder = &ChannelsToggleAutotranslationRequest{}
|
|
_ bin.BareDecoder = &ChannelsToggleAutotranslationRequest{}
|
|
)
|
|
|
|
func (t *ChannelsToggleAutotranslationRequest) Zero() bool {
|
|
if t == nil {
|
|
return true
|
|
}
|
|
if !(t.Channel == nil) {
|
|
return false
|
|
}
|
|
if !(t.Enabled == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (t *ChannelsToggleAutotranslationRequest) String() string {
|
|
if t == nil {
|
|
return "ChannelsToggleAutotranslationRequest(nil)"
|
|
}
|
|
type Alias ChannelsToggleAutotranslationRequest
|
|
return fmt.Sprintf("ChannelsToggleAutotranslationRequest%+v", Alias(*t))
|
|
}
|
|
|
|
// FillFrom fills ChannelsToggleAutotranslationRequest from given interface.
|
|
func (t *ChannelsToggleAutotranslationRequest) FillFrom(from interface {
|
|
GetChannel() (value InputChannelClass)
|
|
GetEnabled() (value bool)
|
|
}) {
|
|
t.Channel = from.GetChannel()
|
|
t.Enabled = from.GetEnabled()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChannelsToggleAutotranslationRequest) TypeID() uint32 {
|
|
return ChannelsToggleAutotranslationRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChannelsToggleAutotranslationRequest) TypeName() string {
|
|
return "channels.toggleAutotranslation"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (t *ChannelsToggleAutotranslationRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "channels.toggleAutotranslation",
|
|
ID: ChannelsToggleAutotranslationRequestTypeID,
|
|
}
|
|
if t == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Channel",
|
|
SchemaName: "channel",
|
|
},
|
|
{
|
|
Name: "Enabled",
|
|
SchemaName: "enabled",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (t *ChannelsToggleAutotranslationRequest) Encode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode channels.toggleAutotranslation#167fc0a1 as nil")
|
|
}
|
|
b.PutID(ChannelsToggleAutotranslationRequestTypeID)
|
|
return t.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (t *ChannelsToggleAutotranslationRequest) EncodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode channels.toggleAutotranslation#167fc0a1 as nil")
|
|
}
|
|
if t.Channel == nil {
|
|
return fmt.Errorf("unable to encode channels.toggleAutotranslation#167fc0a1: field channel is nil")
|
|
}
|
|
if err := t.Channel.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channels.toggleAutotranslation#167fc0a1: field channel: %w", err)
|
|
}
|
|
b.PutBool(t.Enabled)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (t *ChannelsToggleAutotranslationRequest) Decode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode channels.toggleAutotranslation#167fc0a1 to nil")
|
|
}
|
|
if err := b.ConsumeID(ChannelsToggleAutotranslationRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode channels.toggleAutotranslation#167fc0a1: %w", err)
|
|
}
|
|
return t.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (t *ChannelsToggleAutotranslationRequest) DecodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode channels.toggleAutotranslation#167fc0a1 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeInputChannel(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channels.toggleAutotranslation#167fc0a1: field channel: %w", err)
|
|
}
|
|
t.Channel = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channels.toggleAutotranslation#167fc0a1: field enabled: %w", err)
|
|
}
|
|
t.Enabled = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetChannel returns value of Channel field.
|
|
func (t *ChannelsToggleAutotranslationRequest) GetChannel() (value InputChannelClass) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.Channel
|
|
}
|
|
|
|
// GetEnabled returns value of Enabled field.
|
|
func (t *ChannelsToggleAutotranslationRequest) GetEnabled() (value bool) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.Enabled
|
|
}
|
|
|
|
// GetChannelAsNotEmpty returns mapped value of Channel field.
|
|
func (t *ChannelsToggleAutotranslationRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) {
|
|
return t.Channel.AsNotEmpty()
|
|
}
|
|
|
|
// ChannelsToggleAutotranslation invokes method channels.toggleAutotranslation#167fc0a1 returning error if any.
|
|
// Toggle autotranslation in a channel, for all users: see here »¹ for more info.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/translation#autotranslation-for-channels
|
|
//
|
|
// Possible errors:
|
|
//
|
|
// 400 CHANNEL_INVALID: The provided channel is invalid.
|
|
//
|
|
// See https://core.telegram.org/method/channels.toggleAutotranslation for reference.
|
|
func (c *Client) ChannelsToggleAutotranslation(ctx context.Context, request *ChannelsToggleAutotranslationRequest) (UpdatesClass, error) {
|
|
var result UpdatesBox
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return result.Updates, nil
|
|
}
|