make it better

This commit is contained in:
Secven 2021-07-13 03:13:27 +00:00
parent a0e3bec882
commit 6b0b4f912c
3 changed files with 6 additions and 7 deletions

View File

@ -16,10 +16,9 @@ config.consignOpts = {
config.limitSecurity = {
window: ms('15s'),
limit: 6,
onLimitExceeded: ({ message, i18n, replyWithHTML }) =>
limit: 5,
onLimitExceeded: ({ message, replyWithHTML }) =>
replyWithHTML('❗Please wait a second (5s)', {
reply_to_message_id: message.message_id,
disable_notification: true
})
}

View File

@ -1,9 +1,9 @@
class EyeofgodTask {
checkLeak = async ({ db, i18n, extra, message, session, replyWithHTML }) => {
try {
let id = (session.eyeof = message.text)
let id = (session.eyeof = Number(message.text))
if (id.includes('eye')) {
if (id.includes('/eye')) {
id = id.split(' ')[1]
}
@ -34,7 +34,7 @@ class EyeofgodTask {
} catch (e) {
console.log(e.message)
return await replyWithHTML(
`🙅‍♂️ No in Database 🆔 <code>${Number(session.eyeof)}</code>`
`🙅‍♂️ No in Database 🆔 <code>${Number(session?.eyeof)}</code>`
)
}
}

View File

@ -33,7 +33,7 @@ const limit = options => {
return (ctx, next) => {
const key = config.keyGenerator(ctx)
if (!key) return next()
if (!key) return next().catch(() => {})
const hit = store.incr(key)
return hit <= config.limit ? next() : config.onLimitExceeded(ctx, next)
}