Skip to content

Commit

Permalink
2c71df59aea7b59cb554703b202493d6fb760904
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 28, 2024
1 parent fbffc66 commit a78a957
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 12 deletions.
10 changes: 10 additions & 0 deletions esm/client/0_params.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,13 @@ export interface GetCreatedInviteLinksParams {
export interface StopPollParams {
replyMarkup?: ReplyMarkup;
}
export interface EditMessageLiveLocationParams {
/** The accuracy radius of the location in meters. Must be in the range of 0-1500. */
horizontalAccuracy?: number;
/** The direction which the user is moving towards. Must be in the range of 1-350. */
heading?: number;
/** The maximum distance for proximity alerts on approaching another chat member in meters. Must be in the range 1-100,000. */
proximityAlertRadius?: number;
/** The reply markup of the message. Bot-only. */
replyMarkup?: ReplyMarkup;
}
4 changes: 3 additions & 1 deletion esm/client/2_message_manager.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { enums, types } from "../2_tl.js";
import { ChatAction, ChatMember, FileSource, FileType, ID, Message, MessageEntity, ParseMode, Reaction, Update, UsernameResolver } from "../3_types.js";
import { AddReactionParams, BanChatMemberParams, CreateInviteLinkParams, DeleteMessagesParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetCreatedInviteLinksParams, GetHistoryParams, PinMessageParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetReactionsParams, StopPollParams } from "./0_params.js";
import { AddReactionParams, BanChatMemberParams, CreateInviteLinkParams, DeleteMessagesParams, EditMessageLiveLocationParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetCreatedInviteLinksParams, GetHistoryParams, PinMessageParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetReactionsParams, StopPollParams } from "./0_params.js";
import { C as C_ } from "./0_types.js";
import { FileManager } from "./1_file_manager.js";
interface C extends C_ {
Expand Down Expand Up @@ -79,5 +79,7 @@ export declare class MessageManager {
setChatStickerSet(chatId: ID, setName: string): Promise<void>;
deleteChatStickerSet(chatId: ID): Promise<void>;
stopPoll(chatId: ID, messageId: number, params?: StopPollParams): Promise<import("../3_types.js").Poll>;
editMessageLiveLocation(chatId: ID, messageId: number, latitude: number, longitude: number, params?: EditMessageLiveLocationParams): Promise<import("../3_types.js").MessageLocation>;
editInlineMessageLiveLocation(inlineMessageId: string, latitude: number, longitude: number, params?: EditMessageLiveLocationParams): Promise<void>;
}
export {};
39 changes: 39 additions & 0 deletions esm/client/2_message_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,45 @@ export class MessageManager {
}
UNREACHABLE();
}
async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
const message = await this.getMessage(chatId, messageId);
if (message && "location" in message && message.location.livePeriod) {
const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editMessage({
peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
id: messageId,
media: new types.InputMediaGeoLive({
geo_point: new types.InputGeoPoint({
lat: latitude,
long: longitude,
accuracy_radius: params?.horizontalAccuracy,
}),
heading: params?.heading,
proximity_notification_radius: params?.proximityAlertRadius,
}),
reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
});
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
return assertMessageType(message, "location");
}
UNREACHABLE();
}
async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageLiveLocation");
const id = deserializeInlineMessageId(inlineMessageId);
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editInlineBotMessage({
id,
media: new types.InputMediaGeoLive({
geo_point: new types.InputGeoPoint({
lat: latitude,
long: longitude,
accuracy_radius: params?.horizontalAccuracy,
}),
heading: params?.heading,
proximity_notification_radius: params?.proximityAlertRadius,
}),
reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
});
}
}
_MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates) {
const messages = new Array();
Expand Down
31 changes: 28 additions & 3 deletions esm/client/4_client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Storage } from "../3_storage.js";
import { DC } from "../3_transport.js";
import { BotCommand, Chat, ChatAction, ChatMember, ChatP, FileSource, ID, InactiveChat, InlineQueryResult, InputStoryContent, InviteLink, Message, MessageAnimation, MessageAudio, MessageContact, MessageDice, MessageDocument, MessageLocation, MessagePhoto, MessagePoll, MessageSticker, MessageText, MessageVenue, MessageVideo, MessageVideoNote, MessageVoice, NetworkStatistics, ParseMode, Poll, Reaction, Sticker, Story, Update, User } from "../3_types.js";
import { Migrate } from "../4_errors.js";
import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, BanChatMemberParams, CreateInviteLinkParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetCreatedInviteLinksParams, GetHistoryParams, GetMyCommandsParams, PinMessageParams, ReplyParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, StopPollParams, UploadParams } from "./0_params.js";
import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, BanChatMemberParams, CreateInviteLinkParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadParams, EditMessageLiveLocationParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetCreatedInviteLinksParams, GetHistoryParams, GetMyCommandsParams, PinMessageParams, ReplyParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, StopPollParams, UploadParams } from "./0_params.js";
import { Api } from "./0_types.js";
import { ClientPlainParams } from "./1_client_plain.js";
import { Composer as Composer_, NextFunction } from "./1_composer.js";
Expand Down Expand Up @@ -73,10 +73,14 @@ export interface Context {
}) => Promise<void>;
/** Context-aware alias for `client.editInlineMessageText()`. */
editInlineMessageText: (text: string, params?: EditMessageParams) => Promise<void>;
/** Context-aware alias for `client.editInlineMessageLiveLocation()`. */
editInlineMessageLiveLocation: (latitude: number, longitude: number, params?: EditMessageLiveLocationParams) => Promise<void>;
/** Context-aware alias for `client.editInlineMessageReplyMarkup()`. */
editInlineMessageReplyMarkup: (params?: EditMessageReplyMarkupParams) => Promise<void>;
/** Context-aware alias for `client.editMessageText()`. */
editMessageText: (messageId: number, text: string, params?: EditMessageParams) => Promise<MessageText>;
/** Context-aware alias for `client.editMessageLiveLocation()`. */
editMessageLiveLocation: (messageId: number, latitude: number, longitude: number, params?: EditMessageLiveLocationParams) => Promise<MessageLocation>;
/** Context-aware alias for `client.editMessageReplyMarkup()`. */
editMessageReplyMarkup: (messageId: number, params?: EditMessageReplyMarkupParams) => Promise<Message>;
/** Context-aware alias for `client.answerCallbackQuery()`. */
Expand Down Expand Up @@ -303,7 +307,7 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
* Edit a message's text.
*
* @method ms
* @param chatId The identifier of the chat that contains the messages.
* @param chatId The identifier of the chat that contains the message.
* @param messageId The message's identifier.
* @param text The new text of the message.
* @returns The edited text message.
Expand All @@ -321,7 +325,7 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
* Edit a message's reply markup.
*
* @method ms
* @param chatId The identifier of the chat that contains the messages.
* @param chatId The identifier of the chat that contains the message.
* @param messageId The message's identifier.
* @returns The edited message.
*/
Expand All @@ -333,6 +337,27 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
* @param inlineMessageId The inline message's identifier.
*/
editInlineMessageReplyMarkup(inlineMessageId: string, params?: EditMessageReplyMarkupParams): Promise<void>;
/**
* Edit a message's live location.
*
* @method ms
* @param chatId The identifier of the chat that contains the messages.
* @param messageId The message's identifier.
* @param latitude The new latitude.
* @param longitude The new longitude.
* @returns The edited location message.
*/
editMessageLiveLocation(chatId: ID, messageId: number, latitude: number, longitude: number, params?: EditMessageLiveLocationParams): Promise<MessageLocation>;
/**
* Edit an inline message's live location. Bot-only.
*
* @method ms
* @param inlineMessageId The inline message's identifier.
* @param latitude The new latitude.
* @param longitude The new longitude.
* @returns The edited location message.
*/
editInlineMessageLiveLocation(inlineMessageId: string, latitude: number, longitude: number, params?: EditMessageLiveLocationParams): Promise<void>;
/**
* Retrieve multiple messages.
*
Expand Down
37 changes: 35 additions & 2 deletions esm/client/4_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ export class Client extends Composer {
const inlineMessageId = mustGetInlineMsgId();
return this.editInlineMessageText(inlineMessageId, text, params);
},
editInlineMessageLiveLocation: (latitude, longitude, params) => {
const inlineMessageId = mustGetInlineMsgId();
return this.editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
},
editInlineMessageReplyMarkup: (params) => {
const inlineMessageId = mustGetInlineMsgId();
return this.editInlineMessageReplyMarkup(inlineMessageId, params);
Expand All @@ -400,6 +404,10 @@ export class Client extends Composer {
const { chatId } = mustGetMsg();
return this.editMessageText(chatId, messageId, text, params);
},
editMessageLiveLocation: (messageId, latitude, longitude, params) => {
const { chatId } = mustGetMsg();
return this.editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
},
editMessageReplyMarkup: (messageId, params) => {
const { chatId } = mustGetMsg();
return this.editMessageReplyMarkup(chatId, messageId, params);
Expand Down Expand Up @@ -1247,7 +1255,7 @@ export class Client extends Composer {
* Edit a message's text.
*
* @method ms
* @param chatId The identifier of the chat that contains the messages.
* @param chatId The identifier of the chat that contains the message.
* @param messageId The message's identifier.
* @param text The new text of the message.
* @returns The edited text message.
Expand All @@ -1269,7 +1277,7 @@ export class Client extends Composer {
* Edit a message's reply markup.
*
* @method ms
* @param chatId The identifier of the chat that contains the messages.
* @param chatId The identifier of the chat that contains the message.
* @param messageId The message's identifier.
* @returns The edited message.
*/
Expand All @@ -1285,6 +1293,31 @@ export class Client extends Composer {
async editInlineMessageReplyMarkup(inlineMessageId, params) {
await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageReplyMarkup(inlineMessageId, params);
}
/**
* Edit a message's live location.
*
* @method ms
* @param chatId The identifier of the chat that contains the messages.
* @param messageId The message's identifier.
* @param latitude The new latitude.
* @param longitude The new longitude.
* @returns The edited location message.
*/
async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
}
/**
* Edit an inline message's live location. Bot-only.
*
* @method ms
* @param inlineMessageId The inline message's identifier.
* @param latitude The new latitude.
* @param longitude The new longitude.
* @returns The edited location message.
*/
async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
}
/**
* Retrieve multiple messages.
*
Expand Down
10 changes: 10 additions & 0 deletions script/client/0_params.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,13 @@ export interface GetCreatedInviteLinksParams {
export interface StopPollParams {
replyMarkup?: ReplyMarkup;
}
export interface EditMessageLiveLocationParams {
/** The accuracy radius of the location in meters. Must be in the range of 0-1500. */
horizontalAccuracy?: number;
/** The direction which the user is moving towards. Must be in the range of 1-350. */
heading?: number;
/** The maximum distance for proximity alerts on approaching another chat member in meters. Must be in the range 1-100,000. */
proximityAlertRadius?: number;
/** The reply markup of the message. Bot-only. */
replyMarkup?: ReplyMarkup;
}
4 changes: 3 additions & 1 deletion script/client/2_message_manager.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { enums, types } from "../2_tl.js";
import { ChatAction, ChatMember, FileSource, FileType, ID, Message, MessageEntity, ParseMode, Reaction, Update, UsernameResolver } from "../3_types.js";
import { AddReactionParams, BanChatMemberParams, CreateInviteLinkParams, DeleteMessagesParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetCreatedInviteLinksParams, GetHistoryParams, PinMessageParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetReactionsParams, StopPollParams } from "./0_params.js";
import { AddReactionParams, BanChatMemberParams, CreateInviteLinkParams, DeleteMessagesParams, EditMessageLiveLocationParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetCreatedInviteLinksParams, GetHistoryParams, PinMessageParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetReactionsParams, StopPollParams } from "./0_params.js";
import { C as C_ } from "./0_types.js";
import { FileManager } from "./1_file_manager.js";
interface C extends C_ {
Expand Down Expand Up @@ -79,5 +79,7 @@ export declare class MessageManager {
setChatStickerSet(chatId: ID, setName: string): Promise<void>;
deleteChatStickerSet(chatId: ID): Promise<void>;
stopPoll(chatId: ID, messageId: number, params?: StopPollParams): Promise<import("../3_types.js").Poll>;
editMessageLiveLocation(chatId: ID, messageId: number, latitude: number, longitude: number, params?: EditMessageLiveLocationParams): Promise<import("../3_types.js").MessageLocation>;
editInlineMessageLiveLocation(inlineMessageId: string, latitude: number, longitude: number, params?: EditMessageLiveLocationParams): Promise<void>;
}
export {};
Loading

0 comments on commit a78a957

Please sign in to comment.