small changes
This commit is contained in:
parent
6b0d7b7198
commit
4d69b87b97
|
@ -15,7 +15,6 @@ export async function queueCommand(ctx: Grammy.CommandContext<Context>) {
|
||||||
const waitingJobs = await jobStore.getBy("status.type", "waiting")
|
const waitingJobs = await jobStore.getBy("status.type", "waiting")
|
||||||
.then((jobs) => jobs.map((job, index) => ({ ...job.value, place: index + 1 })));
|
.then((jobs) => jobs.map((job, index) => ({ ...job.value, place: index + 1 })));
|
||||||
const jobs = [...processingJobs, ...waitingJobs];
|
const jobs = [...processingJobs, ...waitingJobs];
|
||||||
const config = ctx.session.global;
|
|
||||||
const { bold } = GrammyParseMode;
|
const { bold } = GrammyParseMode;
|
||||||
return fmt([
|
return fmt([
|
||||||
"Current queue:\n",
|
"Current queue:\n",
|
||||||
|
@ -40,7 +39,7 @@ export async function queueCommand(ctx: Grammy.CommandContext<Context>) {
|
||||||
])
|
])
|
||||||
: ["Queue is empty.\n"],
|
: ["Queue is empty.\n"],
|
||||||
"\nActive workers:\n",
|
"\nActive workers:\n",
|
||||||
...config.workers.flatMap((worker) => [
|
...ctx.session.global.workers.flatMap((worker) => [
|
||||||
runningWorkers.has(worker.name) ? "✅ " : "☠️ ",
|
runningWorkers.has(worker.name) ? "✅ " : "☠️ ",
|
||||||
fmt`${bold(worker.name)} `,
|
fmt`${bold(worker.name)} `,
|
||||||
`(max ${(worker.maxResolution / 1000000).toFixed(1)} Mpx) `,
|
`(max ${(worker.maxResolution / 1000000).toFixed(1)} Mpx) `,
|
||||||
|
|
|
@ -22,24 +22,23 @@ async function txt2img(ctx: Context, match: string, includeRepliedTo: boolean):
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = ctx.session.global;
|
if (ctx.session.global.pausedReason != null) {
|
||||||
if (config.pausedReason != null) {
|
await ctx.reply(`I'm paused: ${ctx.session.global.pausedReason || "No reason given"}`);
|
||||||
await ctx.reply(`I'm paused: ${config.pausedReason || "No reason given"}`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const jobs = await jobStore.getBy("status.type", "waiting");
|
const jobs = await jobStore.getBy("status.type", "waiting");
|
||||||
if (jobs.length >= config.maxJobs) {
|
if (jobs.length >= ctx.session.global.maxJobs) {
|
||||||
await ctx.reply(
|
await ctx.reply(
|
||||||
`The queue is full. Try again later. (Max queue size: ${config.maxJobs})`,
|
`The queue is full. Try again later. (Max queue size: ${ctx.session.global.maxJobs})`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userJobs = jobs.filter((job) => job.value.request.from.id === ctx.message?.from?.id);
|
const userJobs = jobs.filter((job) => job.value.request.from.id === ctx.message?.from?.id);
|
||||||
if (userJobs.length >= config.maxUserJobs) {
|
if (userJobs.length >= ctx.session.global.maxUserJobs) {
|
||||||
await ctx.reply(
|
await ctx.reply(
|
||||||
`You already have ${config.maxUserJobs} jobs in queue. Try again later.`,
|
`You already have ${ctx.session.global.maxUserJobs} jobs in queue. Try again later.`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
6
utils.ts
6
utils.ts
|
@ -105,7 +105,7 @@ const languageToFlagMap: Record<string, string> = {
|
||||||
"lb": "🇱🇺", // Luxembourgish - Luxembourg
|
"lb": "🇱🇺", // Luxembourgish - Luxembourg
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getFlagEmoji(countryCode?: string): string | undefined {
|
export function getFlagEmoji(languageCode?: string): string | undefined {
|
||||||
if (!countryCode) return;
|
if (!languageCode) return;
|
||||||
return languageToFlagMap[countryCode];
|
return languageToFlagMap[languageCode];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue