7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
238 lines
6.0 KiB
Go
238 lines
6.0 KiB
Go
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tdapi
|
|
|
|
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{}
|
|
)
|
|
|
|
// ToggleChatIsTranslatableRequest represents TL type `toggleChatIsTranslatable#93f9cbdf`.
|
|
type ToggleChatIsTranslatableRequest struct {
|
|
// Chat identifier
|
|
ChatID int64
|
|
// New value of is_translatable
|
|
IsTranslatable bool
|
|
}
|
|
|
|
// ToggleChatIsTranslatableRequestTypeID is TL type id of ToggleChatIsTranslatableRequest.
|
|
const ToggleChatIsTranslatableRequestTypeID = 0x93f9cbdf
|
|
|
|
// Ensuring interfaces in compile-time for ToggleChatIsTranslatableRequest.
|
|
var (
|
|
_ bin.Encoder = &ToggleChatIsTranslatableRequest{}
|
|
_ bin.Decoder = &ToggleChatIsTranslatableRequest{}
|
|
_ bin.BareEncoder = &ToggleChatIsTranslatableRequest{}
|
|
_ bin.BareDecoder = &ToggleChatIsTranslatableRequest{}
|
|
)
|
|
|
|
func (t *ToggleChatIsTranslatableRequest) Zero() bool {
|
|
if t == nil {
|
|
return true
|
|
}
|
|
if !(t.ChatID == 0) {
|
|
return false
|
|
}
|
|
if !(t.IsTranslatable == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (t *ToggleChatIsTranslatableRequest) String() string {
|
|
if t == nil {
|
|
return "ToggleChatIsTranslatableRequest(nil)"
|
|
}
|
|
type Alias ToggleChatIsTranslatableRequest
|
|
return fmt.Sprintf("ToggleChatIsTranslatableRequest%+v", Alias(*t))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ToggleChatIsTranslatableRequest) TypeID() uint32 {
|
|
return ToggleChatIsTranslatableRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ToggleChatIsTranslatableRequest) TypeName() string {
|
|
return "toggleChatIsTranslatable"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (t *ToggleChatIsTranslatableRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "toggleChatIsTranslatable",
|
|
ID: ToggleChatIsTranslatableRequestTypeID,
|
|
}
|
|
if t == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ChatID",
|
|
SchemaName: "chat_id",
|
|
},
|
|
{
|
|
Name: "IsTranslatable",
|
|
SchemaName: "is_translatable",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (t *ToggleChatIsTranslatableRequest) Encode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode toggleChatIsTranslatable#93f9cbdf as nil")
|
|
}
|
|
b.PutID(ToggleChatIsTranslatableRequestTypeID)
|
|
return t.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (t *ToggleChatIsTranslatableRequest) EncodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode toggleChatIsTranslatable#93f9cbdf as nil")
|
|
}
|
|
b.PutInt53(t.ChatID)
|
|
b.PutBool(t.IsTranslatable)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (t *ToggleChatIsTranslatableRequest) Decode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode toggleChatIsTranslatable#93f9cbdf to nil")
|
|
}
|
|
if err := b.ConsumeID(ToggleChatIsTranslatableRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode toggleChatIsTranslatable#93f9cbdf: %w", err)
|
|
}
|
|
return t.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (t *ToggleChatIsTranslatableRequest) DecodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode toggleChatIsTranslatable#93f9cbdf to nil")
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode toggleChatIsTranslatable#93f9cbdf: field chat_id: %w", err)
|
|
}
|
|
t.ChatID = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode toggleChatIsTranslatable#93f9cbdf: field is_translatable: %w", err)
|
|
}
|
|
t.IsTranslatable = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (t *ToggleChatIsTranslatableRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode toggleChatIsTranslatable#93f9cbdf as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("toggleChatIsTranslatable")
|
|
b.Comma()
|
|
b.FieldStart("chat_id")
|
|
b.PutInt53(t.ChatID)
|
|
b.Comma()
|
|
b.FieldStart("is_translatable")
|
|
b.PutBool(t.IsTranslatable)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (t *ToggleChatIsTranslatableRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode toggleChatIsTranslatable#93f9cbdf to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("toggleChatIsTranslatable"); err != nil {
|
|
return fmt.Errorf("unable to decode toggleChatIsTranslatable#93f9cbdf: %w", err)
|
|
}
|
|
case "chat_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode toggleChatIsTranslatable#93f9cbdf: field chat_id: %w", err)
|
|
}
|
|
t.ChatID = value
|
|
case "is_translatable":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode toggleChatIsTranslatable#93f9cbdf: field is_translatable: %w", err)
|
|
}
|
|
t.IsTranslatable = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetChatID returns value of ChatID field.
|
|
func (t *ToggleChatIsTranslatableRequest) GetChatID() (value int64) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.ChatID
|
|
}
|
|
|
|
// GetIsTranslatable returns value of IsTranslatable field.
|
|
func (t *ToggleChatIsTranslatableRequest) GetIsTranslatable() (value bool) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.IsTranslatable
|
|
}
|
|
|
|
// ToggleChatIsTranslatable invokes method toggleChatIsTranslatable#93f9cbdf returning error if any.
|
|
func (c *Client) ToggleChatIsTranslatable(ctx context.Context, request *ToggleChatIsTranslatableRequest) error {
|
|
var ok Ok
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|