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
421 lines
11 KiB
Go
421 lines
11 KiB
Go
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tdapi
|
|
|
|
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{}
|
|
)
|
|
|
|
// EditMessageLiveLocationRequest represents TL type `editMessageLiveLocation#8f511394`.
|
|
type EditMessageLiveLocationRequest struct {
|
|
// The chat the message belongs to
|
|
ChatID int64
|
|
// Identifier of the message. Use messageProperties.can_be_edited to check whether the
|
|
// message can be edited
|
|
MessageID int64
|
|
// The new message reply markup; pass null if none; for bots only
|
|
ReplyMarkup ReplyMarkupClass
|
|
// New location content of the message; pass null to stop sharing the live location
|
|
Location Location
|
|
// New time relative to the message send date, for which the location can be updated, in
|
|
// seconds. If 0x7FFFFFFF specified, then the location can be updated forever.
|
|
LivePeriod int32
|
|
// The new direction in which the location moves, in degrees; 1-360. Pass 0 if unknown
|
|
Heading int32
|
|
// The new maximum distance for proximity alerts, in meters (0-100000). Pass 0 if the
|
|
// notification is disabled
|
|
ProximityAlertRadius int32
|
|
}
|
|
|
|
// EditMessageLiveLocationRequestTypeID is TL type id of EditMessageLiveLocationRequest.
|
|
const EditMessageLiveLocationRequestTypeID = 0x8f511394
|
|
|
|
// Ensuring interfaces in compile-time for EditMessageLiveLocationRequest.
|
|
var (
|
|
_ bin.Encoder = &EditMessageLiveLocationRequest{}
|
|
_ bin.Decoder = &EditMessageLiveLocationRequest{}
|
|
_ bin.BareEncoder = &EditMessageLiveLocationRequest{}
|
|
_ bin.BareDecoder = &EditMessageLiveLocationRequest{}
|
|
)
|
|
|
|
func (e *EditMessageLiveLocationRequest) Zero() bool {
|
|
if e == nil {
|
|
return true
|
|
}
|
|
if !(e.ChatID == 0) {
|
|
return false
|
|
}
|
|
if !(e.MessageID == 0) {
|
|
return false
|
|
}
|
|
if !(e.ReplyMarkup == nil) {
|
|
return false
|
|
}
|
|
if !(e.Location.Zero()) {
|
|
return false
|
|
}
|
|
if !(e.LivePeriod == 0) {
|
|
return false
|
|
}
|
|
if !(e.Heading == 0) {
|
|
return false
|
|
}
|
|
if !(e.ProximityAlertRadius == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (e *EditMessageLiveLocationRequest) String() string {
|
|
if e == nil {
|
|
return "EditMessageLiveLocationRequest(nil)"
|
|
}
|
|
type Alias EditMessageLiveLocationRequest
|
|
return fmt.Sprintf("EditMessageLiveLocationRequest%+v", Alias(*e))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*EditMessageLiveLocationRequest) TypeID() uint32 {
|
|
return EditMessageLiveLocationRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*EditMessageLiveLocationRequest) TypeName() string {
|
|
return "editMessageLiveLocation"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (e *EditMessageLiveLocationRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "editMessageLiveLocation",
|
|
ID: EditMessageLiveLocationRequestTypeID,
|
|
}
|
|
if e == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ChatID",
|
|
SchemaName: "chat_id",
|
|
},
|
|
{
|
|
Name: "MessageID",
|
|
SchemaName: "message_id",
|
|
},
|
|
{
|
|
Name: "ReplyMarkup",
|
|
SchemaName: "reply_markup",
|
|
},
|
|
{
|
|
Name: "Location",
|
|
SchemaName: "location",
|
|
},
|
|
{
|
|
Name: "LivePeriod",
|
|
SchemaName: "live_period",
|
|
},
|
|
{
|
|
Name: "Heading",
|
|
SchemaName: "heading",
|
|
},
|
|
{
|
|
Name: "ProximityAlertRadius",
|
|
SchemaName: "proximity_alert_radius",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (e *EditMessageLiveLocationRequest) Encode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode editMessageLiveLocation#8f511394 as nil")
|
|
}
|
|
b.PutID(EditMessageLiveLocationRequestTypeID)
|
|
return e.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (e *EditMessageLiveLocationRequest) EncodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode editMessageLiveLocation#8f511394 as nil")
|
|
}
|
|
b.PutInt53(e.ChatID)
|
|
b.PutInt53(e.MessageID)
|
|
if e.ReplyMarkup == nil {
|
|
return fmt.Errorf("unable to encode editMessageLiveLocation#8f511394: field reply_markup is nil")
|
|
}
|
|
if err := e.ReplyMarkup.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode editMessageLiveLocation#8f511394: field reply_markup: %w", err)
|
|
}
|
|
if err := e.Location.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode editMessageLiveLocation#8f511394: field location: %w", err)
|
|
}
|
|
b.PutInt32(e.LivePeriod)
|
|
b.PutInt32(e.Heading)
|
|
b.PutInt32(e.ProximityAlertRadius)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (e *EditMessageLiveLocationRequest) Decode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode editMessageLiveLocation#8f511394 to nil")
|
|
}
|
|
if err := b.ConsumeID(EditMessageLiveLocationRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: %w", err)
|
|
}
|
|
return e.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (e *EditMessageLiveLocationRequest) DecodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode editMessageLiveLocation#8f511394 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field chat_id: %w", err)
|
|
}
|
|
e.ChatID = value
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field message_id: %w", err)
|
|
}
|
|
e.MessageID = value
|
|
}
|
|
{
|
|
value, err := DecodeReplyMarkup(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field reply_markup: %w", err)
|
|
}
|
|
e.ReplyMarkup = value
|
|
}
|
|
{
|
|
if err := e.Location.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field location: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field live_period: %w", err)
|
|
}
|
|
e.LivePeriod = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field heading: %w", err)
|
|
}
|
|
e.Heading = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field proximity_alert_radius: %w", err)
|
|
}
|
|
e.ProximityAlertRadius = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (e *EditMessageLiveLocationRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode editMessageLiveLocation#8f511394 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("editMessageLiveLocation")
|
|
b.Comma()
|
|
b.FieldStart("chat_id")
|
|
b.PutInt53(e.ChatID)
|
|
b.Comma()
|
|
b.FieldStart("message_id")
|
|
b.PutInt53(e.MessageID)
|
|
b.Comma()
|
|
b.FieldStart("reply_markup")
|
|
if e.ReplyMarkup == nil {
|
|
return fmt.Errorf("unable to encode editMessageLiveLocation#8f511394: field reply_markup is nil")
|
|
}
|
|
if err := e.ReplyMarkup.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode editMessageLiveLocation#8f511394: field reply_markup: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("location")
|
|
if err := e.Location.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode editMessageLiveLocation#8f511394: field location: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("live_period")
|
|
b.PutInt32(e.LivePeriod)
|
|
b.Comma()
|
|
b.FieldStart("heading")
|
|
b.PutInt32(e.Heading)
|
|
b.Comma()
|
|
b.FieldStart("proximity_alert_radius")
|
|
b.PutInt32(e.ProximityAlertRadius)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (e *EditMessageLiveLocationRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode editMessageLiveLocation#8f511394 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("editMessageLiveLocation"); err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: %w", err)
|
|
}
|
|
case "chat_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field chat_id: %w", err)
|
|
}
|
|
e.ChatID = value
|
|
case "message_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field message_id: %w", err)
|
|
}
|
|
e.MessageID = value
|
|
case "reply_markup":
|
|
value, err := DecodeTDLibJSONReplyMarkup(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field reply_markup: %w", err)
|
|
}
|
|
e.ReplyMarkup = value
|
|
case "location":
|
|
if err := e.Location.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field location: %w", err)
|
|
}
|
|
case "live_period":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field live_period: %w", err)
|
|
}
|
|
e.LivePeriod = value
|
|
case "heading":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field heading: %w", err)
|
|
}
|
|
e.Heading = value
|
|
case "proximity_alert_radius":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode editMessageLiveLocation#8f511394: field proximity_alert_radius: %w", err)
|
|
}
|
|
e.ProximityAlertRadius = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetChatID returns value of ChatID field.
|
|
func (e *EditMessageLiveLocationRequest) GetChatID() (value int64) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.ChatID
|
|
}
|
|
|
|
// GetMessageID returns value of MessageID field.
|
|
func (e *EditMessageLiveLocationRequest) GetMessageID() (value int64) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.MessageID
|
|
}
|
|
|
|
// GetReplyMarkup returns value of ReplyMarkup field.
|
|
func (e *EditMessageLiveLocationRequest) GetReplyMarkup() (value ReplyMarkupClass) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.ReplyMarkup
|
|
}
|
|
|
|
// GetLocation returns value of Location field.
|
|
func (e *EditMessageLiveLocationRequest) GetLocation() (value Location) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.Location
|
|
}
|
|
|
|
// GetLivePeriod returns value of LivePeriod field.
|
|
func (e *EditMessageLiveLocationRequest) GetLivePeriod() (value int32) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.LivePeriod
|
|
}
|
|
|
|
// GetHeading returns value of Heading field.
|
|
func (e *EditMessageLiveLocationRequest) GetHeading() (value int32) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.Heading
|
|
}
|
|
|
|
// GetProximityAlertRadius returns value of ProximityAlertRadius field.
|
|
func (e *EditMessageLiveLocationRequest) GetProximityAlertRadius() (value int32) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.ProximityAlertRadius
|
|
}
|
|
|
|
// EditMessageLiveLocation invokes method editMessageLiveLocation#8f511394 returning error if any.
|
|
func (c *Client) EditMessageLiveLocation(ctx context.Context, request *EditMessageLiveLocationRequest) (*Message, error) {
|
|
var result Message
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|