-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
402 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
- package-ecosystem: npm | ||
directory: / | ||
schedule: | ||
interval: 'daily' | ||
interval: daily |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { createCallbackData } from "callback-data"; | ||
import { createCallbackData } from 'callback-data' | ||
|
||
export const changeLanguageData = createCallbackData("language", { | ||
export const changeLanguageData = createCallbackData('language', { | ||
code: String, | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./change-language.js"; | ||
export * from './change-language.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
import { Update, UserFromGetMe } from "@grammyjs/types"; | ||
import { Context as DefaultContext, SessionFlavor, type Api } from "grammy"; | ||
import type { AutoChatActionFlavor } from "@grammyjs/auto-chat-action"; | ||
import type { HydrateFlavor } from "@grammyjs/hydrate"; | ||
import type { I18nFlavor } from "@grammyjs/i18n"; | ||
import type { ParseModeFlavor } from "@grammyjs/parse-mode"; | ||
import type { Logger } from "#root/logger.js"; | ||
import type { Update, UserFromGetMe } from '@grammyjs/types' | ||
import { type Api, Context as DefaultContext, type SessionFlavor } from 'grammy' | ||
import type { AutoChatActionFlavor } from '@grammyjs/auto-chat-action' | ||
import type { HydrateFlavor } from '@grammyjs/hydrate' | ||
import type { I18nFlavor } from '@grammyjs/i18n' | ||
import type { ParseModeFlavor } from '@grammyjs/parse-mode' | ||
import type { Logger } from '#root/logger.js' | ||
|
||
export type SessionData = { | ||
export interface SessionData { | ||
// field?: string; | ||
}; | ||
} | ||
|
||
type ExtendedContextFlavor = { | ||
logger: Logger; | ||
}; | ||
interface ExtendedContextFlavor { | ||
logger: Logger | ||
} | ||
|
||
export type Context = ParseModeFlavor< | ||
HydrateFlavor< | ||
DefaultContext & | ||
ExtendedContextFlavor & | ||
SessionFlavor<SessionData> & | ||
I18nFlavor & | ||
AutoChatActionFlavor | ||
ExtendedContextFlavor & | ||
SessionFlavor<SessionData> & | ||
I18nFlavor & | ||
AutoChatActionFlavor | ||
> | ||
>; | ||
> | ||
|
||
interface Dependencies { | ||
logger: Logger; | ||
logger: Logger | ||
} | ||
|
||
export function createContextConstructor({ logger }: Dependencies) { | ||
return class extends DefaultContext implements ExtendedContextFlavor { | ||
logger: Logger; | ||
logger: Logger | ||
|
||
constructor(update: Update, api: Api, me: UserFromGetMe) { | ||
super(update, api, me); | ||
super(update, api, me) | ||
|
||
this.logger = logger.child({ | ||
update_id: this.update.update_id, | ||
}); | ||
}) | ||
} | ||
} as unknown as new (update: Update, api: Api, me: UserFromGetMe) => Context; | ||
} as unknown as new (update: Update, api: Api, me: UserFromGetMe) => Context | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { chatAction } from "@grammyjs/auto-chat-action"; | ||
import { Composer } from "grammy"; | ||
import type { Context } from "#root/bot/context.js"; | ||
import { isAdmin } from "#root/bot/filters/index.js"; | ||
import { setCommandsHandler } from "#root/bot/handlers/index.js"; | ||
import { logHandle } from "#root/bot/helpers/logging.js"; | ||
import { chatAction } from '@grammyjs/auto-chat-action' | ||
import { Composer } from 'grammy' | ||
import type { Context } from '#root/bot/context.js' | ||
import { isAdmin } from '#root/bot/filters/index.js' | ||
import { setCommandsHandler } from '#root/bot/handlers/index.js' | ||
import { logHandle } from '#root/bot/helpers/logging.js' | ||
|
||
const composer = new Composer<Context>(); | ||
const composer = new Composer<Context>() | ||
|
||
const feature = composer.chatType("private").filter(isAdmin); | ||
const feature = composer.chatType('private').filter(isAdmin) | ||
|
||
feature.command( | ||
"setcommands", | ||
logHandle("command-setcommands"), | ||
chatAction("typing"), | ||
'setcommands', | ||
logHandle('command-setcommands'), | ||
chatAction('typing'), | ||
setCommandsHandler, | ||
); | ||
) | ||
|
||
export { composer as adminFeature }; | ||
export { composer as adminFeature } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from "./admin.js"; | ||
export * from "./language.js"; | ||
export * from "./unhandled.js"; | ||
export * from "./welcome.js"; | ||
export * from './admin.js' | ||
export * from './language.js' | ||
export * from './unhandled.js' | ||
export * from './welcome.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
import { Composer } from "grammy"; | ||
import { changeLanguageData } from "#root/bot/callback-data/index.js"; | ||
import type { Context } from "#root/bot/context.js"; | ||
import { logHandle } from "#root/bot/helpers/logging.js"; | ||
import { i18n } from "#root/bot/i18n.js"; | ||
import { createChangeLanguageKeyboard } from "#root/bot/keyboards/index.js"; | ||
import { Composer } from 'grammy' | ||
import { changeLanguageData } from '#root/bot/callback-data/index.js' | ||
import type { Context } from '#root/bot/context.js' | ||
import { logHandle } from '#root/bot/helpers/logging.js' | ||
import { i18n } from '#root/bot/i18n.js' | ||
import { createChangeLanguageKeyboard } from '#root/bot/keyboards/index.js' | ||
|
||
const composer = new Composer<Context>(); | ||
const composer = new Composer<Context>() | ||
|
||
const feature = composer.chatType("private"); | ||
const feature = composer.chatType('private') | ||
|
||
feature.command("language", logHandle("command-language"), async (ctx) => { | ||
return ctx.reply(ctx.t("language.select"), { | ||
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"), | ||
logHandle('keyboard-language-select'), | ||
async (ctx) => { | ||
const { code: languageCode } = changeLanguageData.unpack( | ||
ctx.callbackQuery.data, | ||
); | ||
) | ||
|
||
if (i18n.locales.includes(languageCode)) { | ||
await ctx.i18n.setLocale(languageCode); | ||
await ctx.i18n.setLocale(languageCode) | ||
|
||
return ctx.editMessageText(ctx.t("language.changed"), { | ||
return ctx.editMessageText(ctx.t('language.changed'), { | ||
reply_markup: await createChangeLanguageKeyboard(ctx), | ||
}); | ||
}) | ||
} | ||
}, | ||
); | ||
) | ||
|
||
export { composer as languageFeature }; | ||
export { composer as languageFeature } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { Composer } from "grammy"; | ||
import type { Context } from "#root/bot/context.js"; | ||
import { logHandle } from "#root/bot/helpers/logging.js"; | ||
import { Composer } from 'grammy' | ||
import type { Context } from '#root/bot/context.js' | ||
import { logHandle } from '#root/bot/helpers/logging.js' | ||
|
||
const composer = new Composer<Context>(); | ||
const composer = new Composer<Context>() | ||
|
||
const feature = composer.chatType("private"); | ||
const feature = composer.chatType('private') | ||
|
||
feature.on("message", logHandle("unhandled-message"), (ctx) => { | ||
return ctx.reply(ctx.t("unhandled")); | ||
}); | ||
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(); | ||
}); | ||
feature.on('callback_query', logHandle('unhandled-callback-query'), (ctx) => { | ||
return ctx.answerCallbackQuery() | ||
}) | ||
|
||
export { composer as unhandledFeature }; | ||
export { composer as unhandledFeature } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { Composer } from "grammy"; | ||
import type { Context } from "#root/bot/context.js"; | ||
import { logHandle } from "#root/bot/helpers/logging.js"; | ||
import { Composer } from 'grammy' | ||
import type { Context } from '#root/bot/context.js' | ||
import { logHandle } from '#root/bot/helpers/logging.js' | ||
|
||
const composer = new Composer<Context>(); | ||
const composer = new Composer<Context>() | ||
|
||
const feature = composer.chatType("private"); | ||
const feature = composer.chatType('private') | ||
|
||
feature.command("start", logHandle("command-start"), (ctx) => { | ||
return ctx.reply(ctx.t("welcome")); | ||
}); | ||
feature.command('start', logHandle('command-start'), (ctx) => { | ||
return ctx.reply(ctx.t('welcome')) | ||
}) | ||
|
||
export { composer as welcomeFeature }; | ||
export { composer as welcomeFeature } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./is-admin.js"; | ||
export * from './is-admin.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { isUserHasId } from "grammy-guard"; | ||
import { config } from "#root/config.js"; | ||
import { isUserHasId } from 'grammy-guard' | ||
import { config } from '#root/config.js' | ||
|
||
export const isAdmin = isUserHasId(...config.BOT_ADMINS); | ||
export const isAdmin = isUserHasId(...config.BOT_ADMINS) |
Oops, something went wrong.