// 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{} ) // SentWebAppMessage represents TL type `sentWebAppMessage#4a24eec0`. type SentWebAppMessage struct { // Identifier of the sent inline message, if known InlineMessageID string } // SentWebAppMessageTypeID is TL type id of SentWebAppMessage. const SentWebAppMessageTypeID = 0x4a24eec0 // Ensuring interfaces in compile-time for SentWebAppMessage. var ( _ bin.Encoder = &SentWebAppMessage{} _ bin.Decoder = &SentWebAppMessage{} _ bin.BareEncoder = &SentWebAppMessage{} _ bin.BareDecoder = &SentWebAppMessage{} ) func (s *SentWebAppMessage) Zero() bool { if s == nil { return true } if !(s.InlineMessageID == "") { return false } return true } // String implements fmt.Stringer. func (s *SentWebAppMessage) String() string { if s == nil { return "SentWebAppMessage(nil)" } type Alias SentWebAppMessage return fmt.Sprintf("SentWebAppMessage%+v", Alias(*s)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*SentWebAppMessage) TypeID() uint32 { return SentWebAppMessageTypeID } // TypeName returns name of type in TL schema. func (*SentWebAppMessage) TypeName() string { return "sentWebAppMessage" } // TypeInfo returns info about TL type. func (s *SentWebAppMessage) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "sentWebAppMessage", ID: SentWebAppMessageTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "InlineMessageID", SchemaName: "inline_message_id", }, } return typ } // Encode implements bin.Encoder. func (s *SentWebAppMessage) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode sentWebAppMessage#4a24eec0 as nil") } b.PutID(SentWebAppMessageTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *SentWebAppMessage) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode sentWebAppMessage#4a24eec0 as nil") } b.PutString(s.InlineMessageID) return nil } // Decode implements bin.Decoder. func (s *SentWebAppMessage) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode sentWebAppMessage#4a24eec0 to nil") } if err := b.ConsumeID(SentWebAppMessageTypeID); err != nil { return fmt.Errorf("unable to decode sentWebAppMessage#4a24eec0: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *SentWebAppMessage) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode sentWebAppMessage#4a24eec0 to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode sentWebAppMessage#4a24eec0: field inline_message_id: %w", err) } s.InlineMessageID = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *SentWebAppMessage) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { return fmt.Errorf("can't encode sentWebAppMessage#4a24eec0 as nil") } b.ObjStart() b.PutID("sentWebAppMessage") b.Comma() b.FieldStart("inline_message_id") b.PutString(s.InlineMessageID) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *SentWebAppMessage) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { return fmt.Errorf("can't decode sentWebAppMessage#4a24eec0 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("sentWebAppMessage"); err != nil { return fmt.Errorf("unable to decode sentWebAppMessage#4a24eec0: %w", err) } case "inline_message_id": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode sentWebAppMessage#4a24eec0: field inline_message_id: %w", err) } s.InlineMessageID = value default: return b.Skip() } return nil }) } // GetInlineMessageID returns value of InlineMessageID field. func (s *SentWebAppMessage) GetInlineMessageID() (value string) { if s == nil { return } return s.InlineMessageID }