From bd9c98ca7e3a6e5bf83f700ab202943873a5441b Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 14 Mar 2024 09:20:32 +0200 Subject: Implement Slack commands --- src/instagram_task.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/instagram_task.ts') diff --git a/src/instagram_task.ts b/src/instagram_task.ts index 6ab9838..7ca0c77 100644 --- a/src/instagram_task.ts +++ b/src/instagram_task.ts @@ -1,8 +1,13 @@ -import puppeteer, { Browser, Page, TimeoutError } from "puppeteer"; -import { InstagramTask, addTask } from "./tasks"; import fs from "fs"; +import puppeteer, { TimeoutError } from "puppeteer"; import { wait } from "./utils"; +export interface InstagramTask { + type: "download_instagram"; + url: string; + respondWithFile: (message: string, filePath: string) => Promise; +} + export const runDownloadInstagramTask = async (task: InstagramTask) => { const browser = await puppeteer.launch({ headless: false, @@ -117,12 +122,7 @@ export const runDownloadInstagramTask = async (task: InstagramTask) => { const downloadedFile = downloadedFiles[0]; - addTask({ - type: "slack_reply", - replyId: task.replyId, - message: "Here's the video you requested", - filePath: `./downloads/${downloadedFile}`, - }); + await task.respondWithFile("🗿🗿🗿", `./downloads/${downloadedFile}`); } finally { await page.close(); await browser.close(); -- cgit v1.3