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
469 lines
12 KiB
Go
469 lines
12 KiB
Go
// 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{}
|
|
)
|
|
|
|
// ScopeNotificationSettings represents TL type `scopeNotificationSettings#54467fe`.
|
|
type ScopeNotificationSettings struct {
|
|
// Time left before notifications will be unmuted, in seconds
|
|
MuteFor int32
|
|
// Identifier of the notification sound to be played; 0 if sound is disabled
|
|
SoundID int64
|
|
// True, if message content must be displayed in notifications
|
|
ShowPreview bool
|
|
// If true, story notifications are received only for the first 5 chats from
|
|
// topChatCategoryUsers regardless of the value of mute_stories
|
|
UseDefaultMuteStories bool
|
|
// True, if story notifications are disabled
|
|
MuteStories bool
|
|
// Identifier of the notification sound to be played for stories; 0 if sound is disabled
|
|
StorySoundID int64
|
|
// True, if the chat that posted a story must be displayed in notifications
|
|
ShowStoryPoster bool
|
|
// True, if notifications for incoming pinned messages will be created as for an ordinary
|
|
// unread message
|
|
DisablePinnedMessageNotifications bool
|
|
// True, if notifications for messages with mentions will be created as for an ordinary
|
|
// unread message
|
|
DisableMentionNotifications bool
|
|
}
|
|
|
|
// ScopeNotificationSettingsTypeID is TL type id of ScopeNotificationSettings.
|
|
const ScopeNotificationSettingsTypeID = 0x54467fe
|
|
|
|
// Ensuring interfaces in compile-time for ScopeNotificationSettings.
|
|
var (
|
|
_ bin.Encoder = &ScopeNotificationSettings{}
|
|
_ bin.Decoder = &ScopeNotificationSettings{}
|
|
_ bin.BareEncoder = &ScopeNotificationSettings{}
|
|
_ bin.BareDecoder = &ScopeNotificationSettings{}
|
|
)
|
|
|
|
func (s *ScopeNotificationSettings) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
if !(s.MuteFor == 0) {
|
|
return false
|
|
}
|
|
if !(s.SoundID == 0) {
|
|
return false
|
|
}
|
|
if !(s.ShowPreview == false) {
|
|
return false
|
|
}
|
|
if !(s.UseDefaultMuteStories == false) {
|
|
return false
|
|
}
|
|
if !(s.MuteStories == false) {
|
|
return false
|
|
}
|
|
if !(s.StorySoundID == 0) {
|
|
return false
|
|
}
|
|
if !(s.ShowStoryPoster == false) {
|
|
return false
|
|
}
|
|
if !(s.DisablePinnedMessageNotifications == false) {
|
|
return false
|
|
}
|
|
if !(s.DisableMentionNotifications == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *ScopeNotificationSettings) String() string {
|
|
if s == nil {
|
|
return "ScopeNotificationSettings(nil)"
|
|
}
|
|
type Alias ScopeNotificationSettings
|
|
return fmt.Sprintf("ScopeNotificationSettings%+v", Alias(*s))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ScopeNotificationSettings) TypeID() uint32 {
|
|
return ScopeNotificationSettingsTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ScopeNotificationSettings) TypeName() string {
|
|
return "scopeNotificationSettings"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *ScopeNotificationSettings) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "scopeNotificationSettings",
|
|
ID: ScopeNotificationSettingsTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "MuteFor",
|
|
SchemaName: "mute_for",
|
|
},
|
|
{
|
|
Name: "SoundID",
|
|
SchemaName: "sound_id",
|
|
},
|
|
{
|
|
Name: "ShowPreview",
|
|
SchemaName: "show_preview",
|
|
},
|
|
{
|
|
Name: "UseDefaultMuteStories",
|
|
SchemaName: "use_default_mute_stories",
|
|
},
|
|
{
|
|
Name: "MuteStories",
|
|
SchemaName: "mute_stories",
|
|
},
|
|
{
|
|
Name: "StorySoundID",
|
|
SchemaName: "story_sound_id",
|
|
},
|
|
{
|
|
Name: "ShowStoryPoster",
|
|
SchemaName: "show_story_poster",
|
|
},
|
|
{
|
|
Name: "DisablePinnedMessageNotifications",
|
|
SchemaName: "disable_pinned_message_notifications",
|
|
},
|
|
{
|
|
Name: "DisableMentionNotifications",
|
|
SchemaName: "disable_mention_notifications",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *ScopeNotificationSettings) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode scopeNotificationSettings#54467fe as nil")
|
|
}
|
|
b.PutID(ScopeNotificationSettingsTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *ScopeNotificationSettings) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode scopeNotificationSettings#54467fe as nil")
|
|
}
|
|
b.PutInt32(s.MuteFor)
|
|
b.PutLong(s.SoundID)
|
|
b.PutBool(s.ShowPreview)
|
|
b.PutBool(s.UseDefaultMuteStories)
|
|
b.PutBool(s.MuteStories)
|
|
b.PutLong(s.StorySoundID)
|
|
b.PutBool(s.ShowStoryPoster)
|
|
b.PutBool(s.DisablePinnedMessageNotifications)
|
|
b.PutBool(s.DisableMentionNotifications)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *ScopeNotificationSettings) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode scopeNotificationSettings#54467fe to nil")
|
|
}
|
|
if err := b.ConsumeID(ScopeNotificationSettingsTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *ScopeNotificationSettings) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode scopeNotificationSettings#54467fe to nil")
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field mute_for: %w", err)
|
|
}
|
|
s.MuteFor = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field sound_id: %w", err)
|
|
}
|
|
s.SoundID = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field show_preview: %w", err)
|
|
}
|
|
s.ShowPreview = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field use_default_mute_stories: %w", err)
|
|
}
|
|
s.UseDefaultMuteStories = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field mute_stories: %w", err)
|
|
}
|
|
s.MuteStories = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field story_sound_id: %w", err)
|
|
}
|
|
s.StorySoundID = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field show_story_poster: %w", err)
|
|
}
|
|
s.ShowStoryPoster = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field disable_pinned_message_notifications: %w", err)
|
|
}
|
|
s.DisablePinnedMessageNotifications = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field disable_mention_notifications: %w", err)
|
|
}
|
|
s.DisableMentionNotifications = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (s *ScopeNotificationSettings) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode scopeNotificationSettings#54467fe as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("scopeNotificationSettings")
|
|
b.Comma()
|
|
b.FieldStart("mute_for")
|
|
b.PutInt32(s.MuteFor)
|
|
b.Comma()
|
|
b.FieldStart("sound_id")
|
|
b.PutLong(s.SoundID)
|
|
b.Comma()
|
|
b.FieldStart("show_preview")
|
|
b.PutBool(s.ShowPreview)
|
|
b.Comma()
|
|
b.FieldStart("use_default_mute_stories")
|
|
b.PutBool(s.UseDefaultMuteStories)
|
|
b.Comma()
|
|
b.FieldStart("mute_stories")
|
|
b.PutBool(s.MuteStories)
|
|
b.Comma()
|
|
b.FieldStart("story_sound_id")
|
|
b.PutLong(s.StorySoundID)
|
|
b.Comma()
|
|
b.FieldStart("show_story_poster")
|
|
b.PutBool(s.ShowStoryPoster)
|
|
b.Comma()
|
|
b.FieldStart("disable_pinned_message_notifications")
|
|
b.PutBool(s.DisablePinnedMessageNotifications)
|
|
b.Comma()
|
|
b.FieldStart("disable_mention_notifications")
|
|
b.PutBool(s.DisableMentionNotifications)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (s *ScopeNotificationSettings) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode scopeNotificationSettings#54467fe to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("scopeNotificationSettings"); err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: %w", err)
|
|
}
|
|
case "mute_for":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field mute_for: %w", err)
|
|
}
|
|
s.MuteFor = value
|
|
case "sound_id":
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field sound_id: %w", err)
|
|
}
|
|
s.SoundID = value
|
|
case "show_preview":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field show_preview: %w", err)
|
|
}
|
|
s.ShowPreview = value
|
|
case "use_default_mute_stories":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field use_default_mute_stories: %w", err)
|
|
}
|
|
s.UseDefaultMuteStories = value
|
|
case "mute_stories":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field mute_stories: %w", err)
|
|
}
|
|
s.MuteStories = value
|
|
case "story_sound_id":
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field story_sound_id: %w", err)
|
|
}
|
|
s.StorySoundID = value
|
|
case "show_story_poster":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field show_story_poster: %w", err)
|
|
}
|
|
s.ShowStoryPoster = value
|
|
case "disable_pinned_message_notifications":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field disable_pinned_message_notifications: %w", err)
|
|
}
|
|
s.DisablePinnedMessageNotifications = value
|
|
case "disable_mention_notifications":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode scopeNotificationSettings#54467fe: field disable_mention_notifications: %w", err)
|
|
}
|
|
s.DisableMentionNotifications = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetMuteFor returns value of MuteFor field.
|
|
func (s *ScopeNotificationSettings) GetMuteFor() (value int32) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.MuteFor
|
|
}
|
|
|
|
// GetSoundID returns value of SoundID field.
|
|
func (s *ScopeNotificationSettings) GetSoundID() (value int64) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.SoundID
|
|
}
|
|
|
|
// GetShowPreview returns value of ShowPreview field.
|
|
func (s *ScopeNotificationSettings) GetShowPreview() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.ShowPreview
|
|
}
|
|
|
|
// GetUseDefaultMuteStories returns value of UseDefaultMuteStories field.
|
|
func (s *ScopeNotificationSettings) GetUseDefaultMuteStories() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.UseDefaultMuteStories
|
|
}
|
|
|
|
// GetMuteStories returns value of MuteStories field.
|
|
func (s *ScopeNotificationSettings) GetMuteStories() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.MuteStories
|
|
}
|
|
|
|
// GetStorySoundID returns value of StorySoundID field.
|
|
func (s *ScopeNotificationSettings) GetStorySoundID() (value int64) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.StorySoundID
|
|
}
|
|
|
|
// GetShowStoryPoster returns value of ShowStoryPoster field.
|
|
func (s *ScopeNotificationSettings) GetShowStoryPoster() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.ShowStoryPoster
|
|
}
|
|
|
|
// GetDisablePinnedMessageNotifications returns value of DisablePinnedMessageNotifications field.
|
|
func (s *ScopeNotificationSettings) GetDisablePinnedMessageNotifications() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.DisablePinnedMessageNotifications
|
|
}
|
|
|
|
// GetDisableMentionNotifications returns value of DisableMentionNotifications field.
|
|
func (s *ScopeNotificationSettings) GetDisableMentionNotifications() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.DisableMentionNotifications
|
|
}
|