225 lines
5.8 KiB
Go
Generated
225 lines
5.8 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{}
|
|
)
|
|
|
|
// MessagesSetChatThemeRequest represents TL type `messages.setChatTheme#81202c9`.
|
|
// Change the chat theme of a certain chat, see here »¹ for more info.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/themes#chat-themes
|
|
//
|
|
// See https://core.telegram.org/method/messages.setChatTheme for reference.
|
|
type MessagesSetChatThemeRequest struct {
|
|
// Private chat where to change theme
|
|
Peer InputPeerClass
|
|
// The theme to set.
|
|
Theme InputChatThemeClass
|
|
}
|
|
|
|
// MessagesSetChatThemeRequestTypeID is TL type id of MessagesSetChatThemeRequest.
|
|
const MessagesSetChatThemeRequestTypeID = 0x81202c9
|
|
|
|
// Ensuring interfaces in compile-time for MessagesSetChatThemeRequest.
|
|
var (
|
|
_ bin.Encoder = &MessagesSetChatThemeRequest{}
|
|
_ bin.Decoder = &MessagesSetChatThemeRequest{}
|
|
_ bin.BareEncoder = &MessagesSetChatThemeRequest{}
|
|
_ bin.BareDecoder = &MessagesSetChatThemeRequest{}
|
|
)
|
|
|
|
func (s *MessagesSetChatThemeRequest) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
if !(s.Peer == nil) {
|
|
return false
|
|
}
|
|
if !(s.Theme == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *MessagesSetChatThemeRequest) String() string {
|
|
if s == nil {
|
|
return "MessagesSetChatThemeRequest(nil)"
|
|
}
|
|
type Alias MessagesSetChatThemeRequest
|
|
return fmt.Sprintf("MessagesSetChatThemeRequest%+v", Alias(*s))
|
|
}
|
|
|
|
// FillFrom fills MessagesSetChatThemeRequest from given interface.
|
|
func (s *MessagesSetChatThemeRequest) FillFrom(from interface {
|
|
GetPeer() (value InputPeerClass)
|
|
GetTheme() (value InputChatThemeClass)
|
|
}) {
|
|
s.Peer = from.GetPeer()
|
|
s.Theme = from.GetTheme()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*MessagesSetChatThemeRequest) TypeID() uint32 {
|
|
return MessagesSetChatThemeRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*MessagesSetChatThemeRequest) TypeName() string {
|
|
return "messages.setChatTheme"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *MessagesSetChatThemeRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "messages.setChatTheme",
|
|
ID: MessagesSetChatThemeRequestTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Peer",
|
|
SchemaName: "peer",
|
|
},
|
|
{
|
|
Name: "Theme",
|
|
SchemaName: "theme",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *MessagesSetChatThemeRequest) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode messages.setChatTheme#81202c9 as nil")
|
|
}
|
|
b.PutID(MessagesSetChatThemeRequestTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *MessagesSetChatThemeRequest) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode messages.setChatTheme#81202c9 as nil")
|
|
}
|
|
if s.Peer == nil {
|
|
return fmt.Errorf("unable to encode messages.setChatTheme#81202c9: field peer is nil")
|
|
}
|
|
if err := s.Peer.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messages.setChatTheme#81202c9: field peer: %w", err)
|
|
}
|
|
if s.Theme == nil {
|
|
return fmt.Errorf("unable to encode messages.setChatTheme#81202c9: field theme is nil")
|
|
}
|
|
if err := s.Theme.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messages.setChatTheme#81202c9: field theme: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *MessagesSetChatThemeRequest) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode messages.setChatTheme#81202c9 to nil")
|
|
}
|
|
if err := b.ConsumeID(MessagesSetChatThemeRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode messages.setChatTheme#81202c9: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *MessagesSetChatThemeRequest) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode messages.setChatTheme#81202c9 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeInputPeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messages.setChatTheme#81202c9: field peer: %w", err)
|
|
}
|
|
s.Peer = value
|
|
}
|
|
{
|
|
value, err := DecodeInputChatTheme(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messages.setChatTheme#81202c9: field theme: %w", err)
|
|
}
|
|
s.Theme = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetPeer returns value of Peer field.
|
|
func (s *MessagesSetChatThemeRequest) GetPeer() (value InputPeerClass) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Peer
|
|
}
|
|
|
|
// GetTheme returns value of Theme field.
|
|
func (s *MessagesSetChatThemeRequest) GetTheme() (value InputChatThemeClass) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Theme
|
|
}
|
|
|
|
// MessagesSetChatTheme invokes method messages.setChatTheme#81202c9 returning error if any.
|
|
// Change the chat theme of a certain chat, see here »¹ for more info.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/themes#chat-themes
|
|
//
|
|
// Possible errors:
|
|
//
|
|
// 400 EMOJI_INVALID: The specified theme emoji is valid.
|
|
// 400 EMOJI_NOT_MODIFIED: The theme wasn't changed.
|
|
// 400 PEER_ID_INVALID: The provided peer id is invalid.
|
|
//
|
|
// See https://core.telegram.org/method/messages.setChatTheme for reference.
|
|
func (c *Client) MessagesSetChatTheme(ctx context.Context, request *MessagesSetChatThemeRequest) (UpdatesClass, error) {
|
|
var result UpdatesBox
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return result.Updates, nil
|
|
}
|