Initialize deploy/docker-compose
This commit is contained in:
21
src/bot/features/admin.ts
Normal file
21
src/bot/features/admin.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { Context } from '#root/bot/context.js'
|
||||
import { isAdmin } from '#root/bot/filters/is-admin.js'
|
||||
import { setCommandsHandler } from '#root/bot/handlers/commands/setcommands.js'
|
||||
import { logHandle } from '#root/bot/helpers/logging.js'
|
||||
import { chatAction } from '@grammyjs/auto-chat-action'
|
||||
import { Composer } from 'grammy'
|
||||
|
||||
const composer = new Composer<Context>()
|
||||
|
||||
const feature = composer
|
||||
.chatType('private')
|
||||
.filter(isAdmin)
|
||||
|
||||
feature.command(
|
||||
'setcommands',
|
||||
logHandle('command-setcommands'),
|
||||
chatAction('typing'),
|
||||
setCommandsHandler,
|
||||
)
|
||||
|
||||
export { composer as adminFeature }
|
||||
36
src/bot/features/language.ts
Normal file
36
src/bot/features/language.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { Context } from '#root/bot/context.js'
|
||||
import { changeLanguageData } from '#root/bot/callback-data/change-language.js'
|
||||
import { logHandle } from '#root/bot/helpers/logging.js'
|
||||
import { i18n } from '#root/bot/i18n.js'
|
||||
import { createChangeLanguageKeyboard } from '#root/bot/keyboards/change-language.js'
|
||||
import { Composer } from 'grammy'
|
||||
|
||||
const composer = new Composer<Context>()
|
||||
|
||||
const feature = composer.chatType('private')
|
||||
|
||||
feature.command('language', logHandle('command-language'), async (ctx) => {
|
||||
return ctx.reply(ctx.t('language-select'), {
|
||||
reply_markup: await createChangeLanguageKeyboard(ctx),
|
||||
})
|
||||
})
|
||||
|
||||
feature.callbackQuery(
|
||||
changeLanguageData.filter(),
|
||||
logHandle('keyboard-language-select'),
|
||||
async (ctx) => {
|
||||
const { code: languageCode } = changeLanguageData.unpack(
|
||||
ctx.callbackQuery.data,
|
||||
)
|
||||
|
||||
if (i18n.locales.includes(languageCode)) {
|
||||
await ctx.i18n.setLocale(languageCode)
|
||||
|
||||
return ctx.editMessageText(ctx.t('language-changed'), {
|
||||
reply_markup: await createChangeLanguageKeyboard(ctx),
|
||||
})
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export { composer as languageFeature }
|
||||
17
src/bot/features/unhandled.ts
Normal file
17
src/bot/features/unhandled.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { Context } from '#root/bot/context.js'
|
||||
import { logHandle } from '#root/bot/helpers/logging.js'
|
||||
import { Composer } from 'grammy'
|
||||
|
||||
const composer = new Composer<Context>()
|
||||
|
||||
const feature = composer.chatType('private')
|
||||
|
||||
feature.on('message', logHandle('unhandled-message'), (ctx) => {
|
||||
return ctx.reply(ctx.t('unhandled'))
|
||||
})
|
||||
|
||||
feature.on('callback_query', logHandle('unhandled-callback-query'), (ctx) => {
|
||||
return ctx.answerCallbackQuery()
|
||||
})
|
||||
|
||||
export { composer as unhandledFeature }
|
||||
13
src/bot/features/welcome.ts
Normal file
13
src/bot/features/welcome.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { Context } from '#root/bot/context.js'
|
||||
import { logHandle } from '#root/bot/helpers/logging.js'
|
||||
import { Composer } from 'grammy'
|
||||
|
||||
const composer = new Composer<Context>()
|
||||
|
||||
const feature = composer.chatType('private')
|
||||
|
||||
feature.command('start', logHandle('command-start'), (ctx) => {
|
||||
return ctx.reply(ctx.t('welcome'))
|
||||
})
|
||||
|
||||
export { composer as welcomeFeature }
|
||||
Reference in New Issue
Block a user