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
255 lines
6.5 KiB
Go
Generated
255 lines
6.5 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{}
|
|
)
|
|
|
|
// MessagesEditFactCheckRequest represents TL type `messages.editFactCheck#589ee75`.
|
|
// Edit/create a fact-check¹ on a message.
|
|
// Can only be used by independent fact-checkers as specified by the appConfig
|
|
// can_edit_factcheck¹ configuration flag.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/factcheck
|
|
// 2. https://core.telegram.org/api/config#can-edit-factcheck
|
|
//
|
|
// See https://core.telegram.org/method/messages.editFactCheck for reference.
|
|
type MessagesEditFactCheckRequest struct {
|
|
// Peer where the message was sent
|
|
Peer InputPeerClass
|
|
// Message ID
|
|
MsgID int
|
|
// Fact-check (maximum UTF-8 length specified in appConfig.factcheck_length_limit¹).
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/config#factcheck-length-limit
|
|
Text TextWithEntities
|
|
}
|
|
|
|
// MessagesEditFactCheckRequestTypeID is TL type id of MessagesEditFactCheckRequest.
|
|
const MessagesEditFactCheckRequestTypeID = 0x589ee75
|
|
|
|
// Ensuring interfaces in compile-time for MessagesEditFactCheckRequest.
|
|
var (
|
|
_ bin.Encoder = &MessagesEditFactCheckRequest{}
|
|
_ bin.Decoder = &MessagesEditFactCheckRequest{}
|
|
_ bin.BareEncoder = &MessagesEditFactCheckRequest{}
|
|
_ bin.BareDecoder = &MessagesEditFactCheckRequest{}
|
|
)
|
|
|
|
func (e *MessagesEditFactCheckRequest) Zero() bool {
|
|
if e == nil {
|
|
return true
|
|
}
|
|
if !(e.Peer == nil) {
|
|
return false
|
|
}
|
|
if !(e.MsgID == 0) {
|
|
return false
|
|
}
|
|
if !(e.Text.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (e *MessagesEditFactCheckRequest) String() string {
|
|
if e == nil {
|
|
return "MessagesEditFactCheckRequest(nil)"
|
|
}
|
|
type Alias MessagesEditFactCheckRequest
|
|
return fmt.Sprintf("MessagesEditFactCheckRequest%+v", Alias(*e))
|
|
}
|
|
|
|
// FillFrom fills MessagesEditFactCheckRequest from given interface.
|
|
func (e *MessagesEditFactCheckRequest) FillFrom(from interface {
|
|
GetPeer() (value InputPeerClass)
|
|
GetMsgID() (value int)
|
|
GetText() (value TextWithEntities)
|
|
}) {
|
|
e.Peer = from.GetPeer()
|
|
e.MsgID = from.GetMsgID()
|
|
e.Text = from.GetText()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*MessagesEditFactCheckRequest) TypeID() uint32 {
|
|
return MessagesEditFactCheckRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*MessagesEditFactCheckRequest) TypeName() string {
|
|
return "messages.editFactCheck"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (e *MessagesEditFactCheckRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "messages.editFactCheck",
|
|
ID: MessagesEditFactCheckRequestTypeID,
|
|
}
|
|
if e == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Peer",
|
|
SchemaName: "peer",
|
|
},
|
|
{
|
|
Name: "MsgID",
|
|
SchemaName: "msg_id",
|
|
},
|
|
{
|
|
Name: "Text",
|
|
SchemaName: "text",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (e *MessagesEditFactCheckRequest) Encode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode messages.editFactCheck#589ee75 as nil")
|
|
}
|
|
b.PutID(MessagesEditFactCheckRequestTypeID)
|
|
return e.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (e *MessagesEditFactCheckRequest) EncodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode messages.editFactCheck#589ee75 as nil")
|
|
}
|
|
if e.Peer == nil {
|
|
return fmt.Errorf("unable to encode messages.editFactCheck#589ee75: field peer is nil")
|
|
}
|
|
if err := e.Peer.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messages.editFactCheck#589ee75: field peer: %w", err)
|
|
}
|
|
b.PutInt(e.MsgID)
|
|
if err := e.Text.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messages.editFactCheck#589ee75: field text: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (e *MessagesEditFactCheckRequest) Decode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode messages.editFactCheck#589ee75 to nil")
|
|
}
|
|
if err := b.ConsumeID(MessagesEditFactCheckRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode messages.editFactCheck#589ee75: %w", err)
|
|
}
|
|
return e.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (e *MessagesEditFactCheckRequest) DecodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode messages.editFactCheck#589ee75 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeInputPeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messages.editFactCheck#589ee75: field peer: %w", err)
|
|
}
|
|
e.Peer = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messages.editFactCheck#589ee75: field msg_id: %w", err)
|
|
}
|
|
e.MsgID = value
|
|
}
|
|
{
|
|
if err := e.Text.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode messages.editFactCheck#589ee75: field text: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetPeer returns value of Peer field.
|
|
func (e *MessagesEditFactCheckRequest) GetPeer() (value InputPeerClass) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.Peer
|
|
}
|
|
|
|
// GetMsgID returns value of MsgID field.
|
|
func (e *MessagesEditFactCheckRequest) GetMsgID() (value int) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.MsgID
|
|
}
|
|
|
|
// GetText returns value of Text field.
|
|
func (e *MessagesEditFactCheckRequest) GetText() (value TextWithEntities) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.Text
|
|
}
|
|
|
|
// MessagesEditFactCheck invokes method messages.editFactCheck#589ee75 returning error if any.
|
|
// Edit/create a fact-check¹ on a message.
|
|
// Can only be used by independent fact-checkers as specified by the appConfig
|
|
// can_edit_factcheck¹ configuration flag.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/factcheck
|
|
// 2. https://core.telegram.org/api/config#can-edit-factcheck
|
|
//
|
|
// Possible errors:
|
|
//
|
|
// 403 CHAT_ACTION_FORBIDDEN: You cannot execute this action.
|
|
// 400 PEER_ID_INVALID: The provided peer id is invalid.
|
|
//
|
|
// See https://core.telegram.org/method/messages.editFactCheck for reference.
|
|
func (c *Client) MessagesEditFactCheck(ctx context.Context, request *MessagesEditFactCheckRequest) (UpdatesClass, error) {
|
|
var result UpdatesBox
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return result.Updates, nil
|
|
}
|