2023-09-23 18:49:05 +00:00
|
|
|
import { generationQueue } from "../app/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
|
2023-09-22 23:40:21 +00:00
|
|
|
.filter((job) => job.lockUntil < new Date())
|
2023-09-22 02:59:22 +00:00
|
|
|
.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`);
|
|
|
|
}
|