Skip to content

Commit 33e1198

Browse files
committed
Add escapeMarkdownV2 function in QuestionHandler to ensure proper formatting of replies with MarkdownV2.
1 parent 555aa22 commit 33e1198

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apps/bot/src/handlers/question.handler.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { UpdateEvent } from '@app/common';
44

55
const HIVEMIND_BLOCKLIST = ['-1002141367711']; // TODO: Move this to config
66

7+
function escapeMarkdownV2(text) {
8+
return text.replace(/[_*[\]()~`>#+=|{}.!-]/g, '\\$&');
9+
}
10+
711
export class QuestionHandler extends BaseHandler {
812
async handle(ctx: Context, event?: FilterQuery): Promise<void> {
913
try {
@@ -44,7 +48,7 @@ export class QuestionHandler extends BaseHandler {
4448
};
4549

4650
this.logger.log('Reply from hivemind:', result);
47-
await ctx.reply(result, other);
51+
await ctx.reply(escapeMarkdownV2(result), other);
4852
}
4953
} catch (error) {
5054
this.logger.error(error);

0 commit comments

Comments
 (0)