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 MessagesSetTypingRequest struct {
Flags bin .Fields
Peer InputPeerClass
TopMsgID int
Action SendMessageActionClass
}
const MessagesSetTypingRequestTypeID = 0x58943ee2
var (
_ bin .Encoder = &MessagesSetTypingRequest {}
_ bin .Decoder = &MessagesSetTypingRequest {}
_ bin .BareEncoder = &MessagesSetTypingRequest {}
_ bin .BareDecoder = &MessagesSetTypingRequest {}
)
func (s *MessagesSetTypingRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .TopMsgID == 0 ) {
return false
}
if !(s .Action == nil ) {
return false
}
return true
}
func (s *MessagesSetTypingRequest ) String () string {
if s == nil {
return "MessagesSetTypingRequest(nil)"
}
type Alias MessagesSetTypingRequest
return fmt .Sprintf ("MessagesSetTypingRequest%+v" , Alias (*s ))
}
func (s *MessagesSetTypingRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetTopMsgID () (value int , ok bool )
GetAction () (value SendMessageActionClass )
}) {
s .Peer = from .GetPeer ()
if val , ok := from .GetTopMsgID (); ok {
s .TopMsgID = val
}
s .Action = from .GetAction ()
}
func (*MessagesSetTypingRequest ) TypeID () uint32 {
return MessagesSetTypingRequestTypeID
}
func (*MessagesSetTypingRequest ) TypeName () string {
return "messages.setTyping"
}
func (s *MessagesSetTypingRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.setTyping" ,
ID : MessagesSetTypingRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "TopMsgID" ,
SchemaName : "top_msg_id" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Action" ,
SchemaName : "action" ,
},
}
return typ
}
func (s *MessagesSetTypingRequest ) SetFlags () {
if !(s .TopMsgID == 0 ) {
s .Flags .Set (0 )
}
}
func (s *MessagesSetTypingRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setTyping#58943ee2 as nil" )
}
b .PutID (MessagesSetTypingRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSetTypingRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setTyping#58943ee2 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setTyping#58943ee2: field flags: %w" , err )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode messages.setTyping#58943ee2: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setTyping#58943ee2: field peer: %w" , err )
}
if s .Flags .Has (0 ) {
b .PutInt (s .TopMsgID )
}
if s .Action == nil {
return fmt .Errorf ("unable to encode messages.setTyping#58943ee2: field action is nil" )
}
if err := s .Action .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setTyping#58943ee2: field action: %w" , err )
}
return nil
}
func (s *MessagesSetTypingRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setTyping#58943ee2 to nil" )
}
if err := b .ConsumeID (MessagesSetTypingRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.setTyping#58943ee2: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSetTypingRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setTyping#58943ee2 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setTyping#58943ee2: field flags: %w" , err )
}
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.setTyping#58943ee2: field peer: %w" , err )
}
s .Peer = value
}
if s .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setTyping#58943ee2: field top_msg_id: %w" , err )
}
s .TopMsgID = value
}
{
value , err := DecodeSendMessageAction (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.setTyping#58943ee2: field action: %w" , err )
}
s .Action = value
}
return nil
}
func (s *MessagesSetTypingRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSetTypingRequest ) SetTopMsgID (value int ) {
s .Flags .Set (0 )
s .TopMsgID = value
}
func (s *MessagesSetTypingRequest ) GetTopMsgID () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .TopMsgID , true
}
func (s *MessagesSetTypingRequest ) GetAction () (value SendMessageActionClass ) {
if s == nil {
return
}
return s .Action
}
func (c *Client ) MessagesSetTyping (ctx context .Context , request *MessagesSetTypingRequest ) (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 .