Skip to content

Commit

Permalink
f19eb61368088e360e2fcd53d71b6c8a136da798
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 27, 2024
1 parent 4e8a325 commit fbffc66
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 6 deletions.
3 changes: 3 additions & 0 deletions esm/client/0_params.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,6 @@ export interface GetCreatedInviteLinksParams {
afterDate?: Date;
afterInviteLink?: string;
}
export interface StopPollParams {
replyMarkup?: ReplyMarkup;
}
3 changes: 2 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 } from "./0_params.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 { C as C_ } from "./0_types.js";
import { FileManager } from "./1_file_manager.js";
interface C extends C_ {
Expand Down Expand Up @@ -78,5 +78,6 @@ export declare class MessageManager {
getChatMember(chatId: ID, userId: ID): Promise<ChatMember>;
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>;
}
export {};
21 changes: 21 additions & 0 deletions esm/client/2_message_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,27 @@ export class MessageManager {
const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.setStickers({ channel, stickerset: new types.InputStickerSetEmpty() });
}
async stopPoll(chatId, messageId, params) {
const message = await this.getMessage(chatId, messageId);
if (message && "poll" in message && !message.poll.isClosed) {
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.InputMediaPoll({
poll: new types.Poll({
id: BigInt(message.poll.id),
closed: true,
question: "",
answers: [],
}),
}),
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_, "poll").poll;
}
UNREACHABLE();
}
}
_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
13 changes: 11 additions & 2 deletions esm/client/4_client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { MaybePromise } from "../1_utilities.js";
import { enums, functions, types } from "../2_tl.js";
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, Reaction, Sticker, Story, Update, User } from "../3_types.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, UploadParams } from "./0_params.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 { 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 @@ -413,6 +413,15 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
* @returns The sent poll.
*/
sendPoll(chatId: ID, question: string, options: [string, string, ...string[]], params?: SendPollParams): Promise<MessagePoll>;
/**
* Stop a poll.
*
* @method ms
* @param chatId The chat that includes the poll.
* @param messageId The idenfifier of the poll's message.
* @returns The new state of the poll.
*/
stopPoll(chatId: ID, messageId: number, params?: StopPollParams): Promise<Poll>;
/**
* Send a chat action.
*
Expand Down
11 changes: 11 additions & 0 deletions esm/client/4_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,17 @@ export class Client extends Composer {
async sendPoll(chatId, question, options, params) {
return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPoll(chatId, question, options, params);
}
/**
* Stop a poll.
*
* @method ms
* @param chatId The chat that includes the poll.
* @param messageId The idenfifier of the poll's message.
* @returns The new state of the poll.
*/
async stopPoll(chatId, messageId, params) {
return await __classPrivateFieldGet(this, _Client_messageManager, "f").stopPoll(chatId, messageId, params);
}
/**
* Send a chat action.
*
Expand Down
3 changes: 3 additions & 0 deletions script/client/0_params.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,6 @@ export interface GetCreatedInviteLinksParams {
afterDate?: Date;
afterInviteLink?: string;
}
export interface StopPollParams {
replyMarkup?: ReplyMarkup;
}
3 changes: 2 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 } from "./0_params.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 { C as C_ } from "./0_types.js";
import { FileManager } from "./1_file_manager.js";
interface C extends C_ {
Expand Down Expand Up @@ -78,5 +78,6 @@ export declare class MessageManager {
getChatMember(chatId: ID, userId: ID): Promise<ChatMember>;
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>;
}
export {};
21 changes: 21 additions & 0 deletions script/client/2_message_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,27 @@ class MessageManager {
const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.setStickers({ channel, stickerset: new _2_tl_js_1.types.InputStickerSetEmpty() });
}
async stopPoll(chatId, messageId, params) {
const message = await this.getMessage(chatId, messageId);
if (message && "poll" in message && !message.poll.isClosed) {
const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editMessage({
peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
id: messageId,
media: new _2_tl_js_1.types.InputMediaPoll({
poll: new _2_tl_js_1.types.Poll({
id: BigInt(message.poll.id),
closed: true,
question: "",
answers: [],
}),
}),
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 (0, _3_types_js_2.assertMessageType)(message_, "poll").poll;
}
(0, _1_utilities_js_1.UNREACHABLE)();
}
}
exports.MessageManager = MessageManager;
_MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates) {
Expand Down
13 changes: 11 additions & 2 deletions script/client/4_client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { MaybePromise } from "../1_utilities.js";
import { enums, functions, types } from "../2_tl.js";
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, Reaction, Sticker, Story, Update, User } from "../3_types.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, UploadParams } from "./0_params.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 { 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 @@ -413,6 +413,15 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
* @returns The sent poll.
*/
sendPoll(chatId: ID, question: string, options: [string, string, ...string[]], params?: SendPollParams): Promise<MessagePoll>;
/**
* Stop a poll.
*
* @method ms
* @param chatId The chat that includes the poll.
* @param messageId The idenfifier of the poll's message.
* @returns The new state of the poll.
*/
stopPoll(chatId: ID, messageId: number, params?: StopPollParams): Promise<Poll>;
/**
* Send a chat action.
*
Expand Down
11 changes: 11 additions & 0 deletions script/client/4_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,17 @@ class Client extends Composer {
async sendPoll(chatId, question, options, params) {
return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPoll(chatId, question, options, params);
}
/**
* Stop a poll.
*
* @method ms
* @param chatId The chat that includes the poll.
* @param messageId The idenfifier of the poll's message.
* @returns The new state of the poll.
*/
async stopPoll(chatId, messageId, params) {
return await __classPrivateFieldGet(this, _Client_messageManager, "f").stopPoll(chatId, messageId, params);
}
/**
* Send a chat action.
*
Expand Down

0 comments on commit fbffc66

Please sign in to comment.