some improvements
This commit is contained in:
parent
6281946f85
commit
e63870fac6
|
@ -40,15 +40,6 @@ const BALABOLA_INTROS = [0, 24, 25, 11, 6, 8, 9];
|
||||||
|
|
||||||
const spammers = new Map<number, number>();
|
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) => {
|
filter.hear(/^(?:продолжи)\s(.*)?$/i, async (ctx, next) => {
|
||||||
if (ctx.isChat) {
|
if (ctx.isChat) {
|
||||||
ctx.text = `пр 1 ${ctx.$match[1]}`;
|
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 => {
|
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 intro = ctx.$match[1];
|
||||||
const query = ctx.$match[2];
|
const query = ctx.$match[2];
|
||||||
|
|
||||||
await ctx.send('генерирую!!!');
|
await ctx.send('генерирую!!!');
|
||||||
const result = await throttledBalabola(() => balabola(query, BALABOLA_INTROS[+intro - 1]));
|
const result = await throttledBalabola(() => balabola(query, BALABOLA_INTROS[+intro - 1]));
|
||||||
await ctx.send(result);
|
await ctx.reply(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
filter.use(async ctx => {
|
filter.use(async ctx => {
|
||||||
|
@ -74,5 +71,5 @@ filter.use(async ctx => {
|
||||||
|
|
||||||
await ctx.send('генерирую!!');
|
await ctx.send('генерирую!!');
|
||||||
const result = await throttledBalabola(() => balabola(ctx.text!, 0));
|
const result = await throttledBalabola(() => balabola(ctx.text!, 0));
|
||||||
await ctx.send(result);
|
await ctx.reply(result);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue