7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
431 lines
9.7 KiB
Go
Generated
431 lines
9.7 KiB
Go
Generated
//go:build !no_gotd_slices
|
|
// +build !no_gotd_slices
|
|
|
|
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tg
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"go.uber.org/multierr"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
|
|
)
|
|
|
|
// No-op definition for keeping imports.
|
|
var (
|
|
_ = bin.Buffer{}
|
|
_ = context.Background()
|
|
_ = fmt.Stringer(nil)
|
|
_ = strings.Builder{}
|
|
_ = errors.Is
|
|
_ = multierr.AppendInto
|
|
_ = sort.Ints
|
|
_ = tdp.Format
|
|
_ = tgerr.Error{}
|
|
_ = tdjson.Encoder{}
|
|
)
|
|
|
|
// InputStickerSetClassArray is adapter for slice of InputStickerSetClass.
|
|
type InputStickerSetClassArray []InputStickerSetClass
|
|
|
|
// Sort sorts slice of InputStickerSetClass.
|
|
func (s InputStickerSetClassArray) Sort(less func(a, b InputStickerSetClass) bool) InputStickerSetClassArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of InputStickerSetClass.
|
|
func (s InputStickerSetClassArray) SortStable(less func(a, b InputStickerSetClass) bool) InputStickerSetClassArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of InputStickerSetClass.
|
|
func (s InputStickerSetClassArray) Retain(keep func(x InputStickerSetClass) bool) InputStickerSetClassArray {
|
|
n := 0
|
|
for _, x := range s {
|
|
if keep(x) {
|
|
s[n] = x
|
|
n++
|
|
}
|
|
}
|
|
s = s[:n]
|
|
|
|
return s
|
|
}
|
|
|
|
// First returns first element of slice (if exists).
|
|
func (s InputStickerSetClassArray) First() (v InputStickerSetClass, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s InputStickerSetClassArray) Last() (v InputStickerSetClass, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[len(s)-1], true
|
|
}
|
|
|
|
// PopFirst returns first element of slice (if exists) and deletes it.
|
|
func (s *InputStickerSetClassArray) PopFirst() (v InputStickerSetClass, ok bool) {
|
|
if s == nil || len(*s) < 1 {
|
|
return
|
|
}
|
|
|
|
a := *s
|
|
v = a[0]
|
|
|
|
// Delete by index from SliceTricks.
|
|
copy(a[0:], a[1:])
|
|
var zero InputStickerSetClass
|
|
a[len(a)-1] = zero
|
|
a = a[:len(a)-1]
|
|
*s = a
|
|
|
|
return v, true
|
|
}
|
|
|
|
// Pop returns last element of slice (if exists) and deletes it.
|
|
func (s *InputStickerSetClassArray) Pop() (v InputStickerSetClass, 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
|
|
}
|
|
|
|
// AsInputStickerSetID returns copy with only InputStickerSetID constructors.
|
|
func (s InputStickerSetClassArray) AsInputStickerSetID() (to InputStickerSetIDArray) {
|
|
for _, elem := range s {
|
|
value, ok := elem.(*InputStickerSetID)
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, *value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// AsInputStickerSetShortName returns copy with only InputStickerSetShortName constructors.
|
|
func (s InputStickerSetClassArray) AsInputStickerSetShortName() (to InputStickerSetShortNameArray) {
|
|
for _, elem := range s {
|
|
value, ok := elem.(*InputStickerSetShortName)
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, *value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// AsInputStickerSetDice returns copy with only InputStickerSetDice constructors.
|
|
func (s InputStickerSetClassArray) AsInputStickerSetDice() (to InputStickerSetDiceArray) {
|
|
for _, elem := range s {
|
|
value, ok := elem.(*InputStickerSetDice)
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, *value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// InputStickerSetIDArray is adapter for slice of InputStickerSetID.
|
|
type InputStickerSetIDArray []InputStickerSetID
|
|
|
|
// Sort sorts slice of InputStickerSetID.
|
|
func (s InputStickerSetIDArray) Sort(less func(a, b InputStickerSetID) bool) InputStickerSetIDArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of InputStickerSetID.
|
|
func (s InputStickerSetIDArray) SortStable(less func(a, b InputStickerSetID) bool) InputStickerSetIDArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of InputStickerSetID.
|
|
func (s InputStickerSetIDArray) Retain(keep func(x InputStickerSetID) bool) InputStickerSetIDArray {
|
|
n := 0
|
|
for _, x := range s {
|
|
if keep(x) {
|
|
s[n] = x
|
|
n++
|
|
}
|
|
}
|
|
s = s[:n]
|
|
|
|
return s
|
|
}
|
|
|
|
// First returns first element of slice (if exists).
|
|
func (s InputStickerSetIDArray) First() (v InputStickerSetID, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s InputStickerSetIDArray) Last() (v InputStickerSetID, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[len(s)-1], true
|
|
}
|
|
|
|
// PopFirst returns first element of slice (if exists) and deletes it.
|
|
func (s *InputStickerSetIDArray) PopFirst() (v InputStickerSetID, ok bool) {
|
|
if s == nil || len(*s) < 1 {
|
|
return
|
|
}
|
|
|
|
a := *s
|
|
v = a[0]
|
|
|
|
// Delete by index from SliceTricks.
|
|
copy(a[0:], a[1:])
|
|
var zero InputStickerSetID
|
|
a[len(a)-1] = zero
|
|
a = a[:len(a)-1]
|
|
*s = a
|
|
|
|
return v, true
|
|
}
|
|
|
|
// Pop returns last element of slice (if exists) and deletes it.
|
|
func (s *InputStickerSetIDArray) Pop() (v InputStickerSetID, 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
|
|
}
|
|
|
|
// SortByID sorts slice of InputStickerSetID by ID.
|
|
func (s InputStickerSetIDArray) SortByID() InputStickerSetIDArray {
|
|
return s.Sort(func(a, b InputStickerSetID) bool {
|
|
return a.GetID() < b.GetID()
|
|
})
|
|
}
|
|
|
|
// SortStableByID sorts slice of InputStickerSetID by ID.
|
|
func (s InputStickerSetIDArray) SortStableByID() InputStickerSetIDArray {
|
|
return s.SortStable(func(a, b InputStickerSetID) bool {
|
|
return a.GetID() < b.GetID()
|
|
})
|
|
}
|
|
|
|
// FillMap fills constructors to given map.
|
|
func (s InputStickerSetIDArray) FillMap(to map[int64]InputStickerSetID) {
|
|
for _, value := range s {
|
|
to[value.GetID()] = value
|
|
}
|
|
}
|
|
|
|
// ToMap collects constructors to map.
|
|
func (s InputStickerSetIDArray) ToMap() map[int64]InputStickerSetID {
|
|
r := make(map[int64]InputStickerSetID, len(s))
|
|
s.FillMap(r)
|
|
return r
|
|
}
|
|
|
|
// InputStickerSetShortNameArray is adapter for slice of InputStickerSetShortName.
|
|
type InputStickerSetShortNameArray []InputStickerSetShortName
|
|
|
|
// Sort sorts slice of InputStickerSetShortName.
|
|
func (s InputStickerSetShortNameArray) Sort(less func(a, b InputStickerSetShortName) bool) InputStickerSetShortNameArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of InputStickerSetShortName.
|
|
func (s InputStickerSetShortNameArray) SortStable(less func(a, b InputStickerSetShortName) bool) InputStickerSetShortNameArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of InputStickerSetShortName.
|
|
func (s InputStickerSetShortNameArray) Retain(keep func(x InputStickerSetShortName) bool) InputStickerSetShortNameArray {
|
|
n := 0
|
|
for _, x := range s {
|
|
if keep(x) {
|
|
s[n] = x
|
|
n++
|
|
}
|
|
}
|
|
s = s[:n]
|
|
|
|
return s
|
|
}
|
|
|
|
// First returns first element of slice (if exists).
|
|
func (s InputStickerSetShortNameArray) First() (v InputStickerSetShortName, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s InputStickerSetShortNameArray) Last() (v InputStickerSetShortName, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[len(s)-1], true
|
|
}
|
|
|
|
// PopFirst returns first element of slice (if exists) and deletes it.
|
|
func (s *InputStickerSetShortNameArray) PopFirst() (v InputStickerSetShortName, ok bool) {
|
|
if s == nil || len(*s) < 1 {
|
|
return
|
|
}
|
|
|
|
a := *s
|
|
v = a[0]
|
|
|
|
// Delete by index from SliceTricks.
|
|
copy(a[0:], a[1:])
|
|
var zero InputStickerSetShortName
|
|
a[len(a)-1] = zero
|
|
a = a[:len(a)-1]
|
|
*s = a
|
|
|
|
return v, true
|
|
}
|
|
|
|
// Pop returns last element of slice (if exists) and deletes it.
|
|
func (s *InputStickerSetShortNameArray) Pop() (v InputStickerSetShortName, 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
|
|
}
|
|
|
|
// InputStickerSetDiceArray is adapter for slice of InputStickerSetDice.
|
|
type InputStickerSetDiceArray []InputStickerSetDice
|
|
|
|
// Sort sorts slice of InputStickerSetDice.
|
|
func (s InputStickerSetDiceArray) Sort(less func(a, b InputStickerSetDice) bool) InputStickerSetDiceArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of InputStickerSetDice.
|
|
func (s InputStickerSetDiceArray) SortStable(less func(a, b InputStickerSetDice) bool) InputStickerSetDiceArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of InputStickerSetDice.
|
|
func (s InputStickerSetDiceArray) Retain(keep func(x InputStickerSetDice) bool) InputStickerSetDiceArray {
|
|
n := 0
|
|
for _, x := range s {
|
|
if keep(x) {
|
|
s[n] = x
|
|
n++
|
|
}
|
|
}
|
|
s = s[:n]
|
|
|
|
return s
|
|
}
|
|
|
|
// First returns first element of slice (if exists).
|
|
func (s InputStickerSetDiceArray) First() (v InputStickerSetDice, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s InputStickerSetDiceArray) Last() (v InputStickerSetDice, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[len(s)-1], true
|
|
}
|
|
|
|
// PopFirst returns first element of slice (if exists) and deletes it.
|
|
func (s *InputStickerSetDiceArray) PopFirst() (v InputStickerSetDice, ok bool) {
|
|
if s == nil || len(*s) < 1 {
|
|
return
|
|
}
|
|
|
|
a := *s
|
|
v = a[0]
|
|
|
|
// Delete by index from SliceTricks.
|
|
copy(a[0:], a[1:])
|
|
var zero InputStickerSetDice
|
|
a[len(a)-1] = zero
|
|
a = a[:len(a)-1]
|
|
*s = a
|
|
|
|
return v, true
|
|
}
|
|
|
|
// Pop returns last element of slice (if exists) and deletes it.
|
|
func (s *InputStickerSetDiceArray) Pop() (v InputStickerSetDice, 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
|
|
}
|