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
336 lines
7.2 KiB
Go
336 lines
7.2 KiB
Go
//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{}
|
|
)
|
|
|
|
// InputBotAppClassArray is adapter for slice of InputBotAppClass.
|
|
type InputBotAppClassArray []InputBotAppClass
|
|
|
|
// Sort sorts slice of InputBotAppClass.
|
|
func (s InputBotAppClassArray) Sort(less func(a, b InputBotAppClass) bool) InputBotAppClassArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of InputBotAppClass.
|
|
func (s InputBotAppClassArray) SortStable(less func(a, b InputBotAppClass) bool) InputBotAppClassArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of InputBotAppClass.
|
|
func (s InputBotAppClassArray) Retain(keep func(x InputBotAppClass) bool) InputBotAppClassArray {
|
|
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 InputBotAppClassArray) First() (v InputBotAppClass, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s InputBotAppClassArray) Last() (v InputBotAppClass, 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 *InputBotAppClassArray) PopFirst() (v InputBotAppClass, 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 InputBotAppClass
|
|
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 *InputBotAppClassArray) Pop() (v InputBotAppClass, 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
|
|
}
|
|
|
|
// AsInputBotAppID returns copy with only InputBotAppID constructors.
|
|
func (s InputBotAppClassArray) AsInputBotAppID() (to InputBotAppIDArray) {
|
|
for _, elem := range s {
|
|
value, ok := elem.(*InputBotAppID)
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, *value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// AsInputBotAppShortName returns copy with only InputBotAppShortName constructors.
|
|
func (s InputBotAppClassArray) AsInputBotAppShortName() (to InputBotAppShortNameArray) {
|
|
for _, elem := range s {
|
|
value, ok := elem.(*InputBotAppShortName)
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, *value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// InputBotAppIDArray is adapter for slice of InputBotAppID.
|
|
type InputBotAppIDArray []InputBotAppID
|
|
|
|
// Sort sorts slice of InputBotAppID.
|
|
func (s InputBotAppIDArray) Sort(less func(a, b InputBotAppID) bool) InputBotAppIDArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of InputBotAppID.
|
|
func (s InputBotAppIDArray) SortStable(less func(a, b InputBotAppID) bool) InputBotAppIDArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of InputBotAppID.
|
|
func (s InputBotAppIDArray) Retain(keep func(x InputBotAppID) bool) InputBotAppIDArray {
|
|
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 InputBotAppIDArray) First() (v InputBotAppID, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s InputBotAppIDArray) Last() (v InputBotAppID, 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 *InputBotAppIDArray) PopFirst() (v InputBotAppID, 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 InputBotAppID
|
|
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 *InputBotAppIDArray) Pop() (v InputBotAppID, 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 InputBotAppID by ID.
|
|
func (s InputBotAppIDArray) SortByID() InputBotAppIDArray {
|
|
return s.Sort(func(a, b InputBotAppID) bool {
|
|
return a.GetID() < b.GetID()
|
|
})
|
|
}
|
|
|
|
// SortStableByID sorts slice of InputBotAppID by ID.
|
|
func (s InputBotAppIDArray) SortStableByID() InputBotAppIDArray {
|
|
return s.SortStable(func(a, b InputBotAppID) bool {
|
|
return a.GetID() < b.GetID()
|
|
})
|
|
}
|
|
|
|
// FillMap fills constructors to given map.
|
|
func (s InputBotAppIDArray) FillMap(to map[int64]InputBotAppID) {
|
|
for _, value := range s {
|
|
to[value.GetID()] = value
|
|
}
|
|
}
|
|
|
|
// ToMap collects constructors to map.
|
|
func (s InputBotAppIDArray) ToMap() map[int64]InputBotAppID {
|
|
r := make(map[int64]InputBotAppID, len(s))
|
|
s.FillMap(r)
|
|
return r
|
|
}
|
|
|
|
// InputBotAppShortNameArray is adapter for slice of InputBotAppShortName.
|
|
type InputBotAppShortNameArray []InputBotAppShortName
|
|
|
|
// Sort sorts slice of InputBotAppShortName.
|
|
func (s InputBotAppShortNameArray) Sort(less func(a, b InputBotAppShortName) bool) InputBotAppShortNameArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of InputBotAppShortName.
|
|
func (s InputBotAppShortNameArray) SortStable(less func(a, b InputBotAppShortName) bool) InputBotAppShortNameArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of InputBotAppShortName.
|
|
func (s InputBotAppShortNameArray) Retain(keep func(x InputBotAppShortName) bool) InputBotAppShortNameArray {
|
|
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 InputBotAppShortNameArray) First() (v InputBotAppShortName, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s InputBotAppShortNameArray) Last() (v InputBotAppShortName, 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 *InputBotAppShortNameArray) PopFirst() (v InputBotAppShortName, 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 InputBotAppShortName
|
|
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 *InputBotAppShortNameArray) Pop() (v InputBotAppShortName, 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
|
|
}
|