Initial commit

This commit is contained in:
2023-09-08 22:09:35 +03:00
commit 2a6488488e
20 changed files with 2581 additions and 0 deletions

View File

@ -0,0 +1,15 @@
import { Context } from "#root/context.js";
import { logger } from "#root/logger.js";
import { Middleware } from "grammy";
export function ignoreOld(threshold = 5 * 60): Middleware<Context> {
return async (ctx, next) => {
if (ctx.message?.date && new Date().getTime() / 1000 - ctx.message.date > threshold) {
logger.warn(`Ignoring message from user ${ctx.from?.id} at chat ${ctx.chat?.id} (${new Date().getTime() / 1000
}:${ctx.message.date})`);
return;
}
return next();
};
}