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
308 lines
6.6 KiB
Go
308 lines
6.6 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{}
|
|
)
|
|
|
|
// BotInlineResultClassArray is adapter for slice of BotInlineResultClass.
|
|
type BotInlineResultClassArray []BotInlineResultClass
|
|
|
|
// Sort sorts slice of BotInlineResultClass.
|
|
func (s BotInlineResultClassArray) Sort(less func(a, b BotInlineResultClass) bool) BotInlineResultClassArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of BotInlineResultClass.
|
|
func (s BotInlineResultClassArray) SortStable(less func(a, b BotInlineResultClass) bool) BotInlineResultClassArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of BotInlineResultClass.
|
|
func (s BotInlineResultClassArray) Retain(keep func(x BotInlineResultClass) bool) BotInlineResultClassArray {
|
|
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 BotInlineResultClassArray) First() (v BotInlineResultClass, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s BotInlineResultClassArray) Last() (v BotInlineResultClass, 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 *BotInlineResultClassArray) PopFirst() (v BotInlineResultClass, 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 BotInlineResultClass
|
|
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 *BotInlineResultClassArray) Pop() (v BotInlineResultClass, 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
|
|
}
|
|
|
|
// AsBotInlineResult returns copy with only BotInlineResult constructors.
|
|
func (s BotInlineResultClassArray) AsBotInlineResult() (to BotInlineResultArray) {
|
|
for _, elem := range s {
|
|
value, ok := elem.(*BotInlineResult)
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, *value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// AsBotInlineMediaResult returns copy with only BotInlineMediaResult constructors.
|
|
func (s BotInlineResultClassArray) AsBotInlineMediaResult() (to BotInlineMediaResultArray) {
|
|
for _, elem := range s {
|
|
value, ok := elem.(*BotInlineMediaResult)
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, *value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// BotInlineResultArray is adapter for slice of BotInlineResult.
|
|
type BotInlineResultArray []BotInlineResult
|
|
|
|
// Sort sorts slice of BotInlineResult.
|
|
func (s BotInlineResultArray) Sort(less func(a, b BotInlineResult) bool) BotInlineResultArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of BotInlineResult.
|
|
func (s BotInlineResultArray) SortStable(less func(a, b BotInlineResult) bool) BotInlineResultArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of BotInlineResult.
|
|
func (s BotInlineResultArray) Retain(keep func(x BotInlineResult) bool) BotInlineResultArray {
|
|
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 BotInlineResultArray) First() (v BotInlineResult, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s BotInlineResultArray) Last() (v BotInlineResult, 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 *BotInlineResultArray) PopFirst() (v BotInlineResult, 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 BotInlineResult
|
|
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 *BotInlineResultArray) Pop() (v BotInlineResult, 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
|
|
}
|
|
|
|
// BotInlineMediaResultArray is adapter for slice of BotInlineMediaResult.
|
|
type BotInlineMediaResultArray []BotInlineMediaResult
|
|
|
|
// Sort sorts slice of BotInlineMediaResult.
|
|
func (s BotInlineMediaResultArray) Sort(less func(a, b BotInlineMediaResult) bool) BotInlineMediaResultArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of BotInlineMediaResult.
|
|
func (s BotInlineMediaResultArray) SortStable(less func(a, b BotInlineMediaResult) bool) BotInlineMediaResultArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of BotInlineMediaResult.
|
|
func (s BotInlineMediaResultArray) Retain(keep func(x BotInlineMediaResult) bool) BotInlineMediaResultArray {
|
|
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 BotInlineMediaResultArray) First() (v BotInlineMediaResult, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s BotInlineMediaResultArray) Last() (v BotInlineMediaResult, 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 *BotInlineMediaResultArray) PopFirst() (v BotInlineMediaResult, 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 BotInlineMediaResult
|
|
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 *BotInlineMediaResultArray) Pop() (v BotInlineMediaResult, 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
|
|
}
|