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
503 lines
12 KiB
Go
Generated
503 lines
12 KiB
Go
Generated
// 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{}
|
|
)
|
|
|
|
// InputPeerNotifySettings represents TL type `inputPeerNotifySettings#cacb6ae2`.
|
|
// Notification settings.
|
|
//
|
|
// See https://core.telegram.org/constructor/inputPeerNotifySettings for reference.
|
|
type InputPeerNotifySettings struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// If the text of the message shall be displayed in notification
|
|
//
|
|
// Use SetShowPreviews and GetShowPreviews helpers.
|
|
ShowPreviews bool
|
|
// Peer was muted?
|
|
//
|
|
// Use SetSilent and GetSilent helpers.
|
|
Silent bool
|
|
// Date until which all notifications shall be switched off
|
|
//
|
|
// Use SetMuteUntil and GetMuteUntil helpers.
|
|
MuteUntil int
|
|
// Identifier of an audio file to play for notifications.
|
|
//
|
|
// Use SetSound and GetSound helpers.
|
|
Sound NotificationSoundClass
|
|
// Whether story notifications should be disabled.
|
|
//
|
|
// Use SetStoriesMuted and GetStoriesMuted helpers.
|
|
StoriesMuted bool
|
|
// Whether the sender name should be displayed in story notifications.
|
|
//
|
|
// Use SetStoriesHideSender and GetStoriesHideSender helpers.
|
|
StoriesHideSender bool
|
|
// Identifier of an audio file to play for story notifications.
|
|
//
|
|
// Use SetStoriesSound and GetStoriesSound helpers.
|
|
StoriesSound NotificationSoundClass
|
|
}
|
|
|
|
// InputPeerNotifySettingsTypeID is TL type id of InputPeerNotifySettings.
|
|
const InputPeerNotifySettingsTypeID = 0xcacb6ae2
|
|
|
|
// Ensuring interfaces in compile-time for InputPeerNotifySettings.
|
|
var (
|
|
_ bin.Encoder = &InputPeerNotifySettings{}
|
|
_ bin.Decoder = &InputPeerNotifySettings{}
|
|
_ bin.BareEncoder = &InputPeerNotifySettings{}
|
|
_ bin.BareDecoder = &InputPeerNotifySettings{}
|
|
)
|
|
|
|
func (i *InputPeerNotifySettings) Zero() bool {
|
|
if i == nil {
|
|
return true
|
|
}
|
|
if !(i.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(i.ShowPreviews == false) {
|
|
return false
|
|
}
|
|
if !(i.Silent == false) {
|
|
return false
|
|
}
|
|
if !(i.MuteUntil == 0) {
|
|
return false
|
|
}
|
|
if !(i.Sound == nil) {
|
|
return false
|
|
}
|
|
if !(i.StoriesMuted == false) {
|
|
return false
|
|
}
|
|
if !(i.StoriesHideSender == false) {
|
|
return false
|
|
}
|
|
if !(i.StoriesSound == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (i *InputPeerNotifySettings) String() string {
|
|
if i == nil {
|
|
return "InputPeerNotifySettings(nil)"
|
|
}
|
|
type Alias InputPeerNotifySettings
|
|
return fmt.Sprintf("InputPeerNotifySettings%+v", Alias(*i))
|
|
}
|
|
|
|
// FillFrom fills InputPeerNotifySettings from given interface.
|
|
func (i *InputPeerNotifySettings) FillFrom(from interface {
|
|
GetShowPreviews() (value bool, ok bool)
|
|
GetSilent() (value bool, ok bool)
|
|
GetMuteUntil() (value int, ok bool)
|
|
GetSound() (value NotificationSoundClass, ok bool)
|
|
GetStoriesMuted() (value bool, ok bool)
|
|
GetStoriesHideSender() (value bool, ok bool)
|
|
GetStoriesSound() (value NotificationSoundClass, ok bool)
|
|
}) {
|
|
if val, ok := from.GetShowPreviews(); ok {
|
|
i.ShowPreviews = val
|
|
}
|
|
|
|
if val, ok := from.GetSilent(); ok {
|
|
i.Silent = val
|
|
}
|
|
|
|
if val, ok := from.GetMuteUntil(); ok {
|
|
i.MuteUntil = val
|
|
}
|
|
|
|
if val, ok := from.GetSound(); ok {
|
|
i.Sound = val
|
|
}
|
|
|
|
if val, ok := from.GetStoriesMuted(); ok {
|
|
i.StoriesMuted = val
|
|
}
|
|
|
|
if val, ok := from.GetStoriesHideSender(); ok {
|
|
i.StoriesHideSender = val
|
|
}
|
|
|
|
if val, ok := from.GetStoriesSound(); ok {
|
|
i.StoriesSound = val
|
|
}
|
|
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*InputPeerNotifySettings) TypeID() uint32 {
|
|
return InputPeerNotifySettingsTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*InputPeerNotifySettings) TypeName() string {
|
|
return "inputPeerNotifySettings"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (i *InputPeerNotifySettings) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "inputPeerNotifySettings",
|
|
ID: InputPeerNotifySettingsTypeID,
|
|
}
|
|
if i == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ShowPreviews",
|
|
SchemaName: "show_previews",
|
|
Null: !i.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "Silent",
|
|
SchemaName: "silent",
|
|
Null: !i.Flags.Has(1),
|
|
},
|
|
{
|
|
Name: "MuteUntil",
|
|
SchemaName: "mute_until",
|
|
Null: !i.Flags.Has(2),
|
|
},
|
|
{
|
|
Name: "Sound",
|
|
SchemaName: "sound",
|
|
Null: !i.Flags.Has(3),
|
|
},
|
|
{
|
|
Name: "StoriesMuted",
|
|
SchemaName: "stories_muted",
|
|
Null: !i.Flags.Has(6),
|
|
},
|
|
{
|
|
Name: "StoriesHideSender",
|
|
SchemaName: "stories_hide_sender",
|
|
Null: !i.Flags.Has(7),
|
|
},
|
|
{
|
|
Name: "StoriesSound",
|
|
SchemaName: "stories_sound",
|
|
Null: !i.Flags.Has(8),
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (i *InputPeerNotifySettings) SetFlags() {
|
|
if !(i.ShowPreviews == false) {
|
|
i.Flags.Set(0)
|
|
}
|
|
if !(i.Silent == false) {
|
|
i.Flags.Set(1)
|
|
}
|
|
if !(i.MuteUntil == 0) {
|
|
i.Flags.Set(2)
|
|
}
|
|
if !(i.Sound == nil) {
|
|
i.Flags.Set(3)
|
|
}
|
|
if !(i.StoriesMuted == false) {
|
|
i.Flags.Set(6)
|
|
}
|
|
if !(i.StoriesHideSender == false) {
|
|
i.Flags.Set(7)
|
|
}
|
|
if !(i.StoriesSound == nil) {
|
|
i.Flags.Set(8)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (i *InputPeerNotifySettings) Encode(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't encode inputPeerNotifySettings#cacb6ae2 as nil")
|
|
}
|
|
b.PutID(InputPeerNotifySettingsTypeID)
|
|
return i.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (i *InputPeerNotifySettings) EncodeBare(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't encode inputPeerNotifySettings#cacb6ae2 as nil")
|
|
}
|
|
i.SetFlags()
|
|
if err := i.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: field flags: %w", err)
|
|
}
|
|
if i.Flags.Has(0) {
|
|
b.PutBool(i.ShowPreviews)
|
|
}
|
|
if i.Flags.Has(1) {
|
|
b.PutBool(i.Silent)
|
|
}
|
|
if i.Flags.Has(2) {
|
|
b.PutInt(i.MuteUntil)
|
|
}
|
|
if i.Flags.Has(3) {
|
|
if i.Sound == nil {
|
|
return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: field sound is nil")
|
|
}
|
|
if err := i.Sound.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: field sound: %w", err)
|
|
}
|
|
}
|
|
if i.Flags.Has(6) {
|
|
b.PutBool(i.StoriesMuted)
|
|
}
|
|
if i.Flags.Has(7) {
|
|
b.PutBool(i.StoriesHideSender)
|
|
}
|
|
if i.Flags.Has(8) {
|
|
if i.StoriesSound == nil {
|
|
return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: field stories_sound is nil")
|
|
}
|
|
if err := i.StoriesSound.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: field stories_sound: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (i *InputPeerNotifySettings) Decode(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't decode inputPeerNotifySettings#cacb6ae2 to nil")
|
|
}
|
|
if err := b.ConsumeID(InputPeerNotifySettingsTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: %w", err)
|
|
}
|
|
return i.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (i *InputPeerNotifySettings) DecodeBare(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't decode inputPeerNotifySettings#cacb6ae2 to nil")
|
|
}
|
|
{
|
|
if err := i.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field flags: %w", err)
|
|
}
|
|
}
|
|
if i.Flags.Has(0) {
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field show_previews: %w", err)
|
|
}
|
|
i.ShowPreviews = value
|
|
}
|
|
if i.Flags.Has(1) {
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field silent: %w", err)
|
|
}
|
|
i.Silent = value
|
|
}
|
|
if i.Flags.Has(2) {
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field mute_until: %w", err)
|
|
}
|
|
i.MuteUntil = value
|
|
}
|
|
if i.Flags.Has(3) {
|
|
value, err := DecodeNotificationSound(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field sound: %w", err)
|
|
}
|
|
i.Sound = value
|
|
}
|
|
if i.Flags.Has(6) {
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field stories_muted: %w", err)
|
|
}
|
|
i.StoriesMuted = value
|
|
}
|
|
if i.Flags.Has(7) {
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field stories_hide_sender: %w", err)
|
|
}
|
|
i.StoriesHideSender = value
|
|
}
|
|
if i.Flags.Has(8) {
|
|
value, err := DecodeNotificationSound(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field stories_sound: %w", err)
|
|
}
|
|
i.StoriesSound = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetShowPreviews sets value of ShowPreviews conditional field.
|
|
func (i *InputPeerNotifySettings) SetShowPreviews(value bool) {
|
|
i.Flags.Set(0)
|
|
i.ShowPreviews = value
|
|
}
|
|
|
|
// GetShowPreviews returns value of ShowPreviews conditional field and
|
|
// boolean which is true if field was set.
|
|
func (i *InputPeerNotifySettings) GetShowPreviews() (value bool, ok bool) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
if !i.Flags.Has(0) {
|
|
return value, false
|
|
}
|
|
return i.ShowPreviews, true
|
|
}
|
|
|
|
// SetSilent sets value of Silent conditional field.
|
|
func (i *InputPeerNotifySettings) SetSilent(value bool) {
|
|
i.Flags.Set(1)
|
|
i.Silent = value
|
|
}
|
|
|
|
// GetSilent returns value of Silent conditional field and
|
|
// boolean which is true if field was set.
|
|
func (i *InputPeerNotifySettings) GetSilent() (value bool, ok bool) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
if !i.Flags.Has(1) {
|
|
return value, false
|
|
}
|
|
return i.Silent, true
|
|
}
|
|
|
|
// SetMuteUntil sets value of MuteUntil conditional field.
|
|
func (i *InputPeerNotifySettings) SetMuteUntil(value int) {
|
|
i.Flags.Set(2)
|
|
i.MuteUntil = value
|
|
}
|
|
|
|
// GetMuteUntil returns value of MuteUntil conditional field and
|
|
// boolean which is true if field was set.
|
|
func (i *InputPeerNotifySettings) GetMuteUntil() (value int, ok bool) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
if !i.Flags.Has(2) {
|
|
return value, false
|
|
}
|
|
return i.MuteUntil, true
|
|
}
|
|
|
|
// SetSound sets value of Sound conditional field.
|
|
func (i *InputPeerNotifySettings) SetSound(value NotificationSoundClass) {
|
|
i.Flags.Set(3)
|
|
i.Sound = value
|
|
}
|
|
|
|
// GetSound returns value of Sound conditional field and
|
|
// boolean which is true if field was set.
|
|
func (i *InputPeerNotifySettings) GetSound() (value NotificationSoundClass, ok bool) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
if !i.Flags.Has(3) {
|
|
return value, false
|
|
}
|
|
return i.Sound, true
|
|
}
|
|
|
|
// SetStoriesMuted sets value of StoriesMuted conditional field.
|
|
func (i *InputPeerNotifySettings) SetStoriesMuted(value bool) {
|
|
i.Flags.Set(6)
|
|
i.StoriesMuted = value
|
|
}
|
|
|
|
// GetStoriesMuted returns value of StoriesMuted conditional field and
|
|
// boolean which is true if field was set.
|
|
func (i *InputPeerNotifySettings) GetStoriesMuted() (value bool, ok bool) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
if !i.Flags.Has(6) {
|
|
return value, false
|
|
}
|
|
return i.StoriesMuted, true
|
|
}
|
|
|
|
// SetStoriesHideSender sets value of StoriesHideSender conditional field.
|
|
func (i *InputPeerNotifySettings) SetStoriesHideSender(value bool) {
|
|
i.Flags.Set(7)
|
|
i.StoriesHideSender = value
|
|
}
|
|
|
|
// GetStoriesHideSender returns value of StoriesHideSender conditional field and
|
|
// boolean which is true if field was set.
|
|
func (i *InputPeerNotifySettings) GetStoriesHideSender() (value bool, ok bool) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
if !i.Flags.Has(7) {
|
|
return value, false
|
|
}
|
|
return i.StoriesHideSender, true
|
|
}
|
|
|
|
// SetStoriesSound sets value of StoriesSound conditional field.
|
|
func (i *InputPeerNotifySettings) SetStoriesSound(value NotificationSoundClass) {
|
|
i.Flags.Set(8)
|
|
i.StoriesSound = value
|
|
}
|
|
|
|
// GetStoriesSound returns value of StoriesSound conditional field and
|
|
// boolean which is true if field was set.
|
|
func (i *InputPeerNotifySettings) GetStoriesSound() (value NotificationSoundClass, ok bool) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
if !i.Flags.Has(8) {
|
|
return value, false
|
|
}
|
|
return i.StoriesSound, true
|
|
}
|