move gotd fork into repo. (#111)
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
This commit is contained in:
@@ -0,0 +1,286 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// InputBusinessAwayMessage represents TL type `inputBusinessAwayMessage#832175e0`.
|
||||
// Describes a Telegram Business away message¹, automatically sent to users writing to
|
||||
// us when we're offline, during closing hours, while we're on vacation, or in some other
|
||||
// custom time period when we cannot immediately answer to the user.
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/api/business#away-messages
|
||||
//
|
||||
// See https://core.telegram.org/constructor/inputBusinessAwayMessage for reference.
|
||||
type InputBusinessAwayMessage struct {
|
||||
// Flags, see TL conditional fields¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
||||
Flags bin.Fields
|
||||
// If set, the messages will not be sent if the account was online in the last 10 minutes.
|
||||
OfflineOnly bool
|
||||
// ID of a quick reply shorcut, containing the away messages to send, see here » for
|
||||
// more info¹.
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/business#quick-reply-shortcuts
|
||||
ShortcutID int
|
||||
// Specifies when should the away messages be sent.
|
||||
Schedule BusinessAwayMessageScheduleClass
|
||||
// Allowed recipients for the away messages.
|
||||
Recipients InputBusinessRecipients
|
||||
}
|
||||
|
||||
// InputBusinessAwayMessageTypeID is TL type id of InputBusinessAwayMessage.
|
||||
const InputBusinessAwayMessageTypeID = 0x832175e0
|
||||
|
||||
// Ensuring interfaces in compile-time for InputBusinessAwayMessage.
|
||||
var (
|
||||
_ bin.Encoder = &InputBusinessAwayMessage{}
|
||||
_ bin.Decoder = &InputBusinessAwayMessage{}
|
||||
_ bin.BareEncoder = &InputBusinessAwayMessage{}
|
||||
_ bin.BareDecoder = &InputBusinessAwayMessage{}
|
||||
)
|
||||
|
||||
func (i *InputBusinessAwayMessage) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
if !(i.Flags.Zero()) {
|
||||
return false
|
||||
}
|
||||
if !(i.OfflineOnly == false) {
|
||||
return false
|
||||
}
|
||||
if !(i.ShortcutID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(i.Schedule == nil) {
|
||||
return false
|
||||
}
|
||||
if !(i.Recipients.Zero()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InputBusinessAwayMessage) String() string {
|
||||
if i == nil {
|
||||
return "InputBusinessAwayMessage(nil)"
|
||||
}
|
||||
type Alias InputBusinessAwayMessage
|
||||
return fmt.Sprintf("InputBusinessAwayMessage%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// FillFrom fills InputBusinessAwayMessage from given interface.
|
||||
func (i *InputBusinessAwayMessage) FillFrom(from interface {
|
||||
GetOfflineOnly() (value bool)
|
||||
GetShortcutID() (value int)
|
||||
GetSchedule() (value BusinessAwayMessageScheduleClass)
|
||||
GetRecipients() (value InputBusinessRecipients)
|
||||
}) {
|
||||
i.OfflineOnly = from.GetOfflineOnly()
|
||||
i.ShortcutID = from.GetShortcutID()
|
||||
i.Schedule = from.GetSchedule()
|
||||
i.Recipients = from.GetRecipients()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InputBusinessAwayMessage) TypeID() uint32 {
|
||||
return InputBusinessAwayMessageTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InputBusinessAwayMessage) TypeName() string {
|
||||
return "inputBusinessAwayMessage"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InputBusinessAwayMessage) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "inputBusinessAwayMessage",
|
||||
ID: InputBusinessAwayMessageTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "OfflineOnly",
|
||||
SchemaName: "offline_only",
|
||||
Null: !i.Flags.Has(0),
|
||||
},
|
||||
{
|
||||
Name: "ShortcutID",
|
||||
SchemaName: "shortcut_id",
|
||||
},
|
||||
{
|
||||
Name: "Schedule",
|
||||
SchemaName: "schedule",
|
||||
},
|
||||
{
|
||||
Name: "Recipients",
|
||||
SchemaName: "recipients",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// SetFlags sets flags for non-zero fields.
|
||||
func (i *InputBusinessAwayMessage) SetFlags() {
|
||||
if !(i.OfflineOnly == false) {
|
||||
i.Flags.Set(0)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InputBusinessAwayMessage) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputBusinessAwayMessage#832175e0 as nil")
|
||||
}
|
||||
b.PutID(InputBusinessAwayMessageTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InputBusinessAwayMessage) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputBusinessAwayMessage#832175e0 as nil")
|
||||
}
|
||||
i.SetFlags()
|
||||
if err := i.Flags.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode inputBusinessAwayMessage#832175e0: field flags: %w", err)
|
||||
}
|
||||
b.PutInt(i.ShortcutID)
|
||||
if i.Schedule == nil {
|
||||
return fmt.Errorf("unable to encode inputBusinessAwayMessage#832175e0: field schedule is nil")
|
||||
}
|
||||
if err := i.Schedule.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode inputBusinessAwayMessage#832175e0: field schedule: %w", err)
|
||||
}
|
||||
if err := i.Recipients.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode inputBusinessAwayMessage#832175e0: field recipients: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InputBusinessAwayMessage) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputBusinessAwayMessage#832175e0 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InputBusinessAwayMessageTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode inputBusinessAwayMessage#832175e0: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InputBusinessAwayMessage) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputBusinessAwayMessage#832175e0 to nil")
|
||||
}
|
||||
{
|
||||
if err := i.Flags.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode inputBusinessAwayMessage#832175e0: field flags: %w", err)
|
||||
}
|
||||
}
|
||||
i.OfflineOnly = i.Flags.Has(0)
|
||||
{
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputBusinessAwayMessage#832175e0: field shortcut_id: %w", err)
|
||||
}
|
||||
i.ShortcutID = value
|
||||
}
|
||||
{
|
||||
value, err := DecodeBusinessAwayMessageSchedule(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputBusinessAwayMessage#832175e0: field schedule: %w", err)
|
||||
}
|
||||
i.Schedule = value
|
||||
}
|
||||
{
|
||||
if err := i.Recipients.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode inputBusinessAwayMessage#832175e0: field recipients: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetOfflineOnly sets value of OfflineOnly conditional field.
|
||||
func (i *InputBusinessAwayMessage) SetOfflineOnly(value bool) {
|
||||
if value {
|
||||
i.Flags.Set(0)
|
||||
i.OfflineOnly = true
|
||||
} else {
|
||||
i.Flags.Unset(0)
|
||||
i.OfflineOnly = false
|
||||
}
|
||||
}
|
||||
|
||||
// GetOfflineOnly returns value of OfflineOnly conditional field.
|
||||
func (i *InputBusinessAwayMessage) GetOfflineOnly() (value bool) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.Flags.Has(0)
|
||||
}
|
||||
|
||||
// GetShortcutID returns value of ShortcutID field.
|
||||
func (i *InputBusinessAwayMessage) GetShortcutID() (value int) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.ShortcutID
|
||||
}
|
||||
|
||||
// GetSchedule returns value of Schedule field.
|
||||
func (i *InputBusinessAwayMessage) GetSchedule() (value BusinessAwayMessageScheduleClass) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.Schedule
|
||||
}
|
||||
|
||||
// GetRecipients returns value of Recipients field.
|
||||
func (i *InputBusinessAwayMessage) GetRecipients() (value InputBusinessRecipients) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.Recipients
|
||||
}
|
||||
Reference in New Issue
Block a user