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,229 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// NewChatPrivacySettings represents TL type `newChatPrivacySettings#75fc260`.
|
||||
type NewChatPrivacySettings struct {
|
||||
// True, if non-contacts users are able to write first to the current user. Telegram
|
||||
// Premium subscribers are able to write first regardless of this setting
|
||||
AllowNewChatsFromUnknownUsers bool
|
||||
// Number of Telegram Stars that must be paid for every incoming private message by
|
||||
// non-contacts; 0-getOption("paid_message_star_count_max").
|
||||
IncomingPaidMessageStarCount int64
|
||||
}
|
||||
|
||||
// NewChatPrivacySettingsTypeID is TL type id of NewChatPrivacySettings.
|
||||
const NewChatPrivacySettingsTypeID = 0x75fc260
|
||||
|
||||
// Ensuring interfaces in compile-time for NewChatPrivacySettings.
|
||||
var (
|
||||
_ bin.Encoder = &NewChatPrivacySettings{}
|
||||
_ bin.Decoder = &NewChatPrivacySettings{}
|
||||
_ bin.BareEncoder = &NewChatPrivacySettings{}
|
||||
_ bin.BareDecoder = &NewChatPrivacySettings{}
|
||||
)
|
||||
|
||||
func (n *NewChatPrivacySettings) Zero() bool {
|
||||
if n == nil {
|
||||
return true
|
||||
}
|
||||
if !(n.AllowNewChatsFromUnknownUsers == false) {
|
||||
return false
|
||||
}
|
||||
if !(n.IncomingPaidMessageStarCount == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (n *NewChatPrivacySettings) String() string {
|
||||
if n == nil {
|
||||
return "NewChatPrivacySettings(nil)"
|
||||
}
|
||||
type Alias NewChatPrivacySettings
|
||||
return fmt.Sprintf("NewChatPrivacySettings%+v", Alias(*n))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*NewChatPrivacySettings) TypeID() uint32 {
|
||||
return NewChatPrivacySettingsTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*NewChatPrivacySettings) TypeName() string {
|
||||
return "newChatPrivacySettings"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (n *NewChatPrivacySettings) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "newChatPrivacySettings",
|
||||
ID: NewChatPrivacySettingsTypeID,
|
||||
}
|
||||
if n == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "AllowNewChatsFromUnknownUsers",
|
||||
SchemaName: "allow_new_chats_from_unknown_users",
|
||||
},
|
||||
{
|
||||
Name: "IncomingPaidMessageStarCount",
|
||||
SchemaName: "incoming_paid_message_star_count",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (n *NewChatPrivacySettings) Encode(b *bin.Buffer) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't encode newChatPrivacySettings#75fc260 as nil")
|
||||
}
|
||||
b.PutID(NewChatPrivacySettingsTypeID)
|
||||
return n.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (n *NewChatPrivacySettings) EncodeBare(b *bin.Buffer) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't encode newChatPrivacySettings#75fc260 as nil")
|
||||
}
|
||||
b.PutBool(n.AllowNewChatsFromUnknownUsers)
|
||||
b.PutInt53(n.IncomingPaidMessageStarCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (n *NewChatPrivacySettings) Decode(b *bin.Buffer) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't decode newChatPrivacySettings#75fc260 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(NewChatPrivacySettingsTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode newChatPrivacySettings#75fc260: %w", err)
|
||||
}
|
||||
return n.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (n *NewChatPrivacySettings) DecodeBare(b *bin.Buffer) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't decode newChatPrivacySettings#75fc260 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode newChatPrivacySettings#75fc260: field allow_new_chats_from_unknown_users: %w", err)
|
||||
}
|
||||
n.AllowNewChatsFromUnknownUsers = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode newChatPrivacySettings#75fc260: field incoming_paid_message_star_count: %w", err)
|
||||
}
|
||||
n.IncomingPaidMessageStarCount = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (n *NewChatPrivacySettings) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't encode newChatPrivacySettings#75fc260 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("newChatPrivacySettings")
|
||||
b.Comma()
|
||||
b.FieldStart("allow_new_chats_from_unknown_users")
|
||||
b.PutBool(n.AllowNewChatsFromUnknownUsers)
|
||||
b.Comma()
|
||||
b.FieldStart("incoming_paid_message_star_count")
|
||||
b.PutInt53(n.IncomingPaidMessageStarCount)
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (n *NewChatPrivacySettings) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't decode newChatPrivacySettings#75fc260 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("newChatPrivacySettings"); err != nil {
|
||||
return fmt.Errorf("unable to decode newChatPrivacySettings#75fc260: %w", err)
|
||||
}
|
||||
case "allow_new_chats_from_unknown_users":
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode newChatPrivacySettings#75fc260: field allow_new_chats_from_unknown_users: %w", err)
|
||||
}
|
||||
n.AllowNewChatsFromUnknownUsers = value
|
||||
case "incoming_paid_message_star_count":
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode newChatPrivacySettings#75fc260: field incoming_paid_message_star_count: %w", err)
|
||||
}
|
||||
n.IncomingPaidMessageStarCount = value
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetAllowNewChatsFromUnknownUsers returns value of AllowNewChatsFromUnknownUsers field.
|
||||
func (n *NewChatPrivacySettings) GetAllowNewChatsFromUnknownUsers() (value bool) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
return n.AllowNewChatsFromUnknownUsers
|
||||
}
|
||||
|
||||
// GetIncomingPaidMessageStarCount returns value of IncomingPaidMessageStarCount field.
|
||||
func (n *NewChatPrivacySettings) GetIncomingPaidMessageStarCount() (value int64) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
return n.IncomingPaidMessageStarCount
|
||||
}
|
||||
Reference in New Issue
Block a user