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 ReactionsNotifySettings struct {
Flags bin .Fields
MessagesNotifyFrom ReactionNotificationsFromClass
StoriesNotifyFrom ReactionNotificationsFromClass
PollVotesNotifyFrom ReactionNotificationsFromClass
Sound NotificationSoundClass
ShowPreviews bool
}
const ReactionsNotifySettingsTypeID = 0x71e4ea58
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 .PollVotesNotifyFrom == nil ) {
return false
}
if !(r .Sound == nil ) {
return false
}
if !(r .ShowPreviews == false ) {
return false
}
return true
}
func (r *ReactionsNotifySettings ) String () string {
if r == nil {
return "ReactionsNotifySettings(nil)"
}
type Alias ReactionsNotifySettings
return fmt .Sprintf ("ReactionsNotifySettings%+v" , Alias (*r ))
}
func (r *ReactionsNotifySettings ) FillFrom (from interface {
GetMessagesNotifyFrom () (value ReactionNotificationsFromClass , ok bool )
GetStoriesNotifyFrom () (value ReactionNotificationsFromClass , ok bool )
GetPollVotesNotifyFrom () (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
}
if val , ok := from .GetPollVotesNotifyFrom (); ok {
r .PollVotesNotifyFrom = val
}
r .Sound = from .GetSound ()
r .ShowPreviews = from .GetShowPreviews ()
}
func (*ReactionsNotifySettings ) TypeID () uint32 {
return ReactionsNotifySettingsTypeID
}
func (*ReactionsNotifySettings ) TypeName () string {
return "reactionsNotifySettings"
}
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 : "PollVotesNotifyFrom" ,
SchemaName : "poll_votes_notify_from" ,
Null : !r .Flags .Has (2 ),
},
{
Name : "Sound" ,
SchemaName : "sound" ,
},
{
Name : "ShowPreviews" ,
SchemaName : "show_previews" ,
},
}
return typ
}
func (r *ReactionsNotifySettings ) SetFlags () {
if !(r .MessagesNotifyFrom == nil ) {
r .Flags .Set (0 )
}
if !(r .StoriesNotifyFrom == nil ) {
r .Flags .Set (1 )
}
if !(r .PollVotesNotifyFrom == nil ) {
r .Flags .Set (2 )
}
}
func (r *ReactionsNotifySettings ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionsNotifySettings#71e4ea58 as nil" )
}
b .PutID (ReactionsNotifySettingsTypeID )
return r .EncodeBare (b )
}
func (r *ReactionsNotifySettings ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionsNotifySettings#71e4ea58 as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode reactionsNotifySettings#71e4ea58: field flags: %w" , err )
}
if r .Flags .Has (0 ) {
if r .MessagesNotifyFrom == nil {
return fmt .Errorf ("unable to encode reactionsNotifySettings#71e4ea58: field messages_notify_from is nil" )
}
if err := r .MessagesNotifyFrom .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode reactionsNotifySettings#71e4ea58: field messages_notify_from: %w" , err )
}
}
if r .Flags .Has (1 ) {
if r .StoriesNotifyFrom == nil {
return fmt .Errorf ("unable to encode reactionsNotifySettings#71e4ea58: field stories_notify_from is nil" )
}
if err := r .StoriesNotifyFrom .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode reactionsNotifySettings#71e4ea58: field stories_notify_from: %w" , err )
}
}
if r .Flags .Has (2 ) {
if r .PollVotesNotifyFrom == nil {
return fmt .Errorf ("unable to encode reactionsNotifySettings#71e4ea58: field poll_votes_notify_from is nil" )
}
if err := r .PollVotesNotifyFrom .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode reactionsNotifySettings#71e4ea58: field poll_votes_notify_from: %w" , err )
}
}
if r .Sound == nil {
return fmt .Errorf ("unable to encode reactionsNotifySettings#71e4ea58: field sound is nil" )
}
if err := r .Sound .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode reactionsNotifySettings#71e4ea58: field sound: %w" , err )
}
b .PutBool (r .ShowPreviews )
return nil
}
func (r *ReactionsNotifySettings ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionsNotifySettings#71e4ea58 to nil" )
}
if err := b .ConsumeID (ReactionsNotifySettingsTypeID ); err != nil {
return fmt .Errorf ("unable to decode reactionsNotifySettings#71e4ea58: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ReactionsNotifySettings ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionsNotifySettings#71e4ea58 to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode reactionsNotifySettings#71e4ea58: field flags: %w" , err )
}
}
if r .Flags .Has (0 ) {
value , err := DecodeReactionNotificationsFrom (b )
if err != nil {
return fmt .Errorf ("unable to decode reactionsNotifySettings#71e4ea58: 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#71e4ea58: field stories_notify_from: %w" , err )
}
r .StoriesNotifyFrom = value
}
if r .Flags .Has (2 ) {
value , err := DecodeReactionNotificationsFrom (b )
if err != nil {
return fmt .Errorf ("unable to decode reactionsNotifySettings#71e4ea58: field poll_votes_notify_from: %w" , err )
}
r .PollVotesNotifyFrom = value
}
{
value , err := DecodeNotificationSound (b )
if err != nil {
return fmt .Errorf ("unable to decode reactionsNotifySettings#71e4ea58: field sound: %w" , err )
}
r .Sound = value
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode reactionsNotifySettings#71e4ea58: field show_previews: %w" , err )
}
r .ShowPreviews = value
}
return nil
}
func (r *ReactionsNotifySettings ) SetMessagesNotifyFrom (value ReactionNotificationsFromClass ) {
r .Flags .Set (0 )
r .MessagesNotifyFrom = value
}
func (r *ReactionsNotifySettings ) GetMessagesNotifyFrom () (value ReactionNotificationsFromClass , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (0 ) {
return value , false
}
return r .MessagesNotifyFrom , true
}
func (r *ReactionsNotifySettings ) SetStoriesNotifyFrom (value ReactionNotificationsFromClass ) {
r .Flags .Set (1 )
r .StoriesNotifyFrom = value
}
func (r *ReactionsNotifySettings ) GetStoriesNotifyFrom () (value ReactionNotificationsFromClass , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (1 ) {
return value , false
}
return r .StoriesNotifyFrom , true
}
func (r *ReactionsNotifySettings ) SetPollVotesNotifyFrom (value ReactionNotificationsFromClass ) {
r .Flags .Set (2 )
r .PollVotesNotifyFrom = value
}
func (r *ReactionsNotifySettings ) GetPollVotesNotifyFrom () (value ReactionNotificationsFromClass , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (2 ) {
return value , false
}
return r .PollVotesNotifyFrom , true
}
func (r *ReactionsNotifySettings ) GetSound () (value NotificationSoundClass ) {
if r == nil {
return
}
return r .Sound
}
func (r *ReactionsNotifySettings ) GetShowPreviews () (value bool ) {
if r == nil {
return
}
return r .ShowPreviews
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .