0

I want my Telegram bot to send a message that has a formatted table with links inside. I am using prettytable module as a basis to create a table. Here is what my table variable looks like:

+-----------------------------------+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                Name               |  Arrival   |                                                                                      Link                                                                                     |
+-----------------------------------+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|             Package #1            | 2022-08-06 |    [1Z1234567890](https://www.ups.com/track?loc=en_US&tracknum=1Z1234567890&requester=WT/trackdetails) \| [AS](https://somewebsite.com/1Z1234567890)    |
|             Package #2            | 2022-08-07 |    [1Z9876543210](https://www.ups.com/track?loc=en_US&tracknum=1Z9876543210&requester=WT/trackdetails) \| [AS](https://somewebsite.com/1Z9876543210)    |
+-----------------------------------+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

And then I send the table with:

update.message.reply_text(f'```{table}```', parse_mode='MarkdownV2', disable_web_page_preview=True)

but the URLs show up as the markdown code (because of the ``` tags).

Is there a way to send this formatted table but have the links show up as links?

Bijan
  • 7,737
  • 18
  • 89
  • 149

1 Answers1

0

Trying to get TG to send nicely formatted tables is a lost cause. Even with monospaced text, the line width depends on the client, device, font, font size etc. So it's almost sure that there is an additional line break for someone reading the message, which messes up the table formatting.

If you want to send a nice table, send it as document, picture, HTML file or something similar.

CallMeStag
  • 5,467
  • 1
  • 7
  • 22