From 5b00ce4a63132f01f9804fa8bc741e460ed76cf5 Mon Sep 17 00:00:00 2001 From: alina sireneva Date: Sun, 8 Sep 2024 00:11:29 +0300 Subject: [PATCH] feat(core): expose `untilDate` in `banChatMember` --- packages/core/src/highlevel/client.ts | 2 ++ .../core/src/highlevel/methods/chats/ban-chat-member.ts | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/highlevel/client.ts b/packages/core/src/highlevel/client.ts index 4f8950d0..022fd910 100644 --- a/packages/core/src/highlevel/client.ts +++ b/packages/core/src/highlevel/client.ts @@ -1322,6 +1322,8 @@ export interface TelegramClient extends ITelegramClient { /** ID of the user/channel to ban */ participantId: InputPeerLike + untilDate?: number | Date + /** * Whether to dispatch the returned service message (if any) * to the client's update handler. diff --git a/packages/core/src/highlevel/methods/chats/ban-chat-member.ts b/packages/core/src/highlevel/methods/chats/ban-chat-member.ts index 85252af4..d1ddfbc5 100644 --- a/packages/core/src/highlevel/methods/chats/ban-chat-member.ts +++ b/packages/core/src/highlevel/methods/chats/ban-chat-member.ts @@ -1,6 +1,7 @@ import type { ITelegramClient } from '../../client.types.js' import type { InputPeerLike, Message } from '../../types/index.js' import { MtInvalidPeerTypeError } from '../../types/index.js' +import { normalizeDate } from '../../utils/index.js' import { isInputPeerChannel, isInputPeerChat, toInputChannel, toInputUser } from '../../utils/peer-utils.js' import { _findMessageInUpdate } from '../messages/find-in-update.js' import { resolvePeer } from '../users/resolve-peer.js' @@ -24,6 +25,8 @@ export async function banChatMember( /** ID of the user/channel to ban */ participantId: InputPeerLike + untilDate?: number | Date + /** * Whether to dispatch the returned service message (if any) * to the client's update handler. @@ -43,8 +46,7 @@ export async function banChatMember( participant: peer, bannedRights: { _: 'chatBannedRights', - // bans can't be temporary. - untilDate: 0, + untilDate: normalizeDate(params?.untilDate) ?? 0, viewMessages: true, }, })