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
241 lines
6.2 KiB
Go
241 lines
6.2 KiB
Go
// 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{}
|
|
)
|
|
|
|
// ChannelsGetSendAsRequest represents TL type `channels.getSendAs#e785a43f`.
|
|
// Obtains a list of peers that can be used to send messages in a specific group
|
|
//
|
|
// See https://core.telegram.org/method/channels.getSendAs for reference.
|
|
type ChannelsGetSendAsRequest struct {
|
|
// Flags field of ChannelsGetSendAsRequest.
|
|
Flags bin.Fields
|
|
// ForPaidReactions field of ChannelsGetSendAsRequest.
|
|
ForPaidReactions bool
|
|
// The group where we intend to send messages
|
|
Peer InputPeerClass
|
|
}
|
|
|
|
// ChannelsGetSendAsRequestTypeID is TL type id of ChannelsGetSendAsRequest.
|
|
const ChannelsGetSendAsRequestTypeID = 0xe785a43f
|
|
|
|
// Ensuring interfaces in compile-time for ChannelsGetSendAsRequest.
|
|
var (
|
|
_ bin.Encoder = &ChannelsGetSendAsRequest{}
|
|
_ bin.Decoder = &ChannelsGetSendAsRequest{}
|
|
_ bin.BareEncoder = &ChannelsGetSendAsRequest{}
|
|
_ bin.BareDecoder = &ChannelsGetSendAsRequest{}
|
|
)
|
|
|
|
func (g *ChannelsGetSendAsRequest) Zero() bool {
|
|
if g == nil {
|
|
return true
|
|
}
|
|
if !(g.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(g.ForPaidReactions == false) {
|
|
return false
|
|
}
|
|
if !(g.Peer == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (g *ChannelsGetSendAsRequest) String() string {
|
|
if g == nil {
|
|
return "ChannelsGetSendAsRequest(nil)"
|
|
}
|
|
type Alias ChannelsGetSendAsRequest
|
|
return fmt.Sprintf("ChannelsGetSendAsRequest%+v", Alias(*g))
|
|
}
|
|
|
|
// FillFrom fills ChannelsGetSendAsRequest from given interface.
|
|
func (g *ChannelsGetSendAsRequest) FillFrom(from interface {
|
|
GetForPaidReactions() (value bool)
|
|
GetPeer() (value InputPeerClass)
|
|
}) {
|
|
g.ForPaidReactions = from.GetForPaidReactions()
|
|
g.Peer = from.GetPeer()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChannelsGetSendAsRequest) TypeID() uint32 {
|
|
return ChannelsGetSendAsRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChannelsGetSendAsRequest) TypeName() string {
|
|
return "channels.getSendAs"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (g *ChannelsGetSendAsRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "channels.getSendAs",
|
|
ID: ChannelsGetSendAsRequestTypeID,
|
|
}
|
|
if g == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ForPaidReactions",
|
|
SchemaName: "for_paid_reactions",
|
|
Null: !g.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "Peer",
|
|
SchemaName: "peer",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (g *ChannelsGetSendAsRequest) SetFlags() {
|
|
if !(g.ForPaidReactions == false) {
|
|
g.Flags.Set(0)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (g *ChannelsGetSendAsRequest) Encode(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't encode channels.getSendAs#e785a43f as nil")
|
|
}
|
|
b.PutID(ChannelsGetSendAsRequestTypeID)
|
|
return g.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (g *ChannelsGetSendAsRequest) EncodeBare(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't encode channels.getSendAs#e785a43f as nil")
|
|
}
|
|
g.SetFlags()
|
|
if err := g.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channels.getSendAs#e785a43f: field flags: %w", err)
|
|
}
|
|
if g.Peer == nil {
|
|
return fmt.Errorf("unable to encode channels.getSendAs#e785a43f: field peer is nil")
|
|
}
|
|
if err := g.Peer.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channels.getSendAs#e785a43f: field peer: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (g *ChannelsGetSendAsRequest) Decode(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't decode channels.getSendAs#e785a43f to nil")
|
|
}
|
|
if err := b.ConsumeID(ChannelsGetSendAsRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode channels.getSendAs#e785a43f: %w", err)
|
|
}
|
|
return g.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (g *ChannelsGetSendAsRequest) DecodeBare(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't decode channels.getSendAs#e785a43f to nil")
|
|
}
|
|
{
|
|
if err := g.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode channels.getSendAs#e785a43f: field flags: %w", err)
|
|
}
|
|
}
|
|
g.ForPaidReactions = g.Flags.Has(0)
|
|
{
|
|
value, err := DecodeInputPeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channels.getSendAs#e785a43f: field peer: %w", err)
|
|
}
|
|
g.Peer = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetForPaidReactions sets value of ForPaidReactions conditional field.
|
|
func (g *ChannelsGetSendAsRequest) SetForPaidReactions(value bool) {
|
|
if value {
|
|
g.Flags.Set(0)
|
|
g.ForPaidReactions = true
|
|
} else {
|
|
g.Flags.Unset(0)
|
|
g.ForPaidReactions = false
|
|
}
|
|
}
|
|
|
|
// GetForPaidReactions returns value of ForPaidReactions conditional field.
|
|
func (g *ChannelsGetSendAsRequest) GetForPaidReactions() (value bool) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Flags.Has(0)
|
|
}
|
|
|
|
// GetPeer returns value of Peer field.
|
|
func (g *ChannelsGetSendAsRequest) GetPeer() (value InputPeerClass) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Peer
|
|
}
|
|
|
|
// ChannelsGetSendAs invokes method channels.getSendAs#e785a43f returning error if any.
|
|
// Obtains a list of peers that can be used to send messages in a specific group
|
|
//
|
|
// Possible errors:
|
|
//
|
|
// 400 CHANNEL_INVALID: The provided channel is invalid.
|
|
// 400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
|
|
// 400 CHAT_ID_INVALID: The provided chat id is invalid.
|
|
// 400 PEER_ID_INVALID: The provided peer id is invalid.
|
|
//
|
|
// See https://core.telegram.org/method/channels.getSendAs for reference.
|
|
func (c *Client) ChannelsGetSendAs(ctx context.Context, request *ChannelsGetSendAsRequest) (*ChannelsSendAsPeers, error) {
|
|
var result ChannelsSendAsPeers
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|