Files
mautrix-telegram/pkg/gotd/tg/tl_business_greeting_message_gen.go
T
2025-06-27 20:03:37 -07:00

226 lines
5.7 KiB
Go
Generated

// Code generated by gotdgen, DO NOT EDIT.
package tg
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{}
)
// BusinessGreetingMessage represents TL type `businessGreetingMessage#e519abab`.
// Describes a Telegram Business greeting¹, automatically sent to new users writing to
// us in private for the first time, or after a certain inactivity period.
//
// Links:
// 1. https://core.telegram.org/api/business#greeting-messages
//
// See https://core.telegram.org/constructor/businessGreetingMessage for reference.
type BusinessGreetingMessage struct {
// ID of a quick reply shorcut, containing the greeting messages to send, see here » for
// more info¹.
//
// Links:
// 1) https://core.telegram.org/api/business#quick-reply-shortcuts
ShortcutID int
// Allowed recipients for the greeting messages.
Recipients BusinessRecipients
// The number of days after which a private chat will be considered as inactive;
// currently, must be one of 7, 14, 21, or 28.
NoActivityDays int
}
// BusinessGreetingMessageTypeID is TL type id of BusinessGreetingMessage.
const BusinessGreetingMessageTypeID = 0xe519abab
// Ensuring interfaces in compile-time for BusinessGreetingMessage.
var (
_ bin.Encoder = &BusinessGreetingMessage{}
_ bin.Decoder = &BusinessGreetingMessage{}
_ bin.BareEncoder = &BusinessGreetingMessage{}
_ bin.BareDecoder = &BusinessGreetingMessage{}
)
func (b *BusinessGreetingMessage) Zero() bool {
if b == nil {
return true
}
if !(b.ShortcutID == 0) {
return false
}
if !(b.Recipients.Zero()) {
return false
}
if !(b.NoActivityDays == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (b *BusinessGreetingMessage) String() string {
if b == nil {
return "BusinessGreetingMessage(nil)"
}
type Alias BusinessGreetingMessage
return fmt.Sprintf("BusinessGreetingMessage%+v", Alias(*b))
}
// FillFrom fills BusinessGreetingMessage from given interface.
func (b *BusinessGreetingMessage) FillFrom(from interface {
GetShortcutID() (value int)
GetRecipients() (value BusinessRecipients)
GetNoActivityDays() (value int)
}) {
b.ShortcutID = from.GetShortcutID()
b.Recipients = from.GetRecipients()
b.NoActivityDays = from.GetNoActivityDays()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BusinessGreetingMessage) TypeID() uint32 {
return BusinessGreetingMessageTypeID
}
// TypeName returns name of type in TL schema.
func (*BusinessGreetingMessage) TypeName() string {
return "businessGreetingMessage"
}
// TypeInfo returns info about TL type.
func (b *BusinessGreetingMessage) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "businessGreetingMessage",
ID: BusinessGreetingMessageTypeID,
}
if b == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ShortcutID",
SchemaName: "shortcut_id",
},
{
Name: "Recipients",
SchemaName: "recipients",
},
{
Name: "NoActivityDays",
SchemaName: "no_activity_days",
},
}
return typ
}
// Encode implements bin.Encoder.
func (b *BusinessGreetingMessage) Encode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode businessGreetingMessage#e519abab as nil")
}
buf.PutID(BusinessGreetingMessageTypeID)
return b.EncodeBare(buf)
}
// EncodeBare implements bin.BareEncoder.
func (b *BusinessGreetingMessage) EncodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode businessGreetingMessage#e519abab as nil")
}
buf.PutInt(b.ShortcutID)
if err := b.Recipients.Encode(buf); err != nil {
return fmt.Errorf("unable to encode businessGreetingMessage#e519abab: field recipients: %w", err)
}
buf.PutInt(b.NoActivityDays)
return nil
}
// Decode implements bin.Decoder.
func (b *BusinessGreetingMessage) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode businessGreetingMessage#e519abab to nil")
}
if err := buf.ConsumeID(BusinessGreetingMessageTypeID); err != nil {
return fmt.Errorf("unable to decode businessGreetingMessage#e519abab: %w", err)
}
return b.DecodeBare(buf)
}
// DecodeBare implements bin.BareDecoder.
func (b *BusinessGreetingMessage) DecodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode businessGreetingMessage#e519abab to nil")
}
{
value, err := buf.Int()
if err != nil {
return fmt.Errorf("unable to decode businessGreetingMessage#e519abab: field shortcut_id: %w", err)
}
b.ShortcutID = value
}
{
if err := b.Recipients.Decode(buf); err != nil {
return fmt.Errorf("unable to decode businessGreetingMessage#e519abab: field recipients: %w", err)
}
}
{
value, err := buf.Int()
if err != nil {
return fmt.Errorf("unable to decode businessGreetingMessage#e519abab: field no_activity_days: %w", err)
}
b.NoActivityDays = value
}
return nil
}
// GetShortcutID returns value of ShortcutID field.
func (b *BusinessGreetingMessage) GetShortcutID() (value int) {
if b == nil {
return
}
return b.ShortcutID
}
// GetRecipients returns value of Recipients field.
func (b *BusinessGreetingMessage) GetRecipients() (value BusinessRecipients) {
if b == nil {
return
}
return b.Recipients
}
// GetNoActivityDays returns value of NoActivityDays field.
func (b *BusinessGreetingMessage) GetNoActivityDays() (value int) {
if b == nil {
return
}
return b.NoActivityDays
}