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 ChannelsReadHistoryRequest struct {
Channel InputChannelClass
MaxID int
}
const ChannelsReadHistoryRequestTypeID = 0xcc104937
var (
_ bin .Encoder = &ChannelsReadHistoryRequest {}
_ bin .Decoder = &ChannelsReadHistoryRequest {}
_ bin .BareEncoder = &ChannelsReadHistoryRequest {}
_ bin .BareDecoder = &ChannelsReadHistoryRequest {}
)
func (r *ChannelsReadHistoryRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Channel == nil ) {
return false
}
if !(r .MaxID == 0 ) {
return false
}
return true
}
func (r *ChannelsReadHistoryRequest ) String () string {
if r == nil {
return "ChannelsReadHistoryRequest(nil)"
}
type Alias ChannelsReadHistoryRequest
return fmt .Sprintf ("ChannelsReadHistoryRequest%+v" , Alias (*r ))
}
func (r *ChannelsReadHistoryRequest ) FillFrom (from interface {
GetChannel () (value InputChannelClass )
GetMaxID () (value int )
}) {
r .Channel = from .GetChannel ()
r .MaxID = from .GetMaxID ()
}
func (*ChannelsReadHistoryRequest ) TypeID () uint32 {
return ChannelsReadHistoryRequestTypeID
}
func (*ChannelsReadHistoryRequest ) TypeName () string {
return "channels.readHistory"
}
func (r *ChannelsReadHistoryRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.readHistory" ,
ID : ChannelsReadHistoryRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "MaxID" ,
SchemaName : "max_id" ,
},
}
return typ
}
func (r *ChannelsReadHistoryRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode channels.readHistory#cc104937 as nil" )
}
b .PutID (ChannelsReadHistoryRequestTypeID )
return r .EncodeBare (b )
}
func (r *ChannelsReadHistoryRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode channels.readHistory#cc104937 as nil" )
}
if r .Channel == nil {
return fmt .Errorf ("unable to encode channels.readHistory#cc104937: field channel is nil" )
}
if err := r .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.readHistory#cc104937: field channel: %w" , err )
}
b .PutInt (r .MaxID )
return nil
}
func (r *ChannelsReadHistoryRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode channels.readHistory#cc104937 to nil" )
}
if err := b .ConsumeID (ChannelsReadHistoryRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.readHistory#cc104937: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ChannelsReadHistoryRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode channels.readHistory#cc104937 to nil" )
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.readHistory#cc104937: field channel: %w" , err )
}
r .Channel = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channels.readHistory#cc104937: field max_id: %w" , err )
}
r .MaxID = value
}
return nil
}
func (r *ChannelsReadHistoryRequest ) GetChannel () (value InputChannelClass ) {
if r == nil {
return
}
return r .Channel
}
func (r *ChannelsReadHistoryRequest ) GetMaxID () (value int ) {
if r == nil {
return
}
return r .MaxID
}
func (r *ChannelsReadHistoryRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return r .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsReadHistory (ctx context .Context , request *ChannelsReadHistoryRequest ) (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 .