Telegram hyperlinks
Возникла проблема отправки сообщения в MarkdownV2.
Нашел темплейт гиперссылки для телеграма [Text](Link)
Написал функцию генерации календаря:
def generate_calendar() -> str:
template = '###\n' \
'[{event_name}]({event_link}) : {from_date} - {to_date} | Format: {format} | Weight: {weight}\n'
calendar = 'Calendar of upcoming events:\n'
for event in get_upcoming_events():
calendar += template.format(event_name=event.name,
event_link=event.link,
from_date=event.start_date,
to_date=event.finish_date,
format=event.format,
weight=event.weight
)
return markdown_decoration.quote(calendar)
Отправил:
@dp.message_handler(commands=['calendar'])
async def command_calendar(message: types.Message):
await message.reply(text=generate_calendar() ,parse_mode='MarkdownV2')
И ссылка не обрабатывается
Calendar of upcoming events:
###
[3kCTF-2020](https://ctftime.org/event/1077) : 07/24 17:00 - 07/25 13:00 | Format: Jeopardy | Weight: Undefined
###
[CyBRICS CTF 2020](https://ctftime.org/event/1012) : 07/25 10:00 - 07/26 10:00 | Format: Jeopardy | Weight: 24.09
###
[InCTF 2020](https://ctftime.org/event/981) : 07/31 13:30 - 08/02 13:30 | Format: Jeopardy | Weight: 53.95
###
[DEF CON CTF 2020](https://ctftime.org/event/1088) : 08/07 17:00 - 08/09 21:00 | Format: Attack-Defense | Weight: Undefined
###
[PoseidonCTF 1st Edition](https://ctftime.org/event/1049) : 08/08 17:00 - 08/09 17:00 | Format: Jeopardy | Weight: Undefined
UPD: Нашел метод класса markdown_decoration - link, но с ним ситуация та же самая (очевидно потому что реализация метода такая же, как и моя):
markdown_decoration.link(event.name, event.link)
Не понимаю почему;
Ответы (1 шт):
Автор решения: icYFTL
→ Ссылка
Ошибка заключалась в том, что я делал
return markdown_decoration.quote(calendar)
тем самым убивая саму разметку.