250 lines
5.7 KiB
Go
Generated
250 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{}
|
|
)
|
|
|
|
// PendingSuggestion represents TL type `pendingSuggestion#e7e82e12`.
|
|
// Represents a custom pending suggestion »¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/config#custom-suggestions
|
|
//
|
|
// See https://core.telegram.org/constructor/pendingSuggestion for reference.
|
|
type PendingSuggestion struct {
|
|
// The suggestion ID, can be passed to help.dismissSuggestion¹.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/method/help.dismissSuggestion
|
|
Suggestion string
|
|
// Title of the suggestion.
|
|
Title TextWithEntities
|
|
// Body of the suggestion.
|
|
Description TextWithEntities
|
|
// URL to open when the user clicks on the suggestion.
|
|
URL string
|
|
}
|
|
|
|
// PendingSuggestionTypeID is TL type id of PendingSuggestion.
|
|
const PendingSuggestionTypeID = 0xe7e82e12
|
|
|
|
// Ensuring interfaces in compile-time for PendingSuggestion.
|
|
var (
|
|
_ bin.Encoder = &PendingSuggestion{}
|
|
_ bin.Decoder = &PendingSuggestion{}
|
|
_ bin.BareEncoder = &PendingSuggestion{}
|
|
_ bin.BareDecoder = &PendingSuggestion{}
|
|
)
|
|
|
|
func (p *PendingSuggestion) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Suggestion == "") {
|
|
return false
|
|
}
|
|
if !(p.Title.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.Description.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.URL == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PendingSuggestion) String() string {
|
|
if p == nil {
|
|
return "PendingSuggestion(nil)"
|
|
}
|
|
type Alias PendingSuggestion
|
|
return fmt.Sprintf("PendingSuggestion%+v", Alias(*p))
|
|
}
|
|
|
|
// FillFrom fills PendingSuggestion from given interface.
|
|
func (p *PendingSuggestion) FillFrom(from interface {
|
|
GetSuggestion() (value string)
|
|
GetTitle() (value TextWithEntities)
|
|
GetDescription() (value TextWithEntities)
|
|
GetURL() (value string)
|
|
}) {
|
|
p.Suggestion = from.GetSuggestion()
|
|
p.Title = from.GetTitle()
|
|
p.Description = from.GetDescription()
|
|
p.URL = from.GetURL()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PendingSuggestion) TypeID() uint32 {
|
|
return PendingSuggestionTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PendingSuggestion) TypeName() string {
|
|
return "pendingSuggestion"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PendingSuggestion) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pendingSuggestion",
|
|
ID: PendingSuggestionTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Suggestion",
|
|
SchemaName: "suggestion",
|
|
},
|
|
{
|
|
Name: "Title",
|
|
SchemaName: "title",
|
|
},
|
|
{
|
|
Name: "Description",
|
|
SchemaName: "description",
|
|
},
|
|
{
|
|
Name: "URL",
|
|
SchemaName: "url",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PendingSuggestion) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pendingSuggestion#e7e82e12 as nil")
|
|
}
|
|
b.PutID(PendingSuggestionTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PendingSuggestion) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pendingSuggestion#e7e82e12 as nil")
|
|
}
|
|
b.PutString(p.Suggestion)
|
|
if err := p.Title.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pendingSuggestion#e7e82e12: field title: %w", err)
|
|
}
|
|
if err := p.Description.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pendingSuggestion#e7e82e12: field description: %w", err)
|
|
}
|
|
b.PutString(p.URL)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PendingSuggestion) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pendingSuggestion#e7e82e12 to nil")
|
|
}
|
|
if err := b.ConsumeID(PendingSuggestionTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pendingSuggestion#e7e82e12: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PendingSuggestion) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pendingSuggestion#e7e82e12 to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pendingSuggestion#e7e82e12: field suggestion: %w", err)
|
|
}
|
|
p.Suggestion = value
|
|
}
|
|
{
|
|
if err := p.Title.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pendingSuggestion#e7e82e12: field title: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := p.Description.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pendingSuggestion#e7e82e12: field description: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pendingSuggestion#e7e82e12: field url: %w", err)
|
|
}
|
|
p.URL = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetSuggestion returns value of Suggestion field.
|
|
func (p *PendingSuggestion) GetSuggestion() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Suggestion
|
|
}
|
|
|
|
// GetTitle returns value of Title field.
|
|
func (p *PendingSuggestion) GetTitle() (value TextWithEntities) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Title
|
|
}
|
|
|
|
// GetDescription returns value of Description field.
|
|
func (p *PendingSuggestion) GetDescription() (value TextWithEntities) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Description
|
|
}
|
|
|
|
// GetURL returns value of URL field.
|
|
func (p *PendingSuggestion) GetURL() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.URL
|
|
}
|