move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,272 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// MessagesDeleteChatUserRequest represents TL type `messages.deleteChatUser#a2185cab`.
|
||||
// Deletes a user from a chat and sends a service message on it.
|
||||
//
|
||||
// See https://core.telegram.org/method/messages.deleteChatUser for reference.
|
||||
type MessagesDeleteChatUserRequest struct {
|
||||
// Flags, see TL conditional fields¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
||||
Flags bin.Fields
|
||||
// Remove the entire chat history of the specified user in this chat.
|
||||
RevokeHistory bool
|
||||
// Chat ID
|
||||
ChatID int64
|
||||
// User ID to be deleted
|
||||
UserID InputUserClass
|
||||
}
|
||||
|
||||
// MessagesDeleteChatUserRequestTypeID is TL type id of MessagesDeleteChatUserRequest.
|
||||
const MessagesDeleteChatUserRequestTypeID = 0xa2185cab
|
||||
|
||||
// Ensuring interfaces in compile-time for MessagesDeleteChatUserRequest.
|
||||
var (
|
||||
_ bin.Encoder = &MessagesDeleteChatUserRequest{}
|
||||
_ bin.Decoder = &MessagesDeleteChatUserRequest{}
|
||||
_ bin.BareEncoder = &MessagesDeleteChatUserRequest{}
|
||||
_ bin.BareDecoder = &MessagesDeleteChatUserRequest{}
|
||||
)
|
||||
|
||||
func (d *MessagesDeleteChatUserRequest) Zero() bool {
|
||||
if d == nil {
|
||||
return true
|
||||
}
|
||||
if !(d.Flags.Zero()) {
|
||||
return false
|
||||
}
|
||||
if !(d.RevokeHistory == false) {
|
||||
return false
|
||||
}
|
||||
if !(d.ChatID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(d.UserID == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (d *MessagesDeleteChatUserRequest) String() string {
|
||||
if d == nil {
|
||||
return "MessagesDeleteChatUserRequest(nil)"
|
||||
}
|
||||
type Alias MessagesDeleteChatUserRequest
|
||||
return fmt.Sprintf("MessagesDeleteChatUserRequest%+v", Alias(*d))
|
||||
}
|
||||
|
||||
// FillFrom fills MessagesDeleteChatUserRequest from given interface.
|
||||
func (d *MessagesDeleteChatUserRequest) FillFrom(from interface {
|
||||
GetRevokeHistory() (value bool)
|
||||
GetChatID() (value int64)
|
||||
GetUserID() (value InputUserClass)
|
||||
}) {
|
||||
d.RevokeHistory = from.GetRevokeHistory()
|
||||
d.ChatID = from.GetChatID()
|
||||
d.UserID = from.GetUserID()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*MessagesDeleteChatUserRequest) TypeID() uint32 {
|
||||
return MessagesDeleteChatUserRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*MessagesDeleteChatUserRequest) TypeName() string {
|
||||
return "messages.deleteChatUser"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (d *MessagesDeleteChatUserRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "messages.deleteChatUser",
|
||||
ID: MessagesDeleteChatUserRequestTypeID,
|
||||
}
|
||||
if d == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "RevokeHistory",
|
||||
SchemaName: "revoke_history",
|
||||
Null: !d.Flags.Has(0),
|
||||
},
|
||||
{
|
||||
Name: "ChatID",
|
||||
SchemaName: "chat_id",
|
||||
},
|
||||
{
|
||||
Name: "UserID",
|
||||
SchemaName: "user_id",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// SetFlags sets flags for non-zero fields.
|
||||
func (d *MessagesDeleteChatUserRequest) SetFlags() {
|
||||
if !(d.RevokeHistory == false) {
|
||||
d.Flags.Set(0)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (d *MessagesDeleteChatUserRequest) Encode(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't encode messages.deleteChatUser#a2185cab as nil")
|
||||
}
|
||||
b.PutID(MessagesDeleteChatUserRequestTypeID)
|
||||
return d.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (d *MessagesDeleteChatUserRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't encode messages.deleteChatUser#a2185cab as nil")
|
||||
}
|
||||
d.SetFlags()
|
||||
if err := d.Flags.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode messages.deleteChatUser#a2185cab: field flags: %w", err)
|
||||
}
|
||||
b.PutLong(d.ChatID)
|
||||
if d.UserID == nil {
|
||||
return fmt.Errorf("unable to encode messages.deleteChatUser#a2185cab: field user_id is nil")
|
||||
}
|
||||
if err := d.UserID.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode messages.deleteChatUser#a2185cab: field user_id: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (d *MessagesDeleteChatUserRequest) Decode(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't decode messages.deleteChatUser#a2185cab to nil")
|
||||
}
|
||||
if err := b.ConsumeID(MessagesDeleteChatUserRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode messages.deleteChatUser#a2185cab: %w", err)
|
||||
}
|
||||
return d.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (d *MessagesDeleteChatUserRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't decode messages.deleteChatUser#a2185cab to nil")
|
||||
}
|
||||
{
|
||||
if err := d.Flags.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode messages.deleteChatUser#a2185cab: field flags: %w", err)
|
||||
}
|
||||
}
|
||||
d.RevokeHistory = d.Flags.Has(0)
|
||||
{
|
||||
value, err := b.Long()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode messages.deleteChatUser#a2185cab: field chat_id: %w", err)
|
||||
}
|
||||
d.ChatID = value
|
||||
}
|
||||
{
|
||||
value, err := DecodeInputUser(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode messages.deleteChatUser#a2185cab: field user_id: %w", err)
|
||||
}
|
||||
d.UserID = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetRevokeHistory sets value of RevokeHistory conditional field.
|
||||
func (d *MessagesDeleteChatUserRequest) SetRevokeHistory(value bool) {
|
||||
if value {
|
||||
d.Flags.Set(0)
|
||||
d.RevokeHistory = true
|
||||
} else {
|
||||
d.Flags.Unset(0)
|
||||
d.RevokeHistory = false
|
||||
}
|
||||
}
|
||||
|
||||
// GetRevokeHistory returns value of RevokeHistory conditional field.
|
||||
func (d *MessagesDeleteChatUserRequest) GetRevokeHistory() (value bool) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.Flags.Has(0)
|
||||
}
|
||||
|
||||
// GetChatID returns value of ChatID field.
|
||||
func (d *MessagesDeleteChatUserRequest) GetChatID() (value int64) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.ChatID
|
||||
}
|
||||
|
||||
// GetUserID returns value of UserID field.
|
||||
func (d *MessagesDeleteChatUserRequest) GetUserID() (value InputUserClass) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.UserID
|
||||
}
|
||||
|
||||
// MessagesDeleteChatUser invokes method messages.deleteChatUser#a2185cab returning error if any.
|
||||
// Deletes a user from a chat and sends a service message on it.
|
||||
//
|
||||
// Possible errors:
|
||||
//
|
||||
// 400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
|
||||
// 400 CHAT_ID_INVALID: The provided chat id is invalid.
|
||||
// 400 PEER_ID_INVALID: The provided peer 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/messages.deleteChatUser for reference.
|
||||
// Can be used by bots.
|
||||
func (c *Client) MessagesDeleteChatUser(ctx context.Context, request *MessagesDeleteChatUserRequest) (UpdatesClass, error) {
|
||||
var result UpdatesBox
|
||||
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Updates, nil
|
||||
}
|
||||
Reference in New Issue
Block a user