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 MessagesReportRequest struct {
Peer InputPeerClass
ID []int
Reason ReportReasonClass
Message string
}
const MessagesReportRequestTypeID = 0x8953ab4e
var (
_ bin .Encoder = &MessagesReportRequest {}
_ bin .Decoder = &MessagesReportRequest {}
_ bin .BareEncoder = &MessagesReportRequest {}
_ bin .BareDecoder = &MessagesReportRequest {}
)
func (r *MessagesReportRequest ) 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 *MessagesReportRequest ) String () string {
if r == nil {
return "MessagesReportRequest(nil)"
}
type Alias MessagesReportRequest
return fmt .Sprintf ("MessagesReportRequest%+v" , Alias (*r ))
}
func (r *MessagesReportRequest ) 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 (*MessagesReportRequest ) TypeID () uint32 {
return MessagesReportRequestTypeID
}
func (*MessagesReportRequest ) TypeName () string {
return "messages.report"
}
func (r *MessagesReportRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.report" ,
ID : MessagesReportRequestTypeID ,
}
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 *MessagesReportRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode messages.report#8953ab4e as nil" )
}
b .PutID (MessagesReportRequestTypeID )
return r .EncodeBare (b )
}
func (r *MessagesReportRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode messages.report#8953ab4e as nil" )
}
if r .Peer == nil {
return fmt .Errorf ("unable to encode messages.report#8953ab4e: field peer is nil" )
}
if err := r .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.report#8953ab4e: 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 messages.report#8953ab4e: field reason is nil" )
}
if err := r .Reason .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.report#8953ab4e: field reason: %w" , err )
}
b .PutString (r .Message )
return nil
}
func (r *MessagesReportRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode messages.report#8953ab4e to nil" )
}
if err := b .ConsumeID (MessagesReportRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.report#8953ab4e: %w" , err )
}
return r .DecodeBare (b )
}
func (r *MessagesReportRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode messages.report#8953ab4e to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.report#8953ab4e: field peer: %w" , err )
}
r .Peer = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.report#8953ab4e: 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 messages.report#8953ab4e: field id: %w" , err )
}
r .ID = append (r .ID , value )
}
}
{
value , err := DecodeReportReason (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.report#8953ab4e: field reason: %w" , err )
}
r .Reason = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.report#8953ab4e: field message: %w" , err )
}
r .Message = value
}
return nil
}
func (r *MessagesReportRequest ) GetPeer () (value InputPeerClass ) {
if r == nil {
return
}
return r .Peer
}
func (r *MessagesReportRequest ) GetID () (value []int ) {
if r == nil {
return
}
return r .ID
}
func (r *MessagesReportRequest ) GetReason () (value ReportReasonClass ) {
if r == nil {
return
}
return r .Reason
}
func (r *MessagesReportRequest ) GetMessage () (value string ) {
if r == nil {
return
}
return r .Message
}
func (c *Client ) MessagesReport (ctx context .Context , request *MessagesReportRequest ) (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 .