// 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{} ) // MessageSendOptions represents TL type `messageSendOptions#73e3f43c`. type MessageSendOptions struct { // Unique identifier of the topic in a channel direct messages chat administered by the // current user; pass 0 if the chat isn't a channel direct messages chat administered by // the current user DirectMessagesChatTopicID int64 // Pass true to disable notification for the message DisableNotification bool // Pass true if the message is sent from the background FromBackground bool // Pass true if the content of the message must be protected from forwarding and saving; // for bots only ProtectContent bool // Pass true to allow the message to ignore regular broadcast limits for a small fee; for // bots only AllowPaidBroadcast bool // The number of Telegram Stars the user agreed to pay to send the messages PaidMessageStarCount int64 // Pass true if the user explicitly chosen a sticker or a custom emoji from an installed // sticker set; applicable only to sendMessage and sendMessageAlbum UpdateOrderOfInstalledStickerSets bool // Message scheduling state; pass null to send message immediately. Messages sent to a // secret chat, to a chat with paid messages, to a channel direct messages chat, SchedulingState MessageSchedulingStateClass // Identifier of the effect to apply to the message; pass 0 if none; applicable only to // sendMessage and sendMessageAlbum in private chats EffectID int64 // Non-persistent identifier, which will be returned back in messageSendingStatePending // object and can be used to match sent messages and corresponding updateNewMessage // updates SendingID int32 // Pass true to get a fake message instead of actually sending them OnlyPreview bool } // MessageSendOptionsTypeID is TL type id of MessageSendOptions. const MessageSendOptionsTypeID = 0x73e3f43c // Ensuring interfaces in compile-time for MessageSendOptions. var ( _ bin.Encoder = &MessageSendOptions{} _ bin.Decoder = &MessageSendOptions{} _ bin.BareEncoder = &MessageSendOptions{} _ bin.BareDecoder = &MessageSendOptions{} ) func (m *MessageSendOptions) Zero() bool { if m == nil { return true } if !(m.DirectMessagesChatTopicID == 0) { return false } if !(m.DisableNotification == false) { return false } if !(m.FromBackground == false) { return false } if !(m.ProtectContent == false) { return false } if !(m.AllowPaidBroadcast == false) { return false } if !(m.PaidMessageStarCount == 0) { return false } if !(m.UpdateOrderOfInstalledStickerSets == false) { return false } if !(m.SchedulingState == nil) { return false } if !(m.EffectID == 0) { return false } if !(m.SendingID == 0) { return false } if !(m.OnlyPreview == false) { return false } return true } // String implements fmt.Stringer. func (m *MessageSendOptions) String() string { if m == nil { return "MessageSendOptions(nil)" } type Alias MessageSendOptions return fmt.Sprintf("MessageSendOptions%+v", Alias(*m)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*MessageSendOptions) TypeID() uint32 { return MessageSendOptionsTypeID } // TypeName returns name of type in TL schema. func (*MessageSendOptions) TypeName() string { return "messageSendOptions" } // TypeInfo returns info about TL type. func (m *MessageSendOptions) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "messageSendOptions", ID: MessageSendOptionsTypeID, } if m == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "DirectMessagesChatTopicID", SchemaName: "direct_messages_chat_topic_id", }, { Name: "DisableNotification", SchemaName: "disable_notification", }, { Name: "FromBackground", SchemaName: "from_background", }, { Name: "ProtectContent", SchemaName: "protect_content", }, { Name: "AllowPaidBroadcast", SchemaName: "allow_paid_broadcast", }, { Name: "PaidMessageStarCount", SchemaName: "paid_message_star_count", }, { Name: "UpdateOrderOfInstalledStickerSets", SchemaName: "update_order_of_installed_sticker_sets", }, { Name: "SchedulingState", SchemaName: "scheduling_state", }, { Name: "EffectID", SchemaName: "effect_id", }, { Name: "SendingID", SchemaName: "sending_id", }, { Name: "OnlyPreview", SchemaName: "only_preview", }, } return typ } // Encode implements bin.Encoder. func (m *MessageSendOptions) Encode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageSendOptions#73e3f43c as nil") } b.PutID(MessageSendOptionsTypeID) return m.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (m *MessageSendOptions) EncodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageSendOptions#73e3f43c as nil") } b.PutInt53(m.DirectMessagesChatTopicID) b.PutBool(m.DisableNotification) b.PutBool(m.FromBackground) b.PutBool(m.ProtectContent) b.PutBool(m.AllowPaidBroadcast) b.PutInt53(m.PaidMessageStarCount) b.PutBool(m.UpdateOrderOfInstalledStickerSets) if m.SchedulingState == nil { return fmt.Errorf("unable to encode messageSendOptions#73e3f43c: field scheduling_state is nil") } if err := m.SchedulingState.Encode(b); err != nil { return fmt.Errorf("unable to encode messageSendOptions#73e3f43c: field scheduling_state: %w", err) } b.PutLong(m.EffectID) b.PutInt32(m.SendingID) b.PutBool(m.OnlyPreview) return nil } // Decode implements bin.Decoder. func (m *MessageSendOptions) Decode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageSendOptions#73e3f43c to nil") } if err := b.ConsumeID(MessageSendOptionsTypeID); err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: %w", err) } return m.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (m *MessageSendOptions) DecodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageSendOptions#73e3f43c to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field direct_messages_chat_topic_id: %w", err) } m.DirectMessagesChatTopicID = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field disable_notification: %w", err) } m.DisableNotification = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field from_background: %w", err) } m.FromBackground = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field protect_content: %w", err) } m.ProtectContent = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field allow_paid_broadcast: %w", err) } m.AllowPaidBroadcast = value } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field paid_message_star_count: %w", err) } m.PaidMessageStarCount = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field update_order_of_installed_sticker_sets: %w", err) } m.UpdateOrderOfInstalledStickerSets = value } { value, err := DecodeMessageSchedulingState(b) if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field scheduling_state: %w", err) } m.SchedulingState = value } { value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field effect_id: %w", err) } m.EffectID = value } { value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field sending_id: %w", err) } m.SendingID = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field only_preview: %w", err) } m.OnlyPreview = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (m *MessageSendOptions) EncodeTDLibJSON(b tdjson.Encoder) error { if m == nil { return fmt.Errorf("can't encode messageSendOptions#73e3f43c as nil") } b.ObjStart() b.PutID("messageSendOptions") b.Comma() b.FieldStart("direct_messages_chat_topic_id") b.PutInt53(m.DirectMessagesChatTopicID) b.Comma() b.FieldStart("disable_notification") b.PutBool(m.DisableNotification) b.Comma() b.FieldStart("from_background") b.PutBool(m.FromBackground) b.Comma() b.FieldStart("protect_content") b.PutBool(m.ProtectContent) b.Comma() b.FieldStart("allow_paid_broadcast") b.PutBool(m.AllowPaidBroadcast) b.Comma() b.FieldStart("paid_message_star_count") b.PutInt53(m.PaidMessageStarCount) b.Comma() b.FieldStart("update_order_of_installed_sticker_sets") b.PutBool(m.UpdateOrderOfInstalledStickerSets) b.Comma() b.FieldStart("scheduling_state") if m.SchedulingState == nil { return fmt.Errorf("unable to encode messageSendOptions#73e3f43c: field scheduling_state is nil") } if err := m.SchedulingState.EncodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to encode messageSendOptions#73e3f43c: field scheduling_state: %w", err) } b.Comma() b.FieldStart("effect_id") b.PutLong(m.EffectID) b.Comma() b.FieldStart("sending_id") b.PutInt32(m.SendingID) b.Comma() b.FieldStart("only_preview") b.PutBool(m.OnlyPreview) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (m *MessageSendOptions) DecodeTDLibJSON(b tdjson.Decoder) error { if m == nil { return fmt.Errorf("can't decode messageSendOptions#73e3f43c to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("messageSendOptions"); err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: %w", err) } case "direct_messages_chat_topic_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field direct_messages_chat_topic_id: %w", err) } m.DirectMessagesChatTopicID = value case "disable_notification": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field disable_notification: %w", err) } m.DisableNotification = value case "from_background": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field from_background: %w", err) } m.FromBackground = value case "protect_content": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field protect_content: %w", err) } m.ProtectContent = value case "allow_paid_broadcast": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field allow_paid_broadcast: %w", err) } m.AllowPaidBroadcast = value case "paid_message_star_count": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field paid_message_star_count: %w", err) } m.PaidMessageStarCount = value case "update_order_of_installed_sticker_sets": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field update_order_of_installed_sticker_sets: %w", err) } m.UpdateOrderOfInstalledStickerSets = value case "scheduling_state": value, err := DecodeTDLibJSONMessageSchedulingState(b) if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field scheduling_state: %w", err) } m.SchedulingState = value case "effect_id": value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field effect_id: %w", err) } m.EffectID = value case "sending_id": value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field sending_id: %w", err) } m.SendingID = value case "only_preview": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode messageSendOptions#73e3f43c: field only_preview: %w", err) } m.OnlyPreview = value default: return b.Skip() } return nil }) } // GetDirectMessagesChatTopicID returns value of DirectMessagesChatTopicID field. func (m *MessageSendOptions) GetDirectMessagesChatTopicID() (value int64) { if m == nil { return } return m.DirectMessagesChatTopicID } // GetDisableNotification returns value of DisableNotification field. func (m *MessageSendOptions) GetDisableNotification() (value bool) { if m == nil { return } return m.DisableNotification } // GetFromBackground returns value of FromBackground field. func (m *MessageSendOptions) GetFromBackground() (value bool) { if m == nil { return } return m.FromBackground } // GetProtectContent returns value of ProtectContent field. func (m *MessageSendOptions) GetProtectContent() (value bool) { if m == nil { return } return m.ProtectContent } // GetAllowPaidBroadcast returns value of AllowPaidBroadcast field. func (m *MessageSendOptions) GetAllowPaidBroadcast() (value bool) { if m == nil { return } return m.AllowPaidBroadcast } // GetPaidMessageStarCount returns value of PaidMessageStarCount field. func (m *MessageSendOptions) GetPaidMessageStarCount() (value int64) { if m == nil { return } return m.PaidMessageStarCount } // GetUpdateOrderOfInstalledStickerSets returns value of UpdateOrderOfInstalledStickerSets field. func (m *MessageSendOptions) GetUpdateOrderOfInstalledStickerSets() (value bool) { if m == nil { return } return m.UpdateOrderOfInstalledStickerSets } // GetSchedulingState returns value of SchedulingState field. func (m *MessageSendOptions) GetSchedulingState() (value MessageSchedulingStateClass) { if m == nil { return } return m.SchedulingState } // GetEffectID returns value of EffectID field. func (m *MessageSendOptions) GetEffectID() (value int64) { if m == nil { return } return m.EffectID } // GetSendingID returns value of SendingID field. func (m *MessageSendOptions) GetSendingID() (value int32) { if m == nil { return } return m.SendingID } // GetOnlyPreview returns value of OnlyPreview field. func (m *MessageSendOptions) GetOnlyPreview() (value bool) { if m == nil { return } return m.OnlyPreview }