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 MessagesGetCommonChatsRequest struct {
UserID InputUserClass
MaxID int64
Limit int
}
const MessagesGetCommonChatsRequestTypeID = 0xe40ca104
var (
_ bin .Encoder = &MessagesGetCommonChatsRequest {}
_ bin .Decoder = &MessagesGetCommonChatsRequest {}
_ bin .BareEncoder = &MessagesGetCommonChatsRequest {}
_ bin .BareDecoder = &MessagesGetCommonChatsRequest {}
)
func (g *MessagesGetCommonChatsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .UserID == nil ) {
return false
}
if !(g .MaxID == 0 ) {
return false
}
if !(g .Limit == 0 ) {
return false
}
return true
}
func (g *MessagesGetCommonChatsRequest ) String () string {
if g == nil {
return "MessagesGetCommonChatsRequest(nil)"
}
type Alias MessagesGetCommonChatsRequest
return fmt .Sprintf ("MessagesGetCommonChatsRequest%+v" , Alias (*g ))
}
func (g *MessagesGetCommonChatsRequest ) FillFrom (from interface {
GetUserID () (value InputUserClass )
GetMaxID () (value int64 )
GetLimit () (value int )
}) {
g .UserID = from .GetUserID ()
g .MaxID = from .GetMaxID ()
g .Limit = from .GetLimit ()
}
func (*MessagesGetCommonChatsRequest ) TypeID () uint32 {
return MessagesGetCommonChatsRequestTypeID
}
func (*MessagesGetCommonChatsRequest ) TypeName () string {
return "messages.getCommonChats"
}
func (g *MessagesGetCommonChatsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.getCommonChats" ,
ID : MessagesGetCommonChatsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "MaxID" ,
SchemaName : "max_id" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
}
return typ
}
func (g *MessagesGetCommonChatsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getCommonChats#e40ca104 as nil" )
}
b .PutID (MessagesGetCommonChatsRequestTypeID )
return g .EncodeBare (b )
}
func (g *MessagesGetCommonChatsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getCommonChats#e40ca104 as nil" )
}
if g .UserID == nil {
return fmt .Errorf ("unable to encode messages.getCommonChats#e40ca104: field user_id is nil" )
}
if err := g .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getCommonChats#e40ca104: field user_id: %w" , err )
}
b .PutLong (g .MaxID )
b .PutInt (g .Limit )
return nil
}
func (g *MessagesGetCommonChatsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getCommonChats#e40ca104 to nil" )
}
if err := b .ConsumeID (MessagesGetCommonChatsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.getCommonChats#e40ca104: %w" , err )
}
return g .DecodeBare (b )
}
func (g *MessagesGetCommonChatsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getCommonChats#e40ca104 to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.getCommonChats#e40ca104: field user_id: %w" , err )
}
g .UserID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getCommonChats#e40ca104: field max_id: %w" , err )
}
g .MaxID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getCommonChats#e40ca104: field limit: %w" , err )
}
g .Limit = value
}
return nil
}
func (g *MessagesGetCommonChatsRequest ) GetUserID () (value InputUserClass ) {
if g == nil {
return
}
return g .UserID
}
func (g *MessagesGetCommonChatsRequest ) GetMaxID () (value int64 ) {
if g == nil {
return
}
return g .MaxID
}
func (g *MessagesGetCommonChatsRequest ) GetLimit () (value int ) {
if g == nil {
return
}
return g .Limit
}
func (c *Client ) MessagesGetCommonChats (ctx context .Context , request *MessagesGetCommonChatsRequest ) (MessagesChatsClass , error ) {
var result MessagesChatsBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Chats , 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 .