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

273 lines
7.0 KiB
Go

// 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{}
)
// SetChatDraftMessageRequest represents TL type `setChatDraftMessage#645e1f1a`.
type SetChatDraftMessageRequest struct {
// Chat identifier
ChatID int64
// If not 0, the message thread identifier in which the draft was changed
MessageThreadID int64
// New draft message; pass null to remove the draft. All files in draft message content
// must be of the type inputFileLocal. Media thumbnails and captions are ignored
DraftMessage DraftMessage
}
// SetChatDraftMessageRequestTypeID is TL type id of SetChatDraftMessageRequest.
const SetChatDraftMessageRequestTypeID = 0x645e1f1a
// Ensuring interfaces in compile-time for SetChatDraftMessageRequest.
var (
_ bin.Encoder = &SetChatDraftMessageRequest{}
_ bin.Decoder = &SetChatDraftMessageRequest{}
_ bin.BareEncoder = &SetChatDraftMessageRequest{}
_ bin.BareDecoder = &SetChatDraftMessageRequest{}
)
func (s *SetChatDraftMessageRequest) Zero() bool {
if s == nil {
return true
}
if !(s.ChatID == 0) {
return false
}
if !(s.MessageThreadID == 0) {
return false
}
if !(s.DraftMessage.Zero()) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *SetChatDraftMessageRequest) String() string {
if s == nil {
return "SetChatDraftMessageRequest(nil)"
}
type Alias SetChatDraftMessageRequest
return fmt.Sprintf("SetChatDraftMessageRequest%+v", Alias(*s))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*SetChatDraftMessageRequest) TypeID() uint32 {
return SetChatDraftMessageRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*SetChatDraftMessageRequest) TypeName() string {
return "setChatDraftMessage"
}
// TypeInfo returns info about TL type.
func (s *SetChatDraftMessageRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "setChatDraftMessage",
ID: SetChatDraftMessageRequestTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ChatID",
SchemaName: "chat_id",
},
{
Name: "MessageThreadID",
SchemaName: "message_thread_id",
},
{
Name: "DraftMessage",
SchemaName: "draft_message",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *SetChatDraftMessageRequest) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode setChatDraftMessage#645e1f1a as nil")
}
b.PutID(SetChatDraftMessageRequestTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *SetChatDraftMessageRequest) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode setChatDraftMessage#645e1f1a as nil")
}
b.PutInt53(s.ChatID)
b.PutInt53(s.MessageThreadID)
if err := s.DraftMessage.Encode(b); err != nil {
return fmt.Errorf("unable to encode setChatDraftMessage#645e1f1a: field draft_message: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (s *SetChatDraftMessageRequest) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode setChatDraftMessage#645e1f1a to nil")
}
if err := b.ConsumeID(SetChatDraftMessageRequestTypeID); err != nil {
return fmt.Errorf("unable to decode setChatDraftMessage#645e1f1a: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *SetChatDraftMessageRequest) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode setChatDraftMessage#645e1f1a to nil")
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode setChatDraftMessage#645e1f1a: field chat_id: %w", err)
}
s.ChatID = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode setChatDraftMessage#645e1f1a: field message_thread_id: %w", err)
}
s.MessageThreadID = value
}
{
if err := s.DraftMessage.Decode(b); err != nil {
return fmt.Errorf("unable to decode setChatDraftMessage#645e1f1a: field draft_message: %w", err)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SetChatDraftMessageRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if s == nil {
return fmt.Errorf("can't encode setChatDraftMessage#645e1f1a as nil")
}
b.ObjStart()
b.PutID("setChatDraftMessage")
b.Comma()
b.FieldStart("chat_id")
b.PutInt53(s.ChatID)
b.Comma()
b.FieldStart("message_thread_id")
b.PutInt53(s.MessageThreadID)
b.Comma()
b.FieldStart("draft_message")
if err := s.DraftMessage.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode setChatDraftMessage#645e1f1a: field draft_message: %w", err)
}
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SetChatDraftMessageRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if s == nil {
return fmt.Errorf("can't decode setChatDraftMessage#645e1f1a to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("setChatDraftMessage"); err != nil {
return fmt.Errorf("unable to decode setChatDraftMessage#645e1f1a: %w", err)
}
case "chat_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode setChatDraftMessage#645e1f1a: field chat_id: %w", err)
}
s.ChatID = value
case "message_thread_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode setChatDraftMessage#645e1f1a: field message_thread_id: %w", err)
}
s.MessageThreadID = value
case "draft_message":
if err := s.DraftMessage.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode setChatDraftMessage#645e1f1a: field draft_message: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// GetChatID returns value of ChatID field.
func (s *SetChatDraftMessageRequest) GetChatID() (value int64) {
if s == nil {
return
}
return s.ChatID
}
// GetMessageThreadID returns value of MessageThreadID field.
func (s *SetChatDraftMessageRequest) GetMessageThreadID() (value int64) {
if s == nil {
return
}
return s.MessageThreadID
}
// GetDraftMessage returns value of DraftMessage field.
func (s *SetChatDraftMessageRequest) GetDraftMessage() (value DraftMessage) {
if s == nil {
return
}
return s.DraftMessage
}
// SetChatDraftMessage invokes method setChatDraftMessage#645e1f1a returning error if any.
func (c *Client) SetChatDraftMessage(ctx context.Context, request *SetChatDraftMessageRequest) error {
var ok Ok
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
return err
}
return nil
}