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

306 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{}
)
// ReportStoryRequest represents TL type `reportStory#6cacaf34`.
type ReportStoryRequest struct {
// The identifier of the poster of the story to report
StoryPosterChatID int64
// The identifier of the story to report
StoryID int32
// Option identifier chosen by the user; leave empty for the initial request
OptionID []byte
// Additional report details; 0-1024 characters; leave empty for the initial request
Text string
}
// ReportStoryRequestTypeID is TL type id of ReportStoryRequest.
const ReportStoryRequestTypeID = 0x6cacaf34
// Ensuring interfaces in compile-time for ReportStoryRequest.
var (
_ bin.Encoder = &ReportStoryRequest{}
_ bin.Decoder = &ReportStoryRequest{}
_ bin.BareEncoder = &ReportStoryRequest{}
_ bin.BareDecoder = &ReportStoryRequest{}
)
func (r *ReportStoryRequest) Zero() bool {
if r == nil {
return true
}
if !(r.StoryPosterChatID == 0) {
return false
}
if !(r.StoryID == 0) {
return false
}
if !(r.OptionID == nil) {
return false
}
if !(r.Text == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (r *ReportStoryRequest) String() string {
if r == nil {
return "ReportStoryRequest(nil)"
}
type Alias ReportStoryRequest
return fmt.Sprintf("ReportStoryRequest%+v", Alias(*r))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ReportStoryRequest) TypeID() uint32 {
return ReportStoryRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*ReportStoryRequest) TypeName() string {
return "reportStory"
}
// TypeInfo returns info about TL type.
func (r *ReportStoryRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "reportStory",
ID: ReportStoryRequestTypeID,
}
if r == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "StoryPosterChatID",
SchemaName: "story_poster_chat_id",
},
{
Name: "StoryID",
SchemaName: "story_id",
},
{
Name: "OptionID",
SchemaName: "option_id",
},
{
Name: "Text",
SchemaName: "text",
},
}
return typ
}
// Encode implements bin.Encoder.
func (r *ReportStoryRequest) Encode(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't encode reportStory#6cacaf34 as nil")
}
b.PutID(ReportStoryRequestTypeID)
return r.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (r *ReportStoryRequest) EncodeBare(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't encode reportStory#6cacaf34 as nil")
}
b.PutInt53(r.StoryPosterChatID)
b.PutInt32(r.StoryID)
b.PutBytes(r.OptionID)
b.PutString(r.Text)
return nil
}
// Decode implements bin.Decoder.
func (r *ReportStoryRequest) Decode(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't decode reportStory#6cacaf34 to nil")
}
if err := b.ConsumeID(ReportStoryRequestTypeID); err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: %w", err)
}
return r.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (r *ReportStoryRequest) DecodeBare(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't decode reportStory#6cacaf34 to nil")
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: field story_poster_chat_id: %w", err)
}
r.StoryPosterChatID = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: field story_id: %w", err)
}
r.StoryID = value
}
{
value, err := b.Bytes()
if err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: field option_id: %w", err)
}
r.OptionID = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: field text: %w", err)
}
r.Text = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (r *ReportStoryRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if r == nil {
return fmt.Errorf("can't encode reportStory#6cacaf34 as nil")
}
b.ObjStart()
b.PutID("reportStory")
b.Comma()
b.FieldStart("story_poster_chat_id")
b.PutInt53(r.StoryPosterChatID)
b.Comma()
b.FieldStart("story_id")
b.PutInt32(r.StoryID)
b.Comma()
b.FieldStart("option_id")
b.PutBytes(r.OptionID)
b.Comma()
b.FieldStart("text")
b.PutString(r.Text)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (r *ReportStoryRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if r == nil {
return fmt.Errorf("can't decode reportStory#6cacaf34 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("reportStory"); err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: %w", err)
}
case "story_poster_chat_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: field story_poster_chat_id: %w", err)
}
r.StoryPosterChatID = value
case "story_id":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: field story_id: %w", err)
}
r.StoryID = value
case "option_id":
value, err := b.Bytes()
if err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: field option_id: %w", err)
}
r.OptionID = value
case "text":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode reportStory#6cacaf34: field text: %w", err)
}
r.Text = value
default:
return b.Skip()
}
return nil
})
}
// GetStoryPosterChatID returns value of StoryPosterChatID field.
func (r *ReportStoryRequest) GetStoryPosterChatID() (value int64) {
if r == nil {
return
}
return r.StoryPosterChatID
}
// GetStoryID returns value of StoryID field.
func (r *ReportStoryRequest) GetStoryID() (value int32) {
if r == nil {
return
}
return r.StoryID
}
// GetOptionID returns value of OptionID field.
func (r *ReportStoryRequest) GetOptionID() (value []byte) {
if r == nil {
return
}
return r.OptionID
}
// GetText returns value of Text field.
func (r *ReportStoryRequest) GetText() (value string) {
if r == nil {
return
}
return r.Text
}
// ReportStory invokes method reportStory#6cacaf34 returning error if any.
func (c *Client) ReportStory(ctx context.Context, request *ReportStoryRequest) (ReportStoryResultClass, error) {
var result ReportStoryResultBox
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return result.ReportStoryResult, nil
}