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 InputMessageClassArray []InputMessageClass
func (s InputMessageClassArray ) Sort (less func (a , b InputMessageClass ) bool ) InputMessageClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputMessageClassArray ) SortStable (less func (a , b InputMessageClass ) bool ) InputMessageClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputMessageClassArray ) Retain (keep func (x InputMessageClass ) bool ) InputMessageClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputMessageClassArray ) First () (v InputMessageClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputMessageClassArray ) Last () (v InputMessageClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputMessageClassArray ) PopFirst () (v InputMessageClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputMessageClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputMessageClassArray ) Pop () (v InputMessageClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [len (a )-1 ]
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s InputMessageClassArray ) AsInputMessageID () (to InputMessageIDArray ) {
for _ , elem := range s {
value , ok := elem .(*InputMessageID )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputMessageClassArray ) AsInputMessageReplyTo () (to InputMessageReplyToArray ) {
for _ , elem := range s {
value , ok := elem .(*InputMessageReplyTo )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputMessageClassArray ) AsInputMessageCallbackQuery () (to InputMessageCallbackQueryArray ) {
for _ , elem := range s {
value , ok := elem .(*InputMessageCallbackQuery )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type InputMessageIDArray []InputMessageID
func (s InputMessageIDArray ) Sort (less func (a , b InputMessageID ) bool ) InputMessageIDArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputMessageIDArray ) SortStable (less func (a , b InputMessageID ) bool ) InputMessageIDArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputMessageIDArray ) Retain (keep func (x InputMessageID ) bool ) InputMessageIDArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputMessageIDArray ) First () (v InputMessageID , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputMessageIDArray ) Last () (v InputMessageID , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputMessageIDArray ) PopFirst () (v InputMessageID , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputMessageID
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputMessageIDArray ) Pop () (v InputMessageID , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [len (a )-1 ]
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s InputMessageIDArray ) SortByID () InputMessageIDArray {
return s .Sort (func (a , b InputMessageID ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputMessageIDArray ) SortStableByID () InputMessageIDArray {
return s .SortStable (func (a , b InputMessageID ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputMessageIDArray ) FillMap (to map [int ]InputMessageID ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s InputMessageIDArray ) ToMap () map [int ]InputMessageID {
r := make (map [int ]InputMessageID , len (s ))
s .FillMap (r )
return r
}
type InputMessageReplyToArray []InputMessageReplyTo
func (s InputMessageReplyToArray ) Sort (less func (a , b InputMessageReplyTo ) bool ) InputMessageReplyToArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputMessageReplyToArray ) SortStable (less func (a , b InputMessageReplyTo ) bool ) InputMessageReplyToArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputMessageReplyToArray ) Retain (keep func (x InputMessageReplyTo ) bool ) InputMessageReplyToArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputMessageReplyToArray ) First () (v InputMessageReplyTo , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputMessageReplyToArray ) Last () (v InputMessageReplyTo , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputMessageReplyToArray ) PopFirst () (v InputMessageReplyTo , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputMessageReplyTo
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputMessageReplyToArray ) Pop () (v InputMessageReplyTo , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [len (a )-1 ]
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s InputMessageReplyToArray ) SortByID () InputMessageReplyToArray {
return s .Sort (func (a , b InputMessageReplyTo ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputMessageReplyToArray ) SortStableByID () InputMessageReplyToArray {
return s .SortStable (func (a , b InputMessageReplyTo ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputMessageReplyToArray ) FillMap (to map [int ]InputMessageReplyTo ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s InputMessageReplyToArray ) ToMap () map [int ]InputMessageReplyTo {
r := make (map [int ]InputMessageReplyTo , len (s ))
s .FillMap (r )
return r
}
type InputMessageCallbackQueryArray []InputMessageCallbackQuery
func (s InputMessageCallbackQueryArray ) Sort (less func (a , b InputMessageCallbackQuery ) bool ) InputMessageCallbackQueryArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputMessageCallbackQueryArray ) SortStable (less func (a , b InputMessageCallbackQuery ) bool ) InputMessageCallbackQueryArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputMessageCallbackQueryArray ) Retain (keep func (x InputMessageCallbackQuery ) bool ) InputMessageCallbackQueryArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputMessageCallbackQueryArray ) First () (v InputMessageCallbackQuery , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputMessageCallbackQueryArray ) Last () (v InputMessageCallbackQuery , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputMessageCallbackQueryArray ) PopFirst () (v InputMessageCallbackQuery , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputMessageCallbackQuery
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputMessageCallbackQueryArray ) Pop () (v InputMessageCallbackQuery , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [len (a )-1 ]
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s InputMessageCallbackQueryArray ) SortByID () InputMessageCallbackQueryArray {
return s .Sort (func (a , b InputMessageCallbackQuery ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputMessageCallbackQueryArray ) SortStableByID () InputMessageCallbackQueryArray {
return s .SortStable (func (a , b InputMessageCallbackQuery ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputMessageCallbackQueryArray ) FillMap (to map [int ]InputMessageCallbackQuery ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s InputMessageCallbackQueryArray ) ToMap () map [int ]InputMessageCallbackQuery {
r := make (map [int ]InputMessageCallbackQuery , len (s ))
s .FillMap (r )
return r
}
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 .