From a8ef19d811b05d85e82015e81817db83b60271e2 Mon Sep 17 00:00:00 2001 From: Aleksei Pudnikov Date: Mon, 15 Jul 2024 20:13:27 +0200 Subject: [PATCH] animated gifs --- src/bot/conversations/admin.ts | 10 +++++++--- src/bot/features/send/send.ts | 10 ++++------ src/bot/features/welcome.ts | 7 +++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/bot/conversations/admin.ts b/src/bot/conversations/admin.ts index 5a5ae4a..38ea1e2 100644 --- a/src/bot/conversations/admin.ts +++ b/src/bot/conversations/admin.ts @@ -7,10 +7,14 @@ export const ADMIN_CONVERSATION = 'approve'; export function adminConversation(channelId: string) { return createConversation( async (conversation: Conversation, ctx: Context) => { - const fileId = ctx.callbackQuery?.message?.photo?.pop()?.file_id; + const animation = ctx.callbackQuery?.message?.animation?.file_id; + const photo = ctx.callbackQuery?.message?.photo?.pop()?.file_id; + const media = photo || animation; - if (fileId) { - await ctx.api.sendPhoto(channelId, fileId); + if (animation) await ctx.api.sendAnimation(channelId, animation); + if (photo) await ctx.api.sendPhoto(channelId, photo); + + if (media) { await ctx.api.unpinChatMessage(`${ctx.chat?.id}`); await ctx.editMessageReplyMarkup({ reply_markup: { inline_keyboard: [] } }); } diff --git a/src/bot/features/send/send.ts b/src/bot/features/send/send.ts index f2ad5e8..b779c99 100644 --- a/src/bot/features/send/send.ts +++ b/src/bot/features/send/send.ts @@ -20,11 +20,9 @@ export async function sendPhoto(ctx: Context, fileId: string, other?: Other { } }); +feature.on('message:animation', async (ctx) => { + const fileId = ctx.message.animation.file_id; + if (fileId) { + await sendPhoto(ctx, fileId); + } +}); + feature.command(SEND_CONVERSATION, logHandle('command-send'), (ctx) => { return ctx.conversation.enter(SEND_CONVERSATION); });