-
Notifications
You must be signed in to change notification settings - Fork 956
Description
Is your feature request related to a problem? Please describe.
Not a big problem, but I have a lot of lines looking like await ctx.sendMessage(message, {parse_mode: 'MarkdownV2'}) which feels a bit noisy, and it also requires being vigilant. My application uses markdown heavily and almost all user facing strings are assumed to be markdown. So as well as the repetition, there are cases where we forget to add the parse_mode and then things fail in unexpected ways.
Describe the solution you'd like
Something like
const bot = new Telegraf(process.env.BOT_TOKEN, {
defaults: { parse_mode: 'MarkdownV2' },
)Describe alternatives you've considered
- Manually typing
parse_mode: 'MarkdownV2'for every message sent (current solution, but it's cumbersome and error-prone) - Wrapping the
ctxthat's passed into the event handlers (not tried because there are many different ways to send a message - unsure how to wrap only the "base"sendMessageimplementation, that's something that's correctly abstracted away)
Additional context
The above proposal suggests defaults so that other "extras" can have defaults, but since there are different contextual "extras", maybe it'd need to be divided up between the different types, if there is overlap or something.