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
363 lines
8.2 KiB
Go
363 lines
8.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{}
|
|
)
|
|
|
|
// MessagesDhConfigClassArray is adapter for slice of MessagesDhConfigClass.
|
|
type MessagesDhConfigClassArray []MessagesDhConfigClass
|
|
|
|
// Sort sorts slice of MessagesDhConfigClass.
|
|
func (s MessagesDhConfigClassArray) Sort(less func(a, b MessagesDhConfigClass) bool) MessagesDhConfigClassArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of MessagesDhConfigClass.
|
|
func (s MessagesDhConfigClassArray) SortStable(less func(a, b MessagesDhConfigClass) bool) MessagesDhConfigClassArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of MessagesDhConfigClass.
|
|
func (s MessagesDhConfigClassArray) Retain(keep func(x MessagesDhConfigClass) bool) MessagesDhConfigClassArray {
|
|
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 MessagesDhConfigClassArray) First() (v MessagesDhConfigClass, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s MessagesDhConfigClassArray) Last() (v MessagesDhConfigClass, 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 *MessagesDhConfigClassArray) PopFirst() (v MessagesDhConfigClass, 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 MessagesDhConfigClass
|
|
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 *MessagesDhConfigClassArray) Pop() (v MessagesDhConfigClass, 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
|
|
}
|
|
|
|
// AsMessagesDhConfigNotModified returns copy with only MessagesDhConfigNotModified constructors.
|
|
func (s MessagesDhConfigClassArray) AsMessagesDhConfigNotModified() (to MessagesDhConfigNotModifiedArray) {
|
|
for _, elem := range s {
|
|
value, ok := elem.(*MessagesDhConfigNotModified)
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, *value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// AsMessagesDhConfig returns copy with only MessagesDhConfig constructors.
|
|
func (s MessagesDhConfigClassArray) AsMessagesDhConfig() (to MessagesDhConfigArray) {
|
|
for _, elem := range s {
|
|
value, ok := elem.(*MessagesDhConfig)
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, *value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// AppendOnlyModified appends only Modified constructors to
|
|
// given slice.
|
|
func (s MessagesDhConfigClassArray) AppendOnlyModified(to []*MessagesDhConfig) []*MessagesDhConfig {
|
|
for _, elem := range s {
|
|
value, ok := elem.AsModified()
|
|
if !ok {
|
|
continue
|
|
}
|
|
to = append(to, value)
|
|
}
|
|
|
|
return to
|
|
}
|
|
|
|
// AsModified returns copy with only Modified constructors.
|
|
func (s MessagesDhConfigClassArray) AsModified() (to []*MessagesDhConfig) {
|
|
return s.AppendOnlyModified(to)
|
|
}
|
|
|
|
// FirstAsModified returns first element of slice (if exists).
|
|
func (s MessagesDhConfigClassArray) FirstAsModified() (v *MessagesDhConfig, ok bool) {
|
|
value, ok := s.First()
|
|
if !ok {
|
|
return
|
|
}
|
|
return value.AsModified()
|
|
}
|
|
|
|
// LastAsModified returns last element of slice (if exists).
|
|
func (s MessagesDhConfigClassArray) LastAsModified() (v *MessagesDhConfig, ok bool) {
|
|
value, ok := s.Last()
|
|
if !ok {
|
|
return
|
|
}
|
|
return value.AsModified()
|
|
}
|
|
|
|
// PopFirstAsModified returns element of slice (if exists).
|
|
func (s *MessagesDhConfigClassArray) PopFirstAsModified() (v *MessagesDhConfig, ok bool) {
|
|
value, ok := s.PopFirst()
|
|
if !ok {
|
|
return
|
|
}
|
|
return value.AsModified()
|
|
}
|
|
|
|
// PopAsModified returns element of slice (if exists).
|
|
func (s *MessagesDhConfigClassArray) PopAsModified() (v *MessagesDhConfig, ok bool) {
|
|
value, ok := s.Pop()
|
|
if !ok {
|
|
return
|
|
}
|
|
return value.AsModified()
|
|
}
|
|
|
|
// MessagesDhConfigNotModifiedArray is adapter for slice of MessagesDhConfigNotModified.
|
|
type MessagesDhConfigNotModifiedArray []MessagesDhConfigNotModified
|
|
|
|
// Sort sorts slice of MessagesDhConfigNotModified.
|
|
func (s MessagesDhConfigNotModifiedArray) Sort(less func(a, b MessagesDhConfigNotModified) bool) MessagesDhConfigNotModifiedArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of MessagesDhConfigNotModified.
|
|
func (s MessagesDhConfigNotModifiedArray) SortStable(less func(a, b MessagesDhConfigNotModified) bool) MessagesDhConfigNotModifiedArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of MessagesDhConfigNotModified.
|
|
func (s MessagesDhConfigNotModifiedArray) Retain(keep func(x MessagesDhConfigNotModified) bool) MessagesDhConfigNotModifiedArray {
|
|
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 MessagesDhConfigNotModifiedArray) First() (v MessagesDhConfigNotModified, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s MessagesDhConfigNotModifiedArray) Last() (v MessagesDhConfigNotModified, 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 *MessagesDhConfigNotModifiedArray) PopFirst() (v MessagesDhConfigNotModified, 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 MessagesDhConfigNotModified
|
|
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 *MessagesDhConfigNotModifiedArray) Pop() (v MessagesDhConfigNotModified, 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
|
|
}
|
|
|
|
// MessagesDhConfigArray is adapter for slice of MessagesDhConfig.
|
|
type MessagesDhConfigArray []MessagesDhConfig
|
|
|
|
// Sort sorts slice of MessagesDhConfig.
|
|
func (s MessagesDhConfigArray) Sort(less func(a, b MessagesDhConfig) bool) MessagesDhConfigArray {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// SortStable sorts slice of MessagesDhConfig.
|
|
func (s MessagesDhConfigArray) SortStable(less func(a, b MessagesDhConfig) bool) MessagesDhConfigArray {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return less(s[i], s[j])
|
|
})
|
|
return s
|
|
}
|
|
|
|
// Retain filters in-place slice of MessagesDhConfig.
|
|
func (s MessagesDhConfigArray) Retain(keep func(x MessagesDhConfig) bool) MessagesDhConfigArray {
|
|
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 MessagesDhConfigArray) First() (v MessagesDhConfig, ok bool) {
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
return s[0], true
|
|
}
|
|
|
|
// Last returns last element of slice (if exists).
|
|
func (s MessagesDhConfigArray) Last() (v MessagesDhConfig, 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 *MessagesDhConfigArray) PopFirst() (v MessagesDhConfig, 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 MessagesDhConfig
|
|
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 *MessagesDhConfigArray) Pop() (v MessagesDhConfig, 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
|
|
}
|