2023-09-22 02:59:22 +00:00
|
|
|
import { generationQueue } from "../tasks/generationQueue.ts";
|
2023-09-18 15:51:19 +00:00
|
|
|
import { Context } from "./mod.ts";
|
|
|
|
|
|
|
|
export async function cancelCommand(ctx: Context) {
|
2023-09-22 02:59:22 +00:00
|
|
|
const jobs = await generationQueue.getAllJobs();
|
|
|
|
const userJobs = jobs
|
|
|
|
.filter((job) => job.lockUntil > new Date())
|
|
|
|
.filter((j) => j.state.from.id === ctx.from?.id);
|
|
|
|
for (const job of userJobs) await generationQueue.deleteJob(job.id);
|
2023-09-18 15:51:19 +00:00
|
|
|
await ctx.reply(`Cancelled ${userJobs.length} jobs`);
|
|
|
|
}
|