package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type InputPeerNotifySettings struct {
Flags bin .Fields
ShowPreviews bool
Silent bool
MuteUntil int
Sound NotificationSoundClass
StoriesMuted bool
StoriesHideSender bool
StoriesSound NotificationSoundClass
}
const InputPeerNotifySettingsTypeID = 0xcacb6ae2
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
}
func (i *InputPeerNotifySettings ) String () string {
if i == nil {
return "InputPeerNotifySettings(nil)"
}
type Alias InputPeerNotifySettings
return fmt .Sprintf ("InputPeerNotifySettings%+v" , Alias (*i ))
}
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
}
}
func (*InputPeerNotifySettings ) TypeID () uint32 {
return InputPeerNotifySettingsTypeID
}
func (*InputPeerNotifySettings ) TypeName () string {
return "inputPeerNotifySettings"
}
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
}
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 )
}
}
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 )
}
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
}
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 )
}
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
}
func (i *InputPeerNotifySettings ) SetShowPreviews (value bool ) {
i .Flags .Set (0 )
i .ShowPreviews = value
}
func (i *InputPeerNotifySettings ) GetShowPreviews () (value bool , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (0 ) {
return value , false
}
return i .ShowPreviews , true
}
func (i *InputPeerNotifySettings ) SetSilent (value bool ) {
i .Flags .Set (1 )
i .Silent = value
}
func (i *InputPeerNotifySettings ) GetSilent () (value bool , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (1 ) {
return value , false
}
return i .Silent , true
}
func (i *InputPeerNotifySettings ) SetMuteUntil (value int ) {
i .Flags .Set (2 )
i .MuteUntil = value
}
func (i *InputPeerNotifySettings ) GetMuteUntil () (value int , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (2 ) {
return value , false
}
return i .MuteUntil , true
}
func (i *InputPeerNotifySettings ) SetSound (value NotificationSoundClass ) {
i .Flags .Set (3 )
i .Sound = value
}
func (i *InputPeerNotifySettings ) GetSound () (value NotificationSoundClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (3 ) {
return value , false
}
return i .Sound , true
}
func (i *InputPeerNotifySettings ) SetStoriesMuted (value bool ) {
i .Flags .Set (6 )
i .StoriesMuted = value
}
func (i *InputPeerNotifySettings ) GetStoriesMuted () (value bool , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (6 ) {
return value , false
}
return i .StoriesMuted , true
}
func (i *InputPeerNotifySettings ) SetStoriesHideSender (value bool ) {
i .Flags .Set (7 )
i .StoriesHideSender = value
}
func (i *InputPeerNotifySettings ) GetStoriesHideSender () (value bool , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (7 ) {
return value , false
}
return i .StoriesHideSender , true
}
func (i *InputPeerNotifySettings ) SetStoriesSound (value NotificationSoundClass ) {
i .Flags .Set (8 )
i .StoriesSound = value
}
func (i *InputPeerNotifySettings ) GetStoriesSound () (value NotificationSoundClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (8 ) {
return value , false
}
return i .StoriesSound , true
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .