edit: as for importing question: from telegram.constants import ParseMode
I have this code below, everything works otherwise if I remove the parse_mode
bit (besides bold etc):
await update.message.reply_text(await main_menu_message(), reply_markup=await main_menu_keyboard(), parse_mode=telegram.constants.ParseMode.MARKDOWN_V2)
and have imported everything – here is the error I get back:
await update.message.reply_text(await main_menu_message(), reply_markup=await main_menu_keyboard(), parse_mode=telegram.constants.ParseMode.MARKDOWN_V2) NameError: name 'telegram' is not defined
I’ve been stuck on this for hours and have explored mostly every other post to no avail. Thank you and let me know if I need to give any more info.
I’ve tried entering it as a string, using just MARKDOWN_V2 and other entries like it
edit 2:
Okay just tried updating to parse_mode=ParseMode.MARKDOWN_V2
and get the error : telegram.error.BadRequest: Can't parse entities: character '(' is reserved and must be escaped with the preceding ''
And here is my message function:
async def main_menu_message(): return "Bot Demo *bold* n(for trial purposes only)n~~---------------~~nn[Link Text](http://example.com)"
2
Answers
Because you’re importing
ParseMode
, you can reference it by just callingParseMode
directly. You don’t need to (and shouldn’t) call it with the full import path.So in your example,
becomes
Having the same issue @Alienbyte, did you ever get it fully configured?
This is what it looks like in my chat.
Here is the code: