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 NotificationSoundDefault struct {
}
const NotificationSoundDefaultTypeID = 0x97e8bebe
func (n NotificationSoundDefault ) construct () NotificationSoundClass { return &n }
var (
_ bin .Encoder = &NotificationSoundDefault {}
_ bin .Decoder = &NotificationSoundDefault {}
_ bin .BareEncoder = &NotificationSoundDefault {}
_ bin .BareDecoder = &NotificationSoundDefault {}
_ NotificationSoundClass = &NotificationSoundDefault {}
)
func (n *NotificationSoundDefault ) Zero () bool {
if n == nil {
return true
}
return true
}
func (n *NotificationSoundDefault ) String () string {
if n == nil {
return "NotificationSoundDefault(nil)"
}
type Alias NotificationSoundDefault
return fmt .Sprintf ("NotificationSoundDefault%+v" , Alias (*n ))
}
func (*NotificationSoundDefault ) TypeID () uint32 {
return NotificationSoundDefaultTypeID
}
func (*NotificationSoundDefault ) TypeName () string {
return "notificationSoundDefault"
}
func (n *NotificationSoundDefault ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "notificationSoundDefault" ,
ID : NotificationSoundDefaultTypeID ,
}
if n == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (n *NotificationSoundDefault ) Encode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode notificationSoundDefault#97e8bebe as nil" )
}
b .PutID (NotificationSoundDefaultTypeID )
return n .EncodeBare (b )
}
func (n *NotificationSoundDefault ) EncodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode notificationSoundDefault#97e8bebe as nil" )
}
return nil
}
func (n *NotificationSoundDefault ) Decode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode notificationSoundDefault#97e8bebe to nil" )
}
if err := b .ConsumeID (NotificationSoundDefaultTypeID ); err != nil {
return fmt .Errorf ("unable to decode notificationSoundDefault#97e8bebe: %w" , err )
}
return n .DecodeBare (b )
}
func (n *NotificationSoundDefault ) DecodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode notificationSoundDefault#97e8bebe to nil" )
}
return nil
}
type NotificationSoundNone struct {
}
const NotificationSoundNoneTypeID = 0x6f0c34df
func (n NotificationSoundNone ) construct () NotificationSoundClass { return &n }
var (
_ bin .Encoder = &NotificationSoundNone {}
_ bin .Decoder = &NotificationSoundNone {}
_ bin .BareEncoder = &NotificationSoundNone {}
_ bin .BareDecoder = &NotificationSoundNone {}
_ NotificationSoundClass = &NotificationSoundNone {}
)
func (n *NotificationSoundNone ) Zero () bool {
if n == nil {
return true
}
return true
}
func (n *NotificationSoundNone ) String () string {
if n == nil {
return "NotificationSoundNone(nil)"
}
type Alias NotificationSoundNone
return fmt .Sprintf ("NotificationSoundNone%+v" , Alias (*n ))
}
func (*NotificationSoundNone ) TypeID () uint32 {
return NotificationSoundNoneTypeID
}
func (*NotificationSoundNone ) TypeName () string {
return "notificationSoundNone"
}
func (n *NotificationSoundNone ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "notificationSoundNone" ,
ID : NotificationSoundNoneTypeID ,
}
if n == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (n *NotificationSoundNone ) Encode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode notificationSoundNone#6f0c34df as nil" )
}
b .PutID (NotificationSoundNoneTypeID )
return n .EncodeBare (b )
}
func (n *NotificationSoundNone ) EncodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode notificationSoundNone#6f0c34df as nil" )
}
return nil
}
func (n *NotificationSoundNone ) Decode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode notificationSoundNone#6f0c34df to nil" )
}
if err := b .ConsumeID (NotificationSoundNoneTypeID ); err != nil {
return fmt .Errorf ("unable to decode notificationSoundNone#6f0c34df: %w" , err )
}
return n .DecodeBare (b )
}
func (n *NotificationSoundNone ) DecodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode notificationSoundNone#6f0c34df to nil" )
}
return nil
}
type NotificationSoundLocal struct {
Title string
Data string
}
const NotificationSoundLocalTypeID = 0x830b9ae4
func (n NotificationSoundLocal ) construct () NotificationSoundClass { return &n }
var (
_ bin .Encoder = &NotificationSoundLocal {}
_ bin .Decoder = &NotificationSoundLocal {}
_ bin .BareEncoder = &NotificationSoundLocal {}
_ bin .BareDecoder = &NotificationSoundLocal {}
_ NotificationSoundClass = &NotificationSoundLocal {}
)
func (n *NotificationSoundLocal ) Zero () bool {
if n == nil {
return true
}
if !(n .Title == "" ) {
return false
}
if !(n .Data == "" ) {
return false
}
return true
}
func (n *NotificationSoundLocal ) String () string {
if n == nil {
return "NotificationSoundLocal(nil)"
}
type Alias NotificationSoundLocal
return fmt .Sprintf ("NotificationSoundLocal%+v" , Alias (*n ))
}
func (n *NotificationSoundLocal ) FillFrom (from interface {
GetTitle () (value string )
GetData () (value string )
}) {
n .Title = from .GetTitle ()
n .Data = from .GetData ()
}
func (*NotificationSoundLocal ) TypeID () uint32 {
return NotificationSoundLocalTypeID
}
func (*NotificationSoundLocal ) TypeName () string {
return "notificationSoundLocal"
}
func (n *NotificationSoundLocal ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "notificationSoundLocal" ,
ID : NotificationSoundLocalTypeID ,
}
if n == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Data" ,
SchemaName : "data" ,
},
}
return typ
}
func (n *NotificationSoundLocal ) Encode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode notificationSoundLocal#830b9ae4 as nil" )
}
b .PutID (NotificationSoundLocalTypeID )
return n .EncodeBare (b )
}
func (n *NotificationSoundLocal ) EncodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode notificationSoundLocal#830b9ae4 as nil" )
}
b .PutString (n .Title )
b .PutString (n .Data )
return nil
}
func (n *NotificationSoundLocal ) Decode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode notificationSoundLocal#830b9ae4 to nil" )
}
if err := b .ConsumeID (NotificationSoundLocalTypeID ); err != nil {
return fmt .Errorf ("unable to decode notificationSoundLocal#830b9ae4: %w" , err )
}
return n .DecodeBare (b )
}
func (n *NotificationSoundLocal ) DecodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode notificationSoundLocal#830b9ae4 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode notificationSoundLocal#830b9ae4: field title: %w" , err )
}
n .Title = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode notificationSoundLocal#830b9ae4: field data: %w" , err )
}
n .Data = value
}
return nil
}
func (n *NotificationSoundLocal ) GetTitle () (value string ) {
if n == nil {
return
}
return n .Title
}
func (n *NotificationSoundLocal ) GetData () (value string ) {
if n == nil {
return
}
return n .Data
}
type NotificationSoundRingtone struct {
ID int64
}
const NotificationSoundRingtoneTypeID = 0xff6c8049
func (n NotificationSoundRingtone ) construct () NotificationSoundClass { return &n }
var (
_ bin .Encoder = &NotificationSoundRingtone {}
_ bin .Decoder = &NotificationSoundRingtone {}
_ bin .BareEncoder = &NotificationSoundRingtone {}
_ bin .BareDecoder = &NotificationSoundRingtone {}
_ NotificationSoundClass = &NotificationSoundRingtone {}
)
func (n *NotificationSoundRingtone ) Zero () bool {
if n == nil {
return true
}
if !(n .ID == 0 ) {
return false
}
return true
}
func (n *NotificationSoundRingtone ) String () string {
if n == nil {
return "NotificationSoundRingtone(nil)"
}
type Alias NotificationSoundRingtone
return fmt .Sprintf ("NotificationSoundRingtone%+v" , Alias (*n ))
}
func (n *NotificationSoundRingtone ) FillFrom (from interface {
GetID () (value int64 )
}) {
n .ID = from .GetID ()
}
func (*NotificationSoundRingtone ) TypeID () uint32 {
return NotificationSoundRingtoneTypeID
}
func (*NotificationSoundRingtone ) TypeName () string {
return "notificationSoundRingtone"
}
func (n *NotificationSoundRingtone ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "notificationSoundRingtone" ,
ID : NotificationSoundRingtoneTypeID ,
}
if n == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (n *NotificationSoundRingtone ) Encode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode notificationSoundRingtone#ff6c8049 as nil" )
}
b .PutID (NotificationSoundRingtoneTypeID )
return n .EncodeBare (b )
}
func (n *NotificationSoundRingtone ) EncodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode notificationSoundRingtone#ff6c8049 as nil" )
}
b .PutLong (n .ID )
return nil
}
func (n *NotificationSoundRingtone ) Decode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode notificationSoundRingtone#ff6c8049 to nil" )
}
if err := b .ConsumeID (NotificationSoundRingtoneTypeID ); err != nil {
return fmt .Errorf ("unable to decode notificationSoundRingtone#ff6c8049: %w" , err )
}
return n .DecodeBare (b )
}
func (n *NotificationSoundRingtone ) DecodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode notificationSoundRingtone#ff6c8049 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode notificationSoundRingtone#ff6c8049: field id: %w" , err )
}
n .ID = value
}
return nil
}
func (n *NotificationSoundRingtone ) GetID () (value int64 ) {
if n == nil {
return
}
return n .ID
}
const NotificationSoundClassName = "NotificationSound"
type NotificationSoundClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () NotificationSoundClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeNotificationSound (buf *bin .Buffer ) (NotificationSoundClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case NotificationSoundDefaultTypeID :
v := NotificationSoundDefault {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode NotificationSoundClass: %w" , err )
}
return &v , nil
case NotificationSoundNoneTypeID :
v := NotificationSoundNone {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode NotificationSoundClass: %w" , err )
}
return &v , nil
case NotificationSoundLocalTypeID :
v := NotificationSoundLocal {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode NotificationSoundClass: %w" , err )
}
return &v , nil
case NotificationSoundRingtoneTypeID :
v := NotificationSoundRingtone {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode NotificationSoundClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode NotificationSoundClass: %w" , bin .NewUnexpectedID (id ))
}
}
type NotificationSoundBox struct {
NotificationSound NotificationSoundClass
}
func (b *NotificationSoundBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode NotificationSoundBox to nil" )
}
v , err := DecodeNotificationSound (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .NotificationSound = v
return nil
}
func (b *NotificationSoundBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .NotificationSound == nil {
return fmt .Errorf ("unable to encode NotificationSoundClass as nil" )
}
return b .NotificationSound .Encode (buf )
}
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 .