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 AccountReportPeerRequest struct {
Peer InputPeerClass
Reason ReportReasonClass
Message string
}
const AccountReportPeerRequestTypeID = 0xc5ba3d86
var (
_ bin .Encoder = &AccountReportPeerRequest {}
_ bin .Decoder = &AccountReportPeerRequest {}
_ bin .BareEncoder = &AccountReportPeerRequest {}
_ bin .BareDecoder = &AccountReportPeerRequest {}
)
func (r *AccountReportPeerRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Peer == nil ) {
return false
}
if !(r .Reason == nil ) {
return false
}
if !(r .Message == "" ) {
return false
}
return true
}
func (r *AccountReportPeerRequest ) String () string {
if r == nil {
return "AccountReportPeerRequest(nil)"
}
type Alias AccountReportPeerRequest
return fmt .Sprintf ("AccountReportPeerRequest%+v" , Alias (*r ))
}
func (r *AccountReportPeerRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetReason () (value ReportReasonClass )
GetMessage () (value string )
}) {
r .Peer = from .GetPeer ()
r .Reason = from .GetReason ()
r .Message = from .GetMessage ()
}
func (*AccountReportPeerRequest ) TypeID () uint32 {
return AccountReportPeerRequestTypeID
}
func (*AccountReportPeerRequest ) TypeName () string {
return "account.reportPeer"
}
func (r *AccountReportPeerRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.reportPeer" ,
ID : AccountReportPeerRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Reason" ,
SchemaName : "reason" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
},
}
return typ
}
func (r *AccountReportPeerRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode account.reportPeer#c5ba3d86 as nil" )
}
b .PutID (AccountReportPeerRequestTypeID )
return r .EncodeBare (b )
}
func (r *AccountReportPeerRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode account.reportPeer#c5ba3d86 as nil" )
}
if r .Peer == nil {
return fmt .Errorf ("unable to encode account.reportPeer#c5ba3d86: field peer is nil" )
}
if err := r .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.reportPeer#c5ba3d86: field peer: %w" , err )
}
if r .Reason == nil {
return fmt .Errorf ("unable to encode account.reportPeer#c5ba3d86: field reason is nil" )
}
if err := r .Reason .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.reportPeer#c5ba3d86: field reason: %w" , err )
}
b .PutString (r .Message )
return nil
}
func (r *AccountReportPeerRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode account.reportPeer#c5ba3d86 to nil" )
}
if err := b .ConsumeID (AccountReportPeerRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.reportPeer#c5ba3d86: %w" , err )
}
return r .DecodeBare (b )
}
func (r *AccountReportPeerRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode account.reportPeer#c5ba3d86 to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode account.reportPeer#c5ba3d86: field peer: %w" , err )
}
r .Peer = value
}
{
value , err := DecodeReportReason (b )
if err != nil {
return fmt .Errorf ("unable to decode account.reportPeer#c5ba3d86: field reason: %w" , err )
}
r .Reason = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.reportPeer#c5ba3d86: field message: %w" , err )
}
r .Message = value
}
return nil
}
func (r *AccountReportPeerRequest ) GetPeer () (value InputPeerClass ) {
if r == nil {
return
}
return r .Peer
}
func (r *AccountReportPeerRequest ) GetReason () (value ReportReasonClass ) {
if r == nil {
return
}
return r .Reason
}
func (r *AccountReportPeerRequest ) GetMessage () (value string ) {
if r == nil {
return
}
return r .Message
}
func (c *Client ) AccountReportPeer (ctx context .Context , request *AccountReportPeerRequest ) (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 .