improved logging
This commit is contained in:
parent
0084abc4b8
commit
af1c0253bf
@ -44,7 +44,6 @@ const captchaPassed = async (ctx: Ctx, db: Kysely<Database>, cfg: BotConfig) =>
|
|||||||
ctx.chatId, ctx.session.captcha_data.message_id
|
ctx.chatId, ctx.session.captcha_data.message_id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ctx.session.captcha_data = undefined
|
|
||||||
|
|
||||||
const linkValidUntil = new Date()
|
const linkValidUntil = new Date()
|
||||||
linkValidUntil.setHours(linkValidUntil.getHours() + 12)
|
linkValidUntil.setHours(linkValidUntil.getHours() + 12)
|
||||||
@ -65,9 +64,9 @@ const captchaPassed = async (ctx: Ctx, db: Kysely<Database>, cfg: BotConfig) =>
|
|||||||
}).execute()
|
}).execute()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ctx.session.captcha_data = undefined
|
||||||
await ctx.reply(ctx.t("captcha-passed",
|
await ctx.reply(ctx.t("captcha-passed",
|
||||||
{ invite_link: link.invite_link }))
|
{ invite_link: link.invite_link }))
|
||||||
ctx.session.captcha_data = undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,16 +35,25 @@ export const init = (bot: Bot<Ctx>, db: Kysely<Database>, cfg: CompiledConfig) =
|
|||||||
const { botCfg } = cfg
|
const { botCfg } = cfg
|
||||||
|
|
||||||
bot.on('message', async (ctx, next) => {
|
bot.on('message', async (ctx, next) => {
|
||||||
if (ctx.from?.is_bot) return
|
if (!ctx.from || ctx.from.is_bot) return
|
||||||
console.log(`Chat ID: ${ctx.msg.chat.id} From: ${ctx.from.id} Message: ${ctx.msg.text}`)
|
|
||||||
|
console.log('=======================================')
|
||||||
|
console.log(`New message: CID: ${ctx.msg.chat.id} `+
|
||||||
|
`From: ${ctx.from.first_name} ${ctx.from.last_name} `+
|
||||||
|
`UID: ${ctx.from.id} Locale: ${ctx.from.language_code}`)
|
||||||
|
console.log(ctx.msg.text)
|
||||||
|
console.log()
|
||||||
ctx.i18n.useLocale(ctx.from.language_code || DEFAULT_LOCALE)
|
ctx.i18n.useLocale(ctx.from.language_code || DEFAULT_LOCALE)
|
||||||
await next()
|
await next()
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.on('message:text', async (ctx, next) => {
|
bot.on('message:text', async (ctx, next) => {
|
||||||
if (ctx.chat.id === botCfg.chat_id) {
|
if (ctx.chat.id === botCfg.chat_id) {
|
||||||
await checkUser(ctx, db, botCfg, true)
|
console.log("Message was sent into the mic chat")
|
||||||
|
const userInfo = await checkUser(ctx, db, botCfg, true)
|
||||||
|
console.log("User Info: ", userInfo)
|
||||||
} else if (ctx.message.chat.type == "private" && ctx.session.captcha_data) {
|
} else if (ctx.message.chat.type == "private" && ctx.session.captcha_data) {
|
||||||
|
console.log("Handling message as captcha solution")
|
||||||
await checkCaptchaSolution(ctx, db, botCfg)
|
await checkCaptchaSolution(ctx, db, botCfg)
|
||||||
} else {
|
} else {
|
||||||
await next()
|
await next()
|
||||||
@ -53,6 +62,7 @@ export const init = (bot: Bot<Ctx>, db: Kysely<Database>, cfg: CompiledConfig) =
|
|||||||
|
|
||||||
bot.command('start', async ctx => {
|
bot.command('start', async ctx => {
|
||||||
const userInfo = await checkUserOnStart(ctx, db)
|
const userInfo = await checkUserOnStart(ctx, db)
|
||||||
|
console.log("User clicked start. User Info: ", userInfo)
|
||||||
if (userInfo.isBlocked || userInfo.isTimeout) return
|
if (userInfo.isBlocked || userInfo.isTimeout) return
|
||||||
// TODO: if (userInfo.isNewUser) { /* Some hello message? */ }
|
// TODO: if (userInfo.isNewUser) { /* Some hello message? */ }
|
||||||
await initUserCaptcha(ctx, db, userInfo, botCfg)
|
await initUserCaptcha(ctx, db, userInfo, botCfg)
|
||||||
|
Loading…
Reference in New Issue
Block a user