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
316 lines
7.9 KiB
Go
316 lines
7.9 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{}
|
|
)
|
|
|
|
// EditBotMediaPreviewRequest represents TL type `editBotMediaPreview#86955d62`.
|
|
type EditBotMediaPreviewRequest struct {
|
|
// Identifier of the target bot. The bot must be owned and must have the main Web App
|
|
BotUserID int64
|
|
// Language code of the media preview to edit
|
|
LanguageCode string
|
|
// File identifier of the media to replace
|
|
FileID int32
|
|
// Content of the new preview
|
|
Content InputStoryContentClass
|
|
}
|
|
|
|
// EditBotMediaPreviewRequestTypeID is TL type id of EditBotMediaPreviewRequest.
|
|
const EditBotMediaPreviewRequestTypeID = 0x86955d62
|
|
|
|
// Ensuring interfaces in compile-time for EditBotMediaPreviewRequest.
|
|
var (
|
|
_ bin.Encoder = &EditBotMediaPreviewRequest{}
|
|
_ bin.Decoder = &EditBotMediaPreviewRequest{}
|
|
_ bin.BareEncoder = &EditBotMediaPreviewRequest{}
|
|
_ bin.BareDecoder = &EditBotMediaPreviewRequest{}
|
|
)
|
|
|
|
func (e *EditBotMediaPreviewRequest) Zero() bool {
|
|
if e == nil {
|
|
return true
|
|
}
|
|
if !(e.BotUserID == 0) {
|
|
return false
|
|
}
|
|
if !(e.LanguageCode == "") {
|
|
return false
|
|
}
|
|
if !(e.FileID == 0) {
|
|
return false
|
|
}
|
|
if !(e.Content == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (e *EditBotMediaPreviewRequest) String() string {
|
|
if e == nil {
|
|
return "EditBotMediaPreviewRequest(nil)"
|
|
}
|
|
type Alias EditBotMediaPreviewRequest
|
|
return fmt.Sprintf("EditBotMediaPreviewRequest%+v", Alias(*e))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*EditBotMediaPreviewRequest) TypeID() uint32 {
|
|
return EditBotMediaPreviewRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*EditBotMediaPreviewRequest) TypeName() string {
|
|
return "editBotMediaPreview"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (e *EditBotMediaPreviewRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "editBotMediaPreview",
|
|
ID: EditBotMediaPreviewRequestTypeID,
|
|
}
|
|
if e == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "BotUserID",
|
|
SchemaName: "bot_user_id",
|
|
},
|
|
{
|
|
Name: "LanguageCode",
|
|
SchemaName: "language_code",
|
|
},
|
|
{
|
|
Name: "FileID",
|
|
SchemaName: "file_id",
|
|
},
|
|
{
|
|
Name: "Content",
|
|
SchemaName: "content",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (e *EditBotMediaPreviewRequest) Encode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode editBotMediaPreview#86955d62 as nil")
|
|
}
|
|
b.PutID(EditBotMediaPreviewRequestTypeID)
|
|
return e.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (e *EditBotMediaPreviewRequest) EncodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode editBotMediaPreview#86955d62 as nil")
|
|
}
|
|
b.PutInt53(e.BotUserID)
|
|
b.PutString(e.LanguageCode)
|
|
b.PutInt32(e.FileID)
|
|
if e.Content == nil {
|
|
return fmt.Errorf("unable to encode editBotMediaPreview#86955d62: field content is nil")
|
|
}
|
|
if err := e.Content.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode editBotMediaPreview#86955d62: field content: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (e *EditBotMediaPreviewRequest) Decode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode editBotMediaPreview#86955d62 to nil")
|
|
}
|
|
if err := b.ConsumeID(EditBotMediaPreviewRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: %w", err)
|
|
}
|
|
return e.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (e *EditBotMediaPreviewRequest) DecodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode editBotMediaPreview#86955d62 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: field bot_user_id: %w", err)
|
|
}
|
|
e.BotUserID = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: field language_code: %w", err)
|
|
}
|
|
e.LanguageCode = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: field file_id: %w", err)
|
|
}
|
|
e.FileID = value
|
|
}
|
|
{
|
|
value, err := DecodeInputStoryContent(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: field content: %w", err)
|
|
}
|
|
e.Content = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (e *EditBotMediaPreviewRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode editBotMediaPreview#86955d62 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("editBotMediaPreview")
|
|
b.Comma()
|
|
b.FieldStart("bot_user_id")
|
|
b.PutInt53(e.BotUserID)
|
|
b.Comma()
|
|
b.FieldStart("language_code")
|
|
b.PutString(e.LanguageCode)
|
|
b.Comma()
|
|
b.FieldStart("file_id")
|
|
b.PutInt32(e.FileID)
|
|
b.Comma()
|
|
b.FieldStart("content")
|
|
if e.Content == nil {
|
|
return fmt.Errorf("unable to encode editBotMediaPreview#86955d62: field content is nil")
|
|
}
|
|
if err := e.Content.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode editBotMediaPreview#86955d62: field content: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (e *EditBotMediaPreviewRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode editBotMediaPreview#86955d62 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("editBotMediaPreview"); err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: %w", err)
|
|
}
|
|
case "bot_user_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: field bot_user_id: %w", err)
|
|
}
|
|
e.BotUserID = value
|
|
case "language_code":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: field language_code: %w", err)
|
|
}
|
|
e.LanguageCode = value
|
|
case "file_id":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: field file_id: %w", err)
|
|
}
|
|
e.FileID = value
|
|
case "content":
|
|
value, err := DecodeTDLibJSONInputStoryContent(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editBotMediaPreview#86955d62: field content: %w", err)
|
|
}
|
|
e.Content = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetBotUserID returns value of BotUserID field.
|
|
func (e *EditBotMediaPreviewRequest) GetBotUserID() (value int64) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.BotUserID
|
|
}
|
|
|
|
// GetLanguageCode returns value of LanguageCode field.
|
|
func (e *EditBotMediaPreviewRequest) GetLanguageCode() (value string) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.LanguageCode
|
|
}
|
|
|
|
// GetFileID returns value of FileID field.
|
|
func (e *EditBotMediaPreviewRequest) GetFileID() (value int32) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.FileID
|
|
}
|
|
|
|
// GetContent returns value of Content field.
|
|
func (e *EditBotMediaPreviewRequest) GetContent() (value InputStoryContentClass) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.Content
|
|
}
|
|
|
|
// EditBotMediaPreview invokes method editBotMediaPreview#86955d62 returning error if any.
|
|
func (c *Client) EditBotMediaPreview(ctx context.Context, request *EditBotMediaPreviewRequest) (*BotMediaPreview, error) {
|
|
var result BotMediaPreview
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|