some improvements

This commit is contained in:
Timofey Gelazoniya 2022-10-21 10:22:22 +03:00
parent 6281946f85
commit e63870fac6
Signed by: zeldon
GPG Key ID: 047886915281DD2A

View File

@ -40,15 +40,6 @@ const BALABOLA_INTROS = [0, 24, 25, 11, 6, 8, 9];
const spammers = new Map<number, number>();
filter.use((ctx, next) => {
if (spammers.has(ctx.senderId) && spammers.get(ctx.senderId)! > Date.now()) {
return ctx.reply('отказ', { disable_mentions: true });
}
spammers.set(ctx.senderId, Date.now() + 5000);
return next();
});
filter.hear(/^(?:продолжи)\s(.*)?$/i, async (ctx, next) => {
if (ctx.isChat) {
ctx.text = `пр 1 ${ctx.$match[1]}`;
@ -61,12 +52,18 @@ filter.hear(/^(?:продолжи)\s(.*)?$/i, async (ctx, next) => {
});
filter.hear(/^(?:пр)\s(1|2|3|4|5|6|7)\s(.*)?$/i, async ctx => {
if (spammers.has(ctx.senderId) && spammers.get(ctx.senderId)! > Date.now()) {
return ctx.reply('отказ', { disable_mentions: true });
}
spammers.set(ctx.senderId, Date.now() + 5000);
const intro = ctx.$match[1];
const query = ctx.$match[2];
await ctx.send('генерирую!!!');
const result = await throttledBalabola(() => balabola(query, BALABOLA_INTROS[+intro - 1]));
await ctx.send(result);
await ctx.reply(result);
});
filter.use(async ctx => {
@ -74,5 +71,5 @@ filter.use(async ctx => {
await ctx.send('генерирую!!');
const result = await throttledBalabola(() => balabola(ctx.text!, 0));
await ctx.send(result);
await ctx.reply(result);
});