In Slack you're able to post as a user in a code block like in Stackoverflow
like so
As a posting user, you're able to do this by typing "```" it then changes your input box to one formatted for code.
I need to get my Slack App/Bot to post a Tabluate Table as a code block so the formatting stays consistent with my Python output. At the moment, my code looks like this:
client.chat_postMessage(channel="#google-analytics-test",text="```" + table)
This simply posts the table in a text format with "```" added onto the start of it.
Any help on this would be greatly appreciated, any alternative methods to get the Tabulate Table being posted by the bot in the right format would also be very welcomed!
You also need "```" after the table and both should be in a separate line. This should do it:
client.chat_postMessage(channel="#google-analytics-test",text="```\n" + table + "\n```")
Note the added newlines "\n".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.