package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type StoriesReportRequest struct {
Peer InputPeerClass
ID []int
Reason ReportReasonClass
Message string
}
const StoriesReportRequestTypeID = 0x1923fa8c
var (
_ bin .Encoder = &StoriesReportRequest {}
_ bin .Decoder = &StoriesReportRequest {}
_ bin .BareEncoder = &StoriesReportRequest {}
_ bin .BareDecoder = &StoriesReportRequest {}
)
func (r *StoriesReportRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Peer == nil ) {
return false
}
if !(r .ID == nil ) {
return false
}
if !(r .Reason == nil ) {
return false
}
if !(r .Message == "" ) {
return false
}
return true
}
func (r *StoriesReportRequest ) String () string {
if r == nil {
return "StoriesReportRequest(nil)"
}
type Alias StoriesReportRequest
return fmt .Sprintf ("StoriesReportRequest%+v" , Alias (*r ))
}
func (r *StoriesReportRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetID () (value []int )
GetReason () (value ReportReasonClass )
GetMessage () (value string )
}) {
r .Peer = from .GetPeer ()
r .ID = from .GetID ()
r .Reason = from .GetReason ()
r .Message = from .GetMessage ()
}
func (*StoriesReportRequest ) TypeID () uint32 {
return StoriesReportRequestTypeID
}
func (*StoriesReportRequest ) TypeName () string {
return "stories.report"
}
func (r *StoriesReportRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.report" ,
ID : StoriesReportRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Reason" ,
SchemaName : "reason" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
},
}
return typ
}
func (r *StoriesReportRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode stories.report#1923fa8c as nil" )
}
b .PutID (StoriesReportRequestTypeID )
return r .EncodeBare (b )
}
func (r *StoriesReportRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode stories.report#1923fa8c as nil" )
}
if r .Peer == nil {
return fmt .Errorf ("unable to encode stories.report#1923fa8c: field peer is nil" )
}
if err := r .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.report#1923fa8c: field peer: %w" , err )
}
b .PutVectorHeader (len (r .ID ))
for _ , v := range r .ID {
b .PutInt (v )
}
if r .Reason == nil {
return fmt .Errorf ("unable to encode stories.report#1923fa8c: field reason is nil" )
}
if err := r .Reason .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.report#1923fa8c: field reason: %w" , err )
}
b .PutString (r .Message )
return nil
}
func (r *StoriesReportRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode stories.report#1923fa8c to nil" )
}
if err := b .ConsumeID (StoriesReportRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.report#1923fa8c: %w" , err )
}
return r .DecodeBare (b )
}
func (r *StoriesReportRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode stories.report#1923fa8c to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.report#1923fa8c: field peer: %w" , err )
}
r .Peer = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.report#1923fa8c: field id: %w" , err )
}
if headerLen > 0 {
r .ID = make ([]int , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stories.report#1923fa8c: field id: %w" , err )
}
r .ID = append (r .ID , value )
}
}
{
value , err := DecodeReportReason (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.report#1923fa8c: field reason: %w" , err )
}
r .Reason = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stories.report#1923fa8c: field message: %w" , err )
}
r .Message = value
}
return nil
}
func (r *StoriesReportRequest ) GetPeer () (value InputPeerClass ) {
if r == nil {
return
}
return r .Peer
}
func (r *StoriesReportRequest ) GetID () (value []int ) {
if r == nil {
return
}
return r .ID
}
func (r *StoriesReportRequest ) GetReason () (value ReportReasonClass ) {
if r == nil {
return
}
return r .Reason
}
func (r *StoriesReportRequest ) GetMessage () (value string ) {
if r == nil {
return
}
return r .Message
}
func (c *Client ) StoriesReport (ctx context .Context , request *StoriesReportRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , nil
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .