move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,359 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// MessagesTranscribedAudio represents TL type `messages.transcribedAudio#cfb9d957`.
|
||||
// Transcribed text from a voice message »¹
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/api/transcribe
|
||||
//
|
||||
// See https://core.telegram.org/constructor/messages.transcribedAudio for reference.
|
||||
type MessagesTranscribedAudio struct {
|
||||
// Flags, see TL conditional fields¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
||||
Flags bin.Fields
|
||||
// Whether the transcription is partial because audio transcription is still in progress,
|
||||
// if set the user may receive further updateTranscribedAudio¹ updates with the updated
|
||||
// transcription.
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/constructor/updateTranscribedAudio
|
||||
Pending bool
|
||||
// Transcription ID
|
||||
TranscriptionID int64
|
||||
// Transcripted text
|
||||
Text string
|
||||
// For non-Premium¹ users, this flag will be set, indicating the remaining
|
||||
// transcriptions in the free trial period.
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/premium
|
||||
//
|
||||
// Use SetTrialRemainsNum and GetTrialRemainsNum helpers.
|
||||
TrialRemainsNum int
|
||||
// For non-Premium¹ users, this flag will be set, indicating the date when the
|
||||
// trial_remains_num counter will be reset to the maximum value of
|
||||
// transcribe_audio_trial_weekly_number².
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/premium
|
||||
// 2) https://core.telegram.org/api/config#transcribe-audio-trial-weekly-number
|
||||
//
|
||||
// Use SetTrialRemainsUntilDate and GetTrialRemainsUntilDate helpers.
|
||||
TrialRemainsUntilDate int
|
||||
}
|
||||
|
||||
// MessagesTranscribedAudioTypeID is TL type id of MessagesTranscribedAudio.
|
||||
const MessagesTranscribedAudioTypeID = 0xcfb9d957
|
||||
|
||||
// Ensuring interfaces in compile-time for MessagesTranscribedAudio.
|
||||
var (
|
||||
_ bin.Encoder = &MessagesTranscribedAudio{}
|
||||
_ bin.Decoder = &MessagesTranscribedAudio{}
|
||||
_ bin.BareEncoder = &MessagesTranscribedAudio{}
|
||||
_ bin.BareDecoder = &MessagesTranscribedAudio{}
|
||||
)
|
||||
|
||||
func (t *MessagesTranscribedAudio) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Flags.Zero()) {
|
||||
return false
|
||||
}
|
||||
if !(t.Pending == false) {
|
||||
return false
|
||||
}
|
||||
if !(t.TranscriptionID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(t.Text == "") {
|
||||
return false
|
||||
}
|
||||
if !(t.TrialRemainsNum == 0) {
|
||||
return false
|
||||
}
|
||||
if !(t.TrialRemainsUntilDate == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *MessagesTranscribedAudio) String() string {
|
||||
if t == nil {
|
||||
return "MessagesTranscribedAudio(nil)"
|
||||
}
|
||||
type Alias MessagesTranscribedAudio
|
||||
return fmt.Sprintf("MessagesTranscribedAudio%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// FillFrom fills MessagesTranscribedAudio from given interface.
|
||||
func (t *MessagesTranscribedAudio) FillFrom(from interface {
|
||||
GetPending() (value bool)
|
||||
GetTranscriptionID() (value int64)
|
||||
GetText() (value string)
|
||||
GetTrialRemainsNum() (value int, ok bool)
|
||||
GetTrialRemainsUntilDate() (value int, ok bool)
|
||||
}) {
|
||||
t.Pending = from.GetPending()
|
||||
t.TranscriptionID = from.GetTranscriptionID()
|
||||
t.Text = from.GetText()
|
||||
if val, ok := from.GetTrialRemainsNum(); ok {
|
||||
t.TrialRemainsNum = val
|
||||
}
|
||||
|
||||
if val, ok := from.GetTrialRemainsUntilDate(); ok {
|
||||
t.TrialRemainsUntilDate = val
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*MessagesTranscribedAudio) TypeID() uint32 {
|
||||
return MessagesTranscribedAudioTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*MessagesTranscribedAudio) TypeName() string {
|
||||
return "messages.transcribedAudio"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *MessagesTranscribedAudio) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "messages.transcribedAudio",
|
||||
ID: MessagesTranscribedAudioTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Pending",
|
||||
SchemaName: "pending",
|
||||
Null: !t.Flags.Has(0),
|
||||
},
|
||||
{
|
||||
Name: "TranscriptionID",
|
||||
SchemaName: "transcription_id",
|
||||
},
|
||||
{
|
||||
Name: "Text",
|
||||
SchemaName: "text",
|
||||
},
|
||||
{
|
||||
Name: "TrialRemainsNum",
|
||||
SchemaName: "trial_remains_num",
|
||||
Null: !t.Flags.Has(1),
|
||||
},
|
||||
{
|
||||
Name: "TrialRemainsUntilDate",
|
||||
SchemaName: "trial_remains_until_date",
|
||||
Null: !t.Flags.Has(1),
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// SetFlags sets flags for non-zero fields.
|
||||
func (t *MessagesTranscribedAudio) SetFlags() {
|
||||
if !(t.Pending == false) {
|
||||
t.Flags.Set(0)
|
||||
}
|
||||
if !(t.TrialRemainsNum == 0) {
|
||||
t.Flags.Set(1)
|
||||
}
|
||||
if !(t.TrialRemainsUntilDate == 0) {
|
||||
t.Flags.Set(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *MessagesTranscribedAudio) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode messages.transcribedAudio#cfb9d957 as nil")
|
||||
}
|
||||
b.PutID(MessagesTranscribedAudioTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *MessagesTranscribedAudio) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode messages.transcribedAudio#cfb9d957 as nil")
|
||||
}
|
||||
t.SetFlags()
|
||||
if err := t.Flags.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode messages.transcribedAudio#cfb9d957: field flags: %w", err)
|
||||
}
|
||||
b.PutLong(t.TranscriptionID)
|
||||
b.PutString(t.Text)
|
||||
if t.Flags.Has(1) {
|
||||
b.PutInt(t.TrialRemainsNum)
|
||||
}
|
||||
if t.Flags.Has(1) {
|
||||
b.PutInt(t.TrialRemainsUntilDate)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *MessagesTranscribedAudio) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode messages.transcribedAudio#cfb9d957 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(MessagesTranscribedAudioTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *MessagesTranscribedAudio) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode messages.transcribedAudio#cfb9d957 to nil")
|
||||
}
|
||||
{
|
||||
if err := t.Flags.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field flags: %w", err)
|
||||
}
|
||||
}
|
||||
t.Pending = t.Flags.Has(0)
|
||||
{
|
||||
value, err := b.Long()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field transcription_id: %w", err)
|
||||
}
|
||||
t.TranscriptionID = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field text: %w", err)
|
||||
}
|
||||
t.Text = value
|
||||
}
|
||||
if t.Flags.Has(1) {
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field trial_remains_num: %w", err)
|
||||
}
|
||||
t.TrialRemainsNum = value
|
||||
}
|
||||
if t.Flags.Has(1) {
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode messages.transcribedAudio#cfb9d957: field trial_remains_until_date: %w", err)
|
||||
}
|
||||
t.TrialRemainsUntilDate = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetPending sets value of Pending conditional field.
|
||||
func (t *MessagesTranscribedAudio) SetPending(value bool) {
|
||||
if value {
|
||||
t.Flags.Set(0)
|
||||
t.Pending = true
|
||||
} else {
|
||||
t.Flags.Unset(0)
|
||||
t.Pending = false
|
||||
}
|
||||
}
|
||||
|
||||
// GetPending returns value of Pending conditional field.
|
||||
func (t *MessagesTranscribedAudio) GetPending() (value bool) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Flags.Has(0)
|
||||
}
|
||||
|
||||
// GetTranscriptionID returns value of TranscriptionID field.
|
||||
func (t *MessagesTranscribedAudio) GetTranscriptionID() (value int64) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.TranscriptionID
|
||||
}
|
||||
|
||||
// GetText returns value of Text field.
|
||||
func (t *MessagesTranscribedAudio) GetText() (value string) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Text
|
||||
}
|
||||
|
||||
// SetTrialRemainsNum sets value of TrialRemainsNum conditional field.
|
||||
func (t *MessagesTranscribedAudio) SetTrialRemainsNum(value int) {
|
||||
t.Flags.Set(1)
|
||||
t.TrialRemainsNum = value
|
||||
}
|
||||
|
||||
// GetTrialRemainsNum returns value of TrialRemainsNum conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (t *MessagesTranscribedAudio) GetTrialRemainsNum() (value int, ok bool) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
if !t.Flags.Has(1) {
|
||||
return value, false
|
||||
}
|
||||
return t.TrialRemainsNum, true
|
||||
}
|
||||
|
||||
// SetTrialRemainsUntilDate sets value of TrialRemainsUntilDate conditional field.
|
||||
func (t *MessagesTranscribedAudio) SetTrialRemainsUntilDate(value int) {
|
||||
t.Flags.Set(1)
|
||||
t.TrialRemainsUntilDate = value
|
||||
}
|
||||
|
||||
// GetTrialRemainsUntilDate returns value of TrialRemainsUntilDate conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (t *MessagesTranscribedAudio) GetTrialRemainsUntilDate() (value int, ok bool) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
if !t.Flags.Has(1) {
|
||||
return value, false
|
||||
}
|
||||
return t.TrialRemainsUntilDate, true
|
||||
}
|
||||
Reference in New Issue
Block a user