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 MessagesSetGameScoreRequest struct {
Flags bin .Fields
EditMessage bool
Force bool
Peer InputPeerClass
ID int
UserID InputUserClass
Score int
}
const MessagesSetGameScoreRequestTypeID = 0x8ef8ecc0
var (
_ bin .Encoder = &MessagesSetGameScoreRequest {}
_ bin .Decoder = &MessagesSetGameScoreRequest {}
_ bin .BareEncoder = &MessagesSetGameScoreRequest {}
_ bin .BareDecoder = &MessagesSetGameScoreRequest {}
)
func (s *MessagesSetGameScoreRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .EditMessage == false ) {
return false
}
if !(s .Force == false ) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .ID == 0 ) {
return false
}
if !(s .UserID == nil ) {
return false
}
if !(s .Score == 0 ) {
return false
}
return true
}
func (s *MessagesSetGameScoreRequest ) String () string {
if s == nil {
return "MessagesSetGameScoreRequest(nil)"
}
type Alias MessagesSetGameScoreRequest
return fmt .Sprintf ("MessagesSetGameScoreRequest%+v" , Alias (*s ))
}
func (s *MessagesSetGameScoreRequest ) FillFrom (from interface {
GetEditMessage () (value bool )
GetForce () (value bool )
GetPeer () (value InputPeerClass )
GetID () (value int )
GetUserID () (value InputUserClass )
GetScore () (value int )
}) {
s .EditMessage = from .GetEditMessage ()
s .Force = from .GetForce ()
s .Peer = from .GetPeer ()
s .ID = from .GetID ()
s .UserID = from .GetUserID ()
s .Score = from .GetScore ()
}
func (*MessagesSetGameScoreRequest ) TypeID () uint32 {
return MessagesSetGameScoreRequestTypeID
}
func (*MessagesSetGameScoreRequest ) TypeName () string {
return "messages.setGameScore"
}
func (s *MessagesSetGameScoreRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.setGameScore" ,
ID : MessagesSetGameScoreRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "EditMessage" ,
SchemaName : "edit_message" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Force" ,
SchemaName : "force" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Score" ,
SchemaName : "score" ,
},
}
return typ
}
func (s *MessagesSetGameScoreRequest ) SetFlags () {
if !(s .EditMessage == false ) {
s .Flags .Set (0 )
}
if !(s .Force == false ) {
s .Flags .Set (1 )
}
}
func (s *MessagesSetGameScoreRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setGameScore#8ef8ecc0 as nil" )
}
b .PutID (MessagesSetGameScoreRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSetGameScoreRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setGameScore#8ef8ecc0 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setGameScore#8ef8ecc0: field flags: %w" , err )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode messages.setGameScore#8ef8ecc0: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setGameScore#8ef8ecc0: field peer: %w" , err )
}
b .PutInt (s .ID )
if s .UserID == nil {
return fmt .Errorf ("unable to encode messages.setGameScore#8ef8ecc0: field user_id is nil" )
}
if err := s .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setGameScore#8ef8ecc0: field user_id: %w" , err )
}
b .PutInt (s .Score )
return nil
}
func (s *MessagesSetGameScoreRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setGameScore#8ef8ecc0 to nil" )
}
if err := b .ConsumeID (MessagesSetGameScoreRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.setGameScore#8ef8ecc0: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSetGameScoreRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setGameScore#8ef8ecc0 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setGameScore#8ef8ecc0: field flags: %w" , err )
}
}
s .EditMessage = s .Flags .Has (0 )
s .Force = s .Flags .Has (1 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.setGameScore#8ef8ecc0: field peer: %w" , err )
}
s .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setGameScore#8ef8ecc0: field id: %w" , err )
}
s .ID = value
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.setGameScore#8ef8ecc0: field user_id: %w" , err )
}
s .UserID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setGameScore#8ef8ecc0: field score: %w" , err )
}
s .Score = value
}
return nil
}
func (s *MessagesSetGameScoreRequest ) SetEditMessage (value bool ) {
if value {
s .Flags .Set (0 )
s .EditMessage = true
} else {
s .Flags .Unset (0 )
s .EditMessage = false
}
}
func (s *MessagesSetGameScoreRequest ) GetEditMessage () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *MessagesSetGameScoreRequest ) SetForce (value bool ) {
if value {
s .Flags .Set (1 )
s .Force = true
} else {
s .Flags .Unset (1 )
s .Force = false
}
}
func (s *MessagesSetGameScoreRequest ) GetForce () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *MessagesSetGameScoreRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSetGameScoreRequest ) GetID () (value int ) {
if s == nil {
return
}
return s .ID
}
func (s *MessagesSetGameScoreRequest ) GetUserID () (value InputUserClass ) {
if s == nil {
return
}
return s .UserID
}
func (s *MessagesSetGameScoreRequest ) GetScore () (value int ) {
if s == nil {
return
}
return s .Score
}
func (c *Client ) MessagesSetGameScore (ctx context .Context , request *MessagesSetGameScoreRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , 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 .