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
263 lines
6.4 KiB
Go
Generated
263 lines
6.4 KiB
Go
Generated
// 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{}
|
|
)
|
|
|
|
// ContactsGetBlockedRequest represents TL type `contacts.getBlocked#9a868f80`.
|
|
// Returns the list of blocked users.
|
|
//
|
|
// See https://core.telegram.org/method/contacts.getBlocked for reference.
|
|
type ContactsGetBlockedRequest struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// Whether to fetch the story blocklist; if not set, will fetch the main blocklist. See
|
|
// here »¹ for differences between the two.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/block
|
|
MyStoriesFrom bool
|
|
// The number of list elements to be skipped
|
|
Offset int
|
|
// The number of list elements to be returned
|
|
Limit int
|
|
}
|
|
|
|
// ContactsGetBlockedRequestTypeID is TL type id of ContactsGetBlockedRequest.
|
|
const ContactsGetBlockedRequestTypeID = 0x9a868f80
|
|
|
|
// Ensuring interfaces in compile-time for ContactsGetBlockedRequest.
|
|
var (
|
|
_ bin.Encoder = &ContactsGetBlockedRequest{}
|
|
_ bin.Decoder = &ContactsGetBlockedRequest{}
|
|
_ bin.BareEncoder = &ContactsGetBlockedRequest{}
|
|
_ bin.BareDecoder = &ContactsGetBlockedRequest{}
|
|
)
|
|
|
|
func (g *ContactsGetBlockedRequest) Zero() bool {
|
|
if g == nil {
|
|
return true
|
|
}
|
|
if !(g.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(g.MyStoriesFrom == false) {
|
|
return false
|
|
}
|
|
if !(g.Offset == 0) {
|
|
return false
|
|
}
|
|
if !(g.Limit == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (g *ContactsGetBlockedRequest) String() string {
|
|
if g == nil {
|
|
return "ContactsGetBlockedRequest(nil)"
|
|
}
|
|
type Alias ContactsGetBlockedRequest
|
|
return fmt.Sprintf("ContactsGetBlockedRequest%+v", Alias(*g))
|
|
}
|
|
|
|
// FillFrom fills ContactsGetBlockedRequest from given interface.
|
|
func (g *ContactsGetBlockedRequest) FillFrom(from interface {
|
|
GetMyStoriesFrom() (value bool)
|
|
GetOffset() (value int)
|
|
GetLimit() (value int)
|
|
}) {
|
|
g.MyStoriesFrom = from.GetMyStoriesFrom()
|
|
g.Offset = from.GetOffset()
|
|
g.Limit = from.GetLimit()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ContactsGetBlockedRequest) TypeID() uint32 {
|
|
return ContactsGetBlockedRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ContactsGetBlockedRequest) TypeName() string {
|
|
return "contacts.getBlocked"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (g *ContactsGetBlockedRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "contacts.getBlocked",
|
|
ID: ContactsGetBlockedRequestTypeID,
|
|
}
|
|
if g == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "MyStoriesFrom",
|
|
SchemaName: "my_stories_from",
|
|
Null: !g.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "Offset",
|
|
SchemaName: "offset",
|
|
},
|
|
{
|
|
Name: "Limit",
|
|
SchemaName: "limit",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (g *ContactsGetBlockedRequest) SetFlags() {
|
|
if !(g.MyStoriesFrom == false) {
|
|
g.Flags.Set(0)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (g *ContactsGetBlockedRequest) Encode(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't encode contacts.getBlocked#9a868f80 as nil")
|
|
}
|
|
b.PutID(ContactsGetBlockedRequestTypeID)
|
|
return g.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (g *ContactsGetBlockedRequest) EncodeBare(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't encode contacts.getBlocked#9a868f80 as nil")
|
|
}
|
|
g.SetFlags()
|
|
if err := g.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode contacts.getBlocked#9a868f80: field flags: %w", err)
|
|
}
|
|
b.PutInt(g.Offset)
|
|
b.PutInt(g.Limit)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (g *ContactsGetBlockedRequest) Decode(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't decode contacts.getBlocked#9a868f80 to nil")
|
|
}
|
|
if err := b.ConsumeID(ContactsGetBlockedRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode contacts.getBlocked#9a868f80: %w", err)
|
|
}
|
|
return g.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (g *ContactsGetBlockedRequest) DecodeBare(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't decode contacts.getBlocked#9a868f80 to nil")
|
|
}
|
|
{
|
|
if err := g.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode contacts.getBlocked#9a868f80: field flags: %w", err)
|
|
}
|
|
}
|
|
g.MyStoriesFrom = g.Flags.Has(0)
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode contacts.getBlocked#9a868f80: field offset: %w", err)
|
|
}
|
|
g.Offset = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode contacts.getBlocked#9a868f80: field limit: %w", err)
|
|
}
|
|
g.Limit = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetMyStoriesFrom sets value of MyStoriesFrom conditional field.
|
|
func (g *ContactsGetBlockedRequest) SetMyStoriesFrom(value bool) {
|
|
if value {
|
|
g.Flags.Set(0)
|
|
g.MyStoriesFrom = true
|
|
} else {
|
|
g.Flags.Unset(0)
|
|
g.MyStoriesFrom = false
|
|
}
|
|
}
|
|
|
|
// GetMyStoriesFrom returns value of MyStoriesFrom conditional field.
|
|
func (g *ContactsGetBlockedRequest) GetMyStoriesFrom() (value bool) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Flags.Has(0)
|
|
}
|
|
|
|
// GetOffset returns value of Offset field.
|
|
func (g *ContactsGetBlockedRequest) GetOffset() (value int) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Offset
|
|
}
|
|
|
|
// GetLimit returns value of Limit field.
|
|
func (g *ContactsGetBlockedRequest) GetLimit() (value int) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Limit
|
|
}
|
|
|
|
// ContactsGetBlocked invokes method contacts.getBlocked#9a868f80 returning error if any.
|
|
// Returns the list of blocked users.
|
|
//
|
|
// See https://core.telegram.org/method/contacts.getBlocked for reference.
|
|
func (c *Client) ContactsGetBlocked(ctx context.Context, request *ContactsGetBlockedRequest) (ContactsBlockedClass, error) {
|
|
var result ContactsBlockedBox
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return result.Blocked, nil
|
|
}
|