// 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{} ) // BusinessGreetingMessageSettings represents TL type `businessGreetingMessageSettings#64ae3e12`. type BusinessGreetingMessageSettings struct { // Unique quick reply shortcut identifier for the greeting messages ShortcutID int32 // Chosen recipients of the greeting messages Recipients BusinessRecipients // The number of days after which a chat will be considered as inactive; currently, must // be on of 7, 14, 21, or 28 InactivityDays int32 } // BusinessGreetingMessageSettingsTypeID is TL type id of BusinessGreetingMessageSettings. const BusinessGreetingMessageSettingsTypeID = 0x64ae3e12 // Ensuring interfaces in compile-time for BusinessGreetingMessageSettings. var ( _ bin.Encoder = &BusinessGreetingMessageSettings{} _ bin.Decoder = &BusinessGreetingMessageSettings{} _ bin.BareEncoder = &BusinessGreetingMessageSettings{} _ bin.BareDecoder = &BusinessGreetingMessageSettings{} ) func (b *BusinessGreetingMessageSettings) Zero() bool { if b == nil { return true } if !(b.ShortcutID == 0) { return false } if !(b.Recipients.Zero()) { return false } if !(b.InactivityDays == 0) { return false } return true } // String implements fmt.Stringer. func (b *BusinessGreetingMessageSettings) String() string { if b == nil { return "BusinessGreetingMessageSettings(nil)" } type Alias BusinessGreetingMessageSettings return fmt.Sprintf("BusinessGreetingMessageSettings%+v", Alias(*b)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*BusinessGreetingMessageSettings) TypeID() uint32 { return BusinessGreetingMessageSettingsTypeID } // TypeName returns name of type in TL schema. func (*BusinessGreetingMessageSettings) TypeName() string { return "businessGreetingMessageSettings" } // TypeInfo returns info about TL type. func (b *BusinessGreetingMessageSettings) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "businessGreetingMessageSettings", ID: BusinessGreetingMessageSettingsTypeID, } if b == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ShortcutID", SchemaName: "shortcut_id", }, { Name: "Recipients", SchemaName: "recipients", }, { Name: "InactivityDays", SchemaName: "inactivity_days", }, } return typ } // Encode implements bin.Encoder. func (b *BusinessGreetingMessageSettings) Encode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode businessGreetingMessageSettings#64ae3e12 as nil") } buf.PutID(BusinessGreetingMessageSettingsTypeID) return b.EncodeBare(buf) } // EncodeBare implements bin.BareEncoder. func (b *BusinessGreetingMessageSettings) EncodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode businessGreetingMessageSettings#64ae3e12 as nil") } buf.PutInt32(b.ShortcutID) if err := b.Recipients.Encode(buf); err != nil { return fmt.Errorf("unable to encode businessGreetingMessageSettings#64ae3e12: field recipients: %w", err) } buf.PutInt32(b.InactivityDays) return nil } // Decode implements bin.Decoder. func (b *BusinessGreetingMessageSettings) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode businessGreetingMessageSettings#64ae3e12 to nil") } if err := buf.ConsumeID(BusinessGreetingMessageSettingsTypeID); err != nil { return fmt.Errorf("unable to decode businessGreetingMessageSettings#64ae3e12: %w", err) } return b.DecodeBare(buf) } // DecodeBare implements bin.BareDecoder. func (b *BusinessGreetingMessageSettings) DecodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode businessGreetingMessageSettings#64ae3e12 to nil") } { value, err := buf.Int32() if err != nil { return fmt.Errorf("unable to decode businessGreetingMessageSettings#64ae3e12: field shortcut_id: %w", err) } b.ShortcutID = value } { if err := b.Recipients.Decode(buf); err != nil { return fmt.Errorf("unable to decode businessGreetingMessageSettings#64ae3e12: field recipients: %w", err) } } { value, err := buf.Int32() if err != nil { return fmt.Errorf("unable to decode businessGreetingMessageSettings#64ae3e12: field inactivity_days: %w", err) } b.InactivityDays = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (b *BusinessGreetingMessageSettings) EncodeTDLibJSON(buf tdjson.Encoder) error { if b == nil { return fmt.Errorf("can't encode businessGreetingMessageSettings#64ae3e12 as nil") } buf.ObjStart() buf.PutID("businessGreetingMessageSettings") buf.Comma() buf.FieldStart("shortcut_id") buf.PutInt32(b.ShortcutID) buf.Comma() buf.FieldStart("recipients") if err := b.Recipients.EncodeTDLibJSON(buf); err != nil { return fmt.Errorf("unable to encode businessGreetingMessageSettings#64ae3e12: field recipients: %w", err) } buf.Comma() buf.FieldStart("inactivity_days") buf.PutInt32(b.InactivityDays) buf.Comma() buf.StripComma() buf.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (b *BusinessGreetingMessageSettings) DecodeTDLibJSON(buf tdjson.Decoder) error { if b == nil { return fmt.Errorf("can't decode businessGreetingMessageSettings#64ae3e12 to nil") } return buf.Obj(func(buf tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := buf.ConsumeID("businessGreetingMessageSettings"); err != nil { return fmt.Errorf("unable to decode businessGreetingMessageSettings#64ae3e12: %w", err) } case "shortcut_id": value, err := buf.Int32() if err != nil { return fmt.Errorf("unable to decode businessGreetingMessageSettings#64ae3e12: field shortcut_id: %w", err) } b.ShortcutID = value case "recipients": if err := b.Recipients.DecodeTDLibJSON(buf); err != nil { return fmt.Errorf("unable to decode businessGreetingMessageSettings#64ae3e12: field recipients: %w", err) } case "inactivity_days": value, err := buf.Int32() if err != nil { return fmt.Errorf("unable to decode businessGreetingMessageSettings#64ae3e12: field inactivity_days: %w", err) } b.InactivityDays = value default: return buf.Skip() } return nil }) } // GetShortcutID returns value of ShortcutID field. func (b *BusinessGreetingMessageSettings) GetShortcutID() (value int32) { if b == nil { return } return b.ShortcutID } // GetRecipients returns value of Recipients field. func (b *BusinessGreetingMessageSettings) GetRecipients() (value BusinessRecipients) { if b == nil { return } return b.Recipients } // GetInactivityDays returns value of InactivityDays field. func (b *BusinessGreetingMessageSettings) GetInactivityDays() (value int32) { if b == nil { return } return b.InactivityDays }