Files
mautrix-telegram/pkg/gotd/tg/tl_channels_get_participant_gen.go
T
2025-06-27 20:03:37 -07:00

235 lines
6.5 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{}
)
// ChannelsGetParticipantRequest represents TL type `channels.getParticipant#a0ab6cc6`.
// Get info about a channel/supergroup¹ participant
//
// Links:
// 1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/channels.getParticipant for reference.
type ChannelsGetParticipantRequest struct {
// Channel/supergroup
Channel InputChannelClass
// Participant to get info about
Participant InputPeerClass
}
// ChannelsGetParticipantRequestTypeID is TL type id of ChannelsGetParticipantRequest.
const ChannelsGetParticipantRequestTypeID = 0xa0ab6cc6
// Ensuring interfaces in compile-time for ChannelsGetParticipantRequest.
var (
_ bin.Encoder = &ChannelsGetParticipantRequest{}
_ bin.Decoder = &ChannelsGetParticipantRequest{}
_ bin.BareEncoder = &ChannelsGetParticipantRequest{}
_ bin.BareDecoder = &ChannelsGetParticipantRequest{}
)
func (g *ChannelsGetParticipantRequest) Zero() bool {
if g == nil {
return true
}
if !(g.Channel == nil) {
return false
}
if !(g.Participant == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *ChannelsGetParticipantRequest) String() string {
if g == nil {
return "ChannelsGetParticipantRequest(nil)"
}
type Alias ChannelsGetParticipantRequest
return fmt.Sprintf("ChannelsGetParticipantRequest%+v", Alias(*g))
}
// FillFrom fills ChannelsGetParticipantRequest from given interface.
func (g *ChannelsGetParticipantRequest) FillFrom(from interface {
GetChannel() (value InputChannelClass)
GetParticipant() (value InputPeerClass)
}) {
g.Channel = from.GetChannel()
g.Participant = from.GetParticipant()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChannelsGetParticipantRequest) TypeID() uint32 {
return ChannelsGetParticipantRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*ChannelsGetParticipantRequest) TypeName() string {
return "channels.getParticipant"
}
// TypeInfo returns info about TL type.
func (g *ChannelsGetParticipantRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "channels.getParticipant",
ID: ChannelsGetParticipantRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Channel",
SchemaName: "channel",
},
{
Name: "Participant",
SchemaName: "participant",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *ChannelsGetParticipantRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode channels.getParticipant#a0ab6cc6 as nil")
}
b.PutID(ChannelsGetParticipantRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *ChannelsGetParticipantRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode channels.getParticipant#a0ab6cc6 as nil")
}
if g.Channel == nil {
return fmt.Errorf("unable to encode channels.getParticipant#a0ab6cc6: field channel is nil")
}
if err := g.Channel.Encode(b); err != nil {
return fmt.Errorf("unable to encode channels.getParticipant#a0ab6cc6: field channel: %w", err)
}
if g.Participant == nil {
return fmt.Errorf("unable to encode channels.getParticipant#a0ab6cc6: field participant is nil")
}
if err := g.Participant.Encode(b); err != nil {
return fmt.Errorf("unable to encode channels.getParticipant#a0ab6cc6: field participant: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (g *ChannelsGetParticipantRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode channels.getParticipant#a0ab6cc6 to nil")
}
if err := b.ConsumeID(ChannelsGetParticipantRequestTypeID); err != nil {
return fmt.Errorf("unable to decode channels.getParticipant#a0ab6cc6: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *ChannelsGetParticipantRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode channels.getParticipant#a0ab6cc6 to nil")
}
{
value, err := DecodeInputChannel(b)
if err != nil {
return fmt.Errorf("unable to decode channels.getParticipant#a0ab6cc6: field channel: %w", err)
}
g.Channel = value
}
{
value, err := DecodeInputPeer(b)
if err != nil {
return fmt.Errorf("unable to decode channels.getParticipant#a0ab6cc6: field participant: %w", err)
}
g.Participant = value
}
return nil
}
// GetChannel returns value of Channel field.
func (g *ChannelsGetParticipantRequest) GetChannel() (value InputChannelClass) {
if g == nil {
return
}
return g.Channel
}
// GetParticipant returns value of Participant field.
func (g *ChannelsGetParticipantRequest) GetParticipant() (value InputPeerClass) {
if g == nil {
return
}
return g.Participant
}
// GetChannelAsNotEmpty returns mapped value of Channel field.
func (g *ChannelsGetParticipantRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) {
return g.Channel.AsNotEmpty()
}
// ChannelsGetParticipant invokes method channels.getParticipant#a0ab6cc6 returning error if any.
// Get info about a channel/supergroup¹ participant
//
// Links:
// 1. https://core.telegram.org/api/channel
//
// Possible errors:
//
// 400 CHANNEL_INVALID: The provided channel is invalid.
// 406 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
// 403 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
// 400 MSG_ID_INVALID: Invalid message ID provided.
// 400 PARTICIPANT_ID_INVALID: The specified participant ID is invalid.
// 400 USER_ID_INVALID: The provided user ID is invalid.
// 400 USER_NOT_PARTICIPANT: You're not a member of this supergroup/channel.
//
// See https://core.telegram.org/method/channels.getParticipant for reference.
// Can be used by bots.
func (c *Client) ChannelsGetParticipant(ctx context.Context, request *ChannelsGetParticipantRequest) (*ChannelsChannelParticipant, error) {
var result ChannelsChannelParticipant
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}