I'm working on a Slack Webhooks integration with Slack Slash commands. My script flow is as following:
- Getting a slash command request from a Slack.
- Processing the data (in a form of dict or Pandas DataFrame)
- Posting back to the channel using the Slack webhook.
My response is a set of key:value records or two columns dataframe. I want to print them nicely into Slack, however I ran into a formatting problem.
Using Slack back-ticks to make a code block with monospace font would not work, because I might have very large records, and Slack trims the string after 8000 characters.
Printing the lines without monospace, as a plain text, results in an ugly columns with different width in each row.
I tried all sorts of formatting tricks, but could not find a good way to format a response using the Slack API as two very long columns. I guess I am looking for a good library that would format a string for me given the font being used.
Any help would be appreciated.