Skip to content

Commit

Permalink
hotfix: ctx.command stopped working. migrating to ctx.userCommand fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
armand1m committed Mar 12, 2024
1 parent cfa03f9 commit 20fa860
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"pino-pretty": "^9.3.0",
"sharp": "^0.33.2",
"svg-captcha": "^1.4.0",
"telegraf": "^4.11.2",
"telegraf": "^4.16.3",
"telegram-format": "^2.1.0",
"tslib": "^2.1.0",
"yup": "^0.32.9"
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deregisterMemberFrom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const cmdDeregisterMemberFrom: MiddlewareFn<
> = async (ctx) => {
const i18n = ctx.i18n;
const unsafeCountryName = markdown
.escape(ctx.command.args ?? '')
.escape(ctx.userCommand.args ?? '')
.trim();

if (!unsafeCountryName) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/findMembersAt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const cmdFindMembersAt: MiddlewareFn<BotContext> = async (
) => {
const i18n = ctx.i18n;
const unsafeCountryName = markdown
.escape(ctx.command.args ?? '')
.escape(ctx.userCommand.args ?? '')
.trim();

if (!unsafeCountryName) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getContentUrl = (section?: string, topic?: string) => {

export const cmdHelp: Middleware<BotContext> = async (ctx) => {
const [section, topic] = markdown
.escape(ctx.command.args ?? '')
.escape(ctx.userCommand.args ?? '')
.trim()
.split(' ');

Expand Down
2 changes: 1 addition & 1 deletion src/commands/pingMembersAt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const cmdPingMembersAt: MiddlewareFn<BotContext> = async (
) => {
const i18n = ctx.i18n;
const unsafeCountryName = markdown
.escape(ctx.command.args ?? '')
.escape(ctx.userCommand.args ?? '')
.trim();

if (unsafeCountryName.toLowerCase() === 'remote') {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/rankCountryRemoteMemberCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const cmdRankCountryRemoteMemberCount: MiddlewareFn<
const i18n = ctx.i18n;

const unsafeBaseCountryCode = markdown
.escape(ctx.command.args ?? '')
.escape(ctx.userCommand.args ?? '')
.trim();

if (!unsafeBaseCountryCode) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/registerMemberAt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const cmdRegisterMemberAt: MiddlewareFn<BotContext> = async (
) => {
const i18n = ctx.i18n;
const unsafeCountryName = markdown
.escape(ctx.command.args ?? '')
.escape(ctx.userCommand.args ?? '')
.trim();

if (!unsafeCountryName) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/registerRemoteMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const cmdRegisterRemoteMember: MiddlewareFn<
> = async (ctx) => {
const i18n = ctx.i18n;
const countries = markdown
.escape(ctx.command.args ?? '')
.escape(ctx.userCommand.args ?? '')
.trim()
.split(' ');

Expand Down
2 changes: 1 addition & 1 deletion src/commands/setLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const cmdSetLanguage: Middleware<BotContext> = async (ctx) => {
}

const [langParam] = markdown
.escape(ctx.command.args ?? '')
.escape(ctx.userCommand.args ?? '')
.trim()
.split(' ');

Expand Down
2 changes: 1 addition & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface BotContext extends Context {
mention: string;
id: number;
};
command: {
userCommand: {
text: string;
command: string;
bot?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/createCommandMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const createCommandMiddleware = () => {
args: parts[3],
};

ctx.command = command;
ctx.userCommand = command;

return next();
};
Expand Down
3 changes: 3 additions & 0 deletions src/middlewares/createContextMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ export const createContextMiddleware = ({ config }: Props) => {
}

if (!isCaptchaEnabled && captchaRecyclingInterval) {
ctx.logger.info(
`Found captcha recycling intervals for chat "${chatId}" with captcha disabled. Clearing intervals.`
);
clearInterval(captchaIntervals[chatId]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/testing/createTestBotContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const createTestBotContext = async (
mention: createMemberMention(mainFakeTestUser),
},
database: database,
command: {
userCommand: {
bot: 'GringoBot',
},
replyWithMarkdown,
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ svg-captcha@^1.4.0:
dependencies:
opentype.js "^0.7.3"

telegraf@^4.11.2:
telegraf@^4.16.3:
version "4.16.3"
resolved "https://registry.yarnpkg.com/telegraf/-/telegraf-4.16.3.tgz#f03fa30482b540a7f9895af8f13ec8f432840a66"
integrity sha512-yjEu2NwkHlXu0OARWoNhJlIjX09dRktiMQFsM678BAH/PEPVwctzL67+tvXqLCRQQvm3SDtki2saGO9hLlz68w==
Expand Down

0 comments on commit 20fa860

Please sign in to comment.