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
252 lines
6.3 KiB
Go
252 lines
6.3 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{}
|
|
)
|
|
|
|
// ChannelsToggleForumRequest represents TL type `channels.toggleForum#3ff75734`.
|
|
// Enable or disable forum functionality¹ in a supergroup.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/forum
|
|
//
|
|
// See https://core.telegram.org/method/channels.toggleForum for reference.
|
|
type ChannelsToggleForumRequest struct {
|
|
// Supergroup ID
|
|
Channel InputChannelClass
|
|
// Enable or disable forum functionality
|
|
Enabled bool
|
|
// Tabs field of ChannelsToggleForumRequest.
|
|
Tabs bool
|
|
}
|
|
|
|
// ChannelsToggleForumRequestTypeID is TL type id of ChannelsToggleForumRequest.
|
|
const ChannelsToggleForumRequestTypeID = 0x3ff75734
|
|
|
|
// Ensuring interfaces in compile-time for ChannelsToggleForumRequest.
|
|
var (
|
|
_ bin.Encoder = &ChannelsToggleForumRequest{}
|
|
_ bin.Decoder = &ChannelsToggleForumRequest{}
|
|
_ bin.BareEncoder = &ChannelsToggleForumRequest{}
|
|
_ bin.BareDecoder = &ChannelsToggleForumRequest{}
|
|
)
|
|
|
|
func (t *ChannelsToggleForumRequest) Zero() bool {
|
|
if t == nil {
|
|
return true
|
|
}
|
|
if !(t.Channel == nil) {
|
|
return false
|
|
}
|
|
if !(t.Enabled == false) {
|
|
return false
|
|
}
|
|
if !(t.Tabs == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (t *ChannelsToggleForumRequest) String() string {
|
|
if t == nil {
|
|
return "ChannelsToggleForumRequest(nil)"
|
|
}
|
|
type Alias ChannelsToggleForumRequest
|
|
return fmt.Sprintf("ChannelsToggleForumRequest%+v", Alias(*t))
|
|
}
|
|
|
|
// FillFrom fills ChannelsToggleForumRequest from given interface.
|
|
func (t *ChannelsToggleForumRequest) FillFrom(from interface {
|
|
GetChannel() (value InputChannelClass)
|
|
GetEnabled() (value bool)
|
|
GetTabs() (value bool)
|
|
}) {
|
|
t.Channel = from.GetChannel()
|
|
t.Enabled = from.GetEnabled()
|
|
t.Tabs = from.GetTabs()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChannelsToggleForumRequest) TypeID() uint32 {
|
|
return ChannelsToggleForumRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChannelsToggleForumRequest) TypeName() string {
|
|
return "channels.toggleForum"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (t *ChannelsToggleForumRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "channels.toggleForum",
|
|
ID: ChannelsToggleForumRequestTypeID,
|
|
}
|
|
if t == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Channel",
|
|
SchemaName: "channel",
|
|
},
|
|
{
|
|
Name: "Enabled",
|
|
SchemaName: "enabled",
|
|
},
|
|
{
|
|
Name: "Tabs",
|
|
SchemaName: "tabs",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (t *ChannelsToggleForumRequest) Encode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode channels.toggleForum#3ff75734 as nil")
|
|
}
|
|
b.PutID(ChannelsToggleForumRequestTypeID)
|
|
return t.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (t *ChannelsToggleForumRequest) EncodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't encode channels.toggleForum#3ff75734 as nil")
|
|
}
|
|
if t.Channel == nil {
|
|
return fmt.Errorf("unable to encode channels.toggleForum#3ff75734: field channel is nil")
|
|
}
|
|
if err := t.Channel.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode channels.toggleForum#3ff75734: field channel: %w", err)
|
|
}
|
|
b.PutBool(t.Enabled)
|
|
b.PutBool(t.Tabs)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (t *ChannelsToggleForumRequest) Decode(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode channels.toggleForum#3ff75734 to nil")
|
|
}
|
|
if err := b.ConsumeID(ChannelsToggleForumRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode channels.toggleForum#3ff75734: %w", err)
|
|
}
|
|
return t.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (t *ChannelsToggleForumRequest) DecodeBare(b *bin.Buffer) error {
|
|
if t == nil {
|
|
return fmt.Errorf("can't decode channels.toggleForum#3ff75734 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeInputChannel(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channels.toggleForum#3ff75734: field channel: %w", err)
|
|
}
|
|
t.Channel = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channels.toggleForum#3ff75734: field enabled: %w", err)
|
|
}
|
|
t.Enabled = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode channels.toggleForum#3ff75734: field tabs: %w", err)
|
|
}
|
|
t.Tabs = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetChannel returns value of Channel field.
|
|
func (t *ChannelsToggleForumRequest) GetChannel() (value InputChannelClass) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.Channel
|
|
}
|
|
|
|
// GetEnabled returns value of Enabled field.
|
|
func (t *ChannelsToggleForumRequest) GetEnabled() (value bool) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.Enabled
|
|
}
|
|
|
|
// GetTabs returns value of Tabs field.
|
|
func (t *ChannelsToggleForumRequest) GetTabs() (value bool) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
return t.Tabs
|
|
}
|
|
|
|
// GetChannelAsNotEmpty returns mapped value of Channel field.
|
|
func (t *ChannelsToggleForumRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) {
|
|
return t.Channel.AsNotEmpty()
|
|
}
|
|
|
|
// ChannelsToggleForum invokes method channels.toggleForum#3ff75734 returning error if any.
|
|
// Enable or disable forum functionality¹ in a supergroup.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/forum
|
|
//
|
|
// Possible errors:
|
|
//
|
|
// 400 CHANNEL_INVALID: The provided channel is invalid.
|
|
// 400 CHAT_DISCUSSION_UNALLOWED: You can't enable forum topics in a discussion group linked to a channel.
|
|
// 400 CHAT_NOT_MODIFIED: No changes were made to chat information because the new information you passed is identical to the current information.
|
|
//
|
|
// See https://core.telegram.org/method/channels.toggleForum for reference.
|
|
func (c *Client) ChannelsToggleForum(ctx context.Context, request *ChannelsToggleForumRequest) (UpdatesClass, error) {
|
|
var result UpdatesBox
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return result.Updates, nil
|
|
}
|