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,535 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// InputGroupCallLink represents TL type `inputGroupCallLink#cf9775d8`.
|
||||
type InputGroupCallLink struct {
|
||||
// The link for the group call
|
||||
Link string
|
||||
}
|
||||
|
||||
// InputGroupCallLinkTypeID is TL type id of InputGroupCallLink.
|
||||
const InputGroupCallLinkTypeID = 0xcf9775d8
|
||||
|
||||
// construct implements constructor of InputGroupCallClass.
|
||||
func (i InputGroupCallLink) construct() InputGroupCallClass { return &i }
|
||||
|
||||
// Ensuring interfaces in compile-time for InputGroupCallLink.
|
||||
var (
|
||||
_ bin.Encoder = &InputGroupCallLink{}
|
||||
_ bin.Decoder = &InputGroupCallLink{}
|
||||
_ bin.BareEncoder = &InputGroupCallLink{}
|
||||
_ bin.BareDecoder = &InputGroupCallLink{}
|
||||
|
||||
_ InputGroupCallClass = &InputGroupCallLink{}
|
||||
)
|
||||
|
||||
func (i *InputGroupCallLink) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
if !(i.Link == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InputGroupCallLink) String() string {
|
||||
if i == nil {
|
||||
return "InputGroupCallLink(nil)"
|
||||
}
|
||||
type Alias InputGroupCallLink
|
||||
return fmt.Sprintf("InputGroupCallLink%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InputGroupCallLink) TypeID() uint32 {
|
||||
return InputGroupCallLinkTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InputGroupCallLink) TypeName() string {
|
||||
return "inputGroupCallLink"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InputGroupCallLink) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "inputGroupCallLink",
|
||||
ID: InputGroupCallLinkTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Link",
|
||||
SchemaName: "link",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InputGroupCallLink) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputGroupCallLink#cf9775d8 as nil")
|
||||
}
|
||||
b.PutID(InputGroupCallLinkTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InputGroupCallLink) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputGroupCallLink#cf9775d8 as nil")
|
||||
}
|
||||
b.PutString(i.Link)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InputGroupCallLink) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputGroupCallLink#cf9775d8 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InputGroupCallLinkTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallLink#cf9775d8: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InputGroupCallLink) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputGroupCallLink#cf9775d8 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallLink#cf9775d8: field link: %w", err)
|
||||
}
|
||||
i.Link = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (i *InputGroupCallLink) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputGroupCallLink#cf9775d8 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("inputGroupCallLink")
|
||||
b.Comma()
|
||||
b.FieldStart("link")
|
||||
b.PutString(i.Link)
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (i *InputGroupCallLink) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputGroupCallLink#cf9775d8 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("inputGroupCallLink"); err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallLink#cf9775d8: %w", err)
|
||||
}
|
||||
case "link":
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallLink#cf9775d8: field link: %w", err)
|
||||
}
|
||||
i.Link = value
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetLink returns value of Link field.
|
||||
func (i *InputGroupCallLink) GetLink() (value string) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.Link
|
||||
}
|
||||
|
||||
// InputGroupCallMessage represents TL type `inputGroupCallMessage#eba0a418`.
|
||||
type InputGroupCallMessage struct {
|
||||
// Identifier of the chat with the message
|
||||
ChatID int64
|
||||
// Identifier of the message of the type messageGroupCall
|
||||
MessageID int64
|
||||
}
|
||||
|
||||
// InputGroupCallMessageTypeID is TL type id of InputGroupCallMessage.
|
||||
const InputGroupCallMessageTypeID = 0xeba0a418
|
||||
|
||||
// construct implements constructor of InputGroupCallClass.
|
||||
func (i InputGroupCallMessage) construct() InputGroupCallClass { return &i }
|
||||
|
||||
// Ensuring interfaces in compile-time for InputGroupCallMessage.
|
||||
var (
|
||||
_ bin.Encoder = &InputGroupCallMessage{}
|
||||
_ bin.Decoder = &InputGroupCallMessage{}
|
||||
_ bin.BareEncoder = &InputGroupCallMessage{}
|
||||
_ bin.BareDecoder = &InputGroupCallMessage{}
|
||||
|
||||
_ InputGroupCallClass = &InputGroupCallMessage{}
|
||||
)
|
||||
|
||||
func (i *InputGroupCallMessage) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
if !(i.ChatID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(i.MessageID == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InputGroupCallMessage) String() string {
|
||||
if i == nil {
|
||||
return "InputGroupCallMessage(nil)"
|
||||
}
|
||||
type Alias InputGroupCallMessage
|
||||
return fmt.Sprintf("InputGroupCallMessage%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InputGroupCallMessage) TypeID() uint32 {
|
||||
return InputGroupCallMessageTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InputGroupCallMessage) TypeName() string {
|
||||
return "inputGroupCallMessage"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InputGroupCallMessage) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "inputGroupCallMessage",
|
||||
ID: InputGroupCallMessageTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ChatID",
|
||||
SchemaName: "chat_id",
|
||||
},
|
||||
{
|
||||
Name: "MessageID",
|
||||
SchemaName: "message_id",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InputGroupCallMessage) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputGroupCallMessage#eba0a418 as nil")
|
||||
}
|
||||
b.PutID(InputGroupCallMessageTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InputGroupCallMessage) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputGroupCallMessage#eba0a418 as nil")
|
||||
}
|
||||
b.PutInt53(i.ChatID)
|
||||
b.PutInt53(i.MessageID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InputGroupCallMessage) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputGroupCallMessage#eba0a418 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InputGroupCallMessageTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallMessage#eba0a418: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InputGroupCallMessage) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputGroupCallMessage#eba0a418 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallMessage#eba0a418: field chat_id: %w", err)
|
||||
}
|
||||
i.ChatID = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallMessage#eba0a418: field message_id: %w", err)
|
||||
}
|
||||
i.MessageID = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (i *InputGroupCallMessage) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputGroupCallMessage#eba0a418 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("inputGroupCallMessage")
|
||||
b.Comma()
|
||||
b.FieldStart("chat_id")
|
||||
b.PutInt53(i.ChatID)
|
||||
b.Comma()
|
||||
b.FieldStart("message_id")
|
||||
b.PutInt53(i.MessageID)
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (i *InputGroupCallMessage) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputGroupCallMessage#eba0a418 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("inputGroupCallMessage"); err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallMessage#eba0a418: %w", err)
|
||||
}
|
||||
case "chat_id":
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallMessage#eba0a418: field chat_id: %w", err)
|
||||
}
|
||||
i.ChatID = value
|
||||
case "message_id":
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputGroupCallMessage#eba0a418: field message_id: %w", err)
|
||||
}
|
||||
i.MessageID = value
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetChatID returns value of ChatID field.
|
||||
func (i *InputGroupCallMessage) GetChatID() (value int64) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.ChatID
|
||||
}
|
||||
|
||||
// GetMessageID returns value of MessageID field.
|
||||
func (i *InputGroupCallMessage) GetMessageID() (value int64) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.MessageID
|
||||
}
|
||||
|
||||
// InputGroupCallClassName is schema name of InputGroupCallClass.
|
||||
const InputGroupCallClassName = "InputGroupCall"
|
||||
|
||||
// InputGroupCallClass represents InputGroupCall generic type.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := tdapi.DecodeInputGroupCall(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *tdapi.InputGroupCallLink: // inputGroupCallLink#cf9775d8
|
||||
// case *tdapi.InputGroupCallMessage: // inputGroupCallMessage#eba0a418
|
||||
// default: panic(v)
|
||||
// }
|
||||
type InputGroupCallClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() InputGroupCallClass
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
TypeID() uint32
|
||||
// TypeName returns name of type in TL schema.
|
||||
TypeName() string
|
||||
// String implements fmt.Stringer.
|
||||
String() string
|
||||
// Zero returns true if current object has a zero value.
|
||||
Zero() bool
|
||||
|
||||
EncodeTDLibJSON(b tdjson.Encoder) error
|
||||
DecodeTDLibJSON(b tdjson.Decoder) error
|
||||
}
|
||||
|
||||
// DecodeInputGroupCall implements binary de-serialization for InputGroupCallClass.
|
||||
func DecodeInputGroupCall(buf *bin.Buffer) (InputGroupCallClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case InputGroupCallLinkTypeID:
|
||||
// Decoding inputGroupCallLink#cf9775d8.
|
||||
v := InputGroupCallLink{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputGroupCallClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case InputGroupCallMessageTypeID:
|
||||
// Decoding inputGroupCallMessage#eba0a418.
|
||||
v := InputGroupCallMessage{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputGroupCallClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode InputGroupCallClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// DecodeTDLibJSONInputGroupCall implements binary de-serialization for InputGroupCallClass.
|
||||
func DecodeTDLibJSONInputGroupCall(buf tdjson.Decoder) (InputGroupCallClass, error) {
|
||||
id, err := buf.FindTypeID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case "inputGroupCallLink":
|
||||
// Decoding inputGroupCallLink#cf9775d8.
|
||||
v := InputGroupCallLink{}
|
||||
if err := v.DecodeTDLibJSON(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputGroupCallClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case "inputGroupCallMessage":
|
||||
// Decoding inputGroupCallMessage#eba0a418.
|
||||
v := InputGroupCallMessage{}
|
||||
if err := v.DecodeTDLibJSON(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputGroupCallClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode InputGroupCallClass: %w", tdjson.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// InputGroupCall boxes the InputGroupCallClass providing a helper.
|
||||
type InputGroupCallBox struct {
|
||||
InputGroupCall InputGroupCallClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for InputGroupCallBox.
|
||||
func (b *InputGroupCallBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode InputGroupCallBox to nil")
|
||||
}
|
||||
v, err := DecodeInputGroupCall(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.InputGroupCall = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for InputGroupCallBox.
|
||||
func (b *InputGroupCallBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.InputGroupCall == nil {
|
||||
return fmt.Errorf("unable to encode InputGroupCallClass as nil")
|
||||
}
|
||||
return b.InputGroupCall.Encode(buf)
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements bin.Decoder for InputGroupCallBox.
|
||||
func (b *InputGroupCallBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode InputGroupCallBox to nil")
|
||||
}
|
||||
v, err := DecodeTDLibJSONInputGroupCall(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.InputGroupCall = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements bin.Encode for InputGroupCallBox.
|
||||
func (b *InputGroupCallBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
|
||||
if b == nil || b.InputGroupCall == nil {
|
||||
return fmt.Errorf("unable to encode InputGroupCallClass as nil")
|
||||
}
|
||||
return b.InputGroupCall.EncodeTDLibJSON(buf)
|
||||
}
|
||||
Reference in New Issue
Block a user