import { NextFunction } from 'grammy' ; import Context from '@/models/Context' ; const threshold = 5 * 60 ; export default function ignoreOldMessageUpdates ( ctx , next ) { if ( ctx . message ) { if ( new Date ( ) . getTime ( ) / 1000 - ctx . message . date < threshold ) { return next ( ) ; } else { console . log ( `Ignoring message from ${ ctx . from . id } at ${ ctx . chat . id } (${ new Date ( ) . getTime ( ) / 1000 }:${ ctx . message . date })` ) ; } } else { return next ( ) ; } }