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,334 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// ReactionsNotifySettings represents TL type `reactionsNotifySettings#56e34970`.
|
||||
// Reaction notification settings, see here »¹ for more info.
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/api/reactions#notifications-about-reactions
|
||||
//
|
||||
// See https://core.telegram.org/constructor/reactionsNotifySettings for reference.
|
||||
type ReactionsNotifySettings struct {
|
||||
// Flags, see TL conditional fields¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
||||
Flags bin.Fields
|
||||
// Message reaction notification settings, if not set completely disables
|
||||
// notifications/updates about message reactions.
|
||||
//
|
||||
// Use SetMessagesNotifyFrom and GetMessagesNotifyFrom helpers.
|
||||
MessagesNotifyFrom ReactionNotificationsFromClass
|
||||
// Story reaction notification settings, if not set completely disables
|
||||
// notifications/updates about reactions to stories.
|
||||
//
|
||||
// Use SetStoriesNotifyFrom and GetStoriesNotifyFrom helpers.
|
||||
StoriesNotifyFrom ReactionNotificationsFromClass
|
||||
// Notification sound for reactions »¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/ringtones
|
||||
Sound NotificationSoundClass
|
||||
// If false, push notifications »¹ about message/story reactions will only be of type
|
||||
// REACT_HIDDEN/REACT_STORY_HIDDEN, without any information about the reacted-to story or
|
||||
// the reaction itself.
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/push-updates
|
||||
ShowPreviews bool
|
||||
}
|
||||
|
||||
// ReactionsNotifySettingsTypeID is TL type id of ReactionsNotifySettings.
|
||||
const ReactionsNotifySettingsTypeID = 0x56e34970
|
||||
|
||||
// Ensuring interfaces in compile-time for ReactionsNotifySettings.
|
||||
var (
|
||||
_ bin.Encoder = &ReactionsNotifySettings{}
|
||||
_ bin.Decoder = &ReactionsNotifySettings{}
|
||||
_ bin.BareEncoder = &ReactionsNotifySettings{}
|
||||
_ bin.BareDecoder = &ReactionsNotifySettings{}
|
||||
)
|
||||
|
||||
func (r *ReactionsNotifySettings) Zero() bool {
|
||||
if r == nil {
|
||||
return true
|
||||
}
|
||||
if !(r.Flags.Zero()) {
|
||||
return false
|
||||
}
|
||||
if !(r.MessagesNotifyFrom == nil) {
|
||||
return false
|
||||
}
|
||||
if !(r.StoriesNotifyFrom == nil) {
|
||||
return false
|
||||
}
|
||||
if !(r.Sound == nil) {
|
||||
return false
|
||||
}
|
||||
if !(r.ShowPreviews == false) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (r *ReactionsNotifySettings) String() string {
|
||||
if r == nil {
|
||||
return "ReactionsNotifySettings(nil)"
|
||||
}
|
||||
type Alias ReactionsNotifySettings
|
||||
return fmt.Sprintf("ReactionsNotifySettings%+v", Alias(*r))
|
||||
}
|
||||
|
||||
// FillFrom fills ReactionsNotifySettings from given interface.
|
||||
func (r *ReactionsNotifySettings) FillFrom(from interface {
|
||||
GetMessagesNotifyFrom() (value ReactionNotificationsFromClass, ok bool)
|
||||
GetStoriesNotifyFrom() (value ReactionNotificationsFromClass, ok bool)
|
||||
GetSound() (value NotificationSoundClass)
|
||||
GetShowPreviews() (value bool)
|
||||
}) {
|
||||
if val, ok := from.GetMessagesNotifyFrom(); ok {
|
||||
r.MessagesNotifyFrom = val
|
||||
}
|
||||
|
||||
if val, ok := from.GetStoriesNotifyFrom(); ok {
|
||||
r.StoriesNotifyFrom = val
|
||||
}
|
||||
|
||||
r.Sound = from.GetSound()
|
||||
r.ShowPreviews = from.GetShowPreviews()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*ReactionsNotifySettings) TypeID() uint32 {
|
||||
return ReactionsNotifySettingsTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*ReactionsNotifySettings) TypeName() string {
|
||||
return "reactionsNotifySettings"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (r *ReactionsNotifySettings) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "reactionsNotifySettings",
|
||||
ID: ReactionsNotifySettingsTypeID,
|
||||
}
|
||||
if r == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "MessagesNotifyFrom",
|
||||
SchemaName: "messages_notify_from",
|
||||
Null: !r.Flags.Has(0),
|
||||
},
|
||||
{
|
||||
Name: "StoriesNotifyFrom",
|
||||
SchemaName: "stories_notify_from",
|
||||
Null: !r.Flags.Has(1),
|
||||
},
|
||||
{
|
||||
Name: "Sound",
|
||||
SchemaName: "sound",
|
||||
},
|
||||
{
|
||||
Name: "ShowPreviews",
|
||||
SchemaName: "show_previews",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// SetFlags sets flags for non-zero fields.
|
||||
func (r *ReactionsNotifySettings) SetFlags() {
|
||||
if !(r.MessagesNotifyFrom == nil) {
|
||||
r.Flags.Set(0)
|
||||
}
|
||||
if !(r.StoriesNotifyFrom == nil) {
|
||||
r.Flags.Set(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (r *ReactionsNotifySettings) Encode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode reactionsNotifySettings#56e34970 as nil")
|
||||
}
|
||||
b.PutID(ReactionsNotifySettingsTypeID)
|
||||
return r.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (r *ReactionsNotifySettings) EncodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode reactionsNotifySettings#56e34970 as nil")
|
||||
}
|
||||
r.SetFlags()
|
||||
if err := r.Flags.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field flags: %w", err)
|
||||
}
|
||||
if r.Flags.Has(0) {
|
||||
if r.MessagesNotifyFrom == nil {
|
||||
return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field messages_notify_from is nil")
|
||||
}
|
||||
if err := r.MessagesNotifyFrom.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field messages_notify_from: %w", err)
|
||||
}
|
||||
}
|
||||
if r.Flags.Has(1) {
|
||||
if r.StoriesNotifyFrom == nil {
|
||||
return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field stories_notify_from is nil")
|
||||
}
|
||||
if err := r.StoriesNotifyFrom.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field stories_notify_from: %w", err)
|
||||
}
|
||||
}
|
||||
if r.Sound == nil {
|
||||
return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field sound is nil")
|
||||
}
|
||||
if err := r.Sound.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field sound: %w", err)
|
||||
}
|
||||
b.PutBool(r.ShowPreviews)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (r *ReactionsNotifySettings) Decode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode reactionsNotifySettings#56e34970 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(ReactionsNotifySettingsTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: %w", err)
|
||||
}
|
||||
return r.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (r *ReactionsNotifySettings) DecodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode reactionsNotifySettings#56e34970 to nil")
|
||||
}
|
||||
{
|
||||
if err := r.Flags.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field flags: %w", err)
|
||||
}
|
||||
}
|
||||
if r.Flags.Has(0) {
|
||||
value, err := DecodeReactionNotificationsFrom(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field messages_notify_from: %w", err)
|
||||
}
|
||||
r.MessagesNotifyFrom = value
|
||||
}
|
||||
if r.Flags.Has(1) {
|
||||
value, err := DecodeReactionNotificationsFrom(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field stories_notify_from: %w", err)
|
||||
}
|
||||
r.StoriesNotifyFrom = value
|
||||
}
|
||||
{
|
||||
value, err := DecodeNotificationSound(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field sound: %w", err)
|
||||
}
|
||||
r.Sound = value
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field show_previews: %w", err)
|
||||
}
|
||||
r.ShowPreviews = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetMessagesNotifyFrom sets value of MessagesNotifyFrom conditional field.
|
||||
func (r *ReactionsNotifySettings) SetMessagesNotifyFrom(value ReactionNotificationsFromClass) {
|
||||
r.Flags.Set(0)
|
||||
r.MessagesNotifyFrom = value
|
||||
}
|
||||
|
||||
// GetMessagesNotifyFrom returns value of MessagesNotifyFrom conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (r *ReactionsNotifySettings) GetMessagesNotifyFrom() (value ReactionNotificationsFromClass, ok bool) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
if !r.Flags.Has(0) {
|
||||
return value, false
|
||||
}
|
||||
return r.MessagesNotifyFrom, true
|
||||
}
|
||||
|
||||
// SetStoriesNotifyFrom sets value of StoriesNotifyFrom conditional field.
|
||||
func (r *ReactionsNotifySettings) SetStoriesNotifyFrom(value ReactionNotificationsFromClass) {
|
||||
r.Flags.Set(1)
|
||||
r.StoriesNotifyFrom = value
|
||||
}
|
||||
|
||||
// GetStoriesNotifyFrom returns value of StoriesNotifyFrom conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (r *ReactionsNotifySettings) GetStoriesNotifyFrom() (value ReactionNotificationsFromClass, ok bool) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
if !r.Flags.Has(1) {
|
||||
return value, false
|
||||
}
|
||||
return r.StoriesNotifyFrom, true
|
||||
}
|
||||
|
||||
// GetSound returns value of Sound field.
|
||||
func (r *ReactionsNotifySettings) GetSound() (value NotificationSoundClass) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
return r.Sound
|
||||
}
|
||||
|
||||
// GetShowPreviews returns value of ShowPreviews field.
|
||||
func (r *ReactionsNotifySettings) GetShowPreviews() (value bool) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
return r.ShowPreviews
|
||||
}
|
||||
Reference in New Issue
Block a user