Skip to content

Commit

Permalink
fix: add fallback callback queries handler
Browse files Browse the repository at this point in the history
  • Loading branch information
evermake committed Apr 14, 2024
1 parent 518a118 commit 2ca8b3b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions backend/src/bot/handlers/fallback-callback-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Composer } from 'grammy'
import type { Ctx } from '~/bot/context'

const composer = new Composer<Ctx>()

composer.on('callback_query:data', async (ctx) => {
await ctx.answerCallbackQuery({
text: ctx.t['Alerts.ButtonOutdated'],
show_alert: true,
cache_time: 60 * 5,
})
})

export default composer
3 changes: 3 additions & 0 deletions backend/src/bot/handlers/root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import commands from './commands'
import views from './views'
import fallbackCallbackQueryHandler from './fallback-callback-query'
import { handler } from '.'
import { TelegramNotLinkedToInnohassleAccountError } from '~/domain/errors'
import { InnohassleLoginButton } from '~/bot/login-button'
Expand Down Expand Up @@ -38,4 +39,6 @@ export default handler((composer) => {
composer.use(commands.menu)
composer.use(commands.help)
composer.use(commands.howgoodami)

composer.use(fallbackCallbackQueryHandler)
})
2 changes: 2 additions & 0 deletions backend/src/translations/_en.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export default {
'Bot.About': 'I help Innopolis University students to track their sports progress, check-in for training classes and export personal calendar.',
'Bot.Bio': 'Easy sports management for Innopolis University students.\n\ngithub.com/one-zero-eight/sport-bot',

'Alerts.ButtonOutdated': '😬 This button doesn\'t work anymore. Most likely because we have released a new version of the bot. Try another way.',

'Messages.WelcomeUnauthorized': (
<>
<b>Welcome to IU Sport Bot! 💪</b>
Expand Down
2 changes: 2 additions & 0 deletions backend/src/translations/_ru.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export default {
'Bot.About': 'Я помогаю студентам Иннополиса следить за прогрессом по спорту и записываться на занятия в пару кликов, а ещё показываю личный календарь со всеми занятиями.',
'Bot.Bio': 'Помогаю закрывать спорт студентам Иннополиса.\n\ngithub.com/one-zero-eight/sport-bot',

'Alerts.ButtonOutdated': '😬 Кнопка больше не работает. Скорее всего, потому что мы обновили бота. Попробуй по-другому.',

'Messages.WelcomeUnauthorized': (
<>
<b>Привет, я IU Sport бот! 💪</b>
Expand Down

0 comments on commit 2ca8b3b

Please sign in to comment.