python – How can I color part of Slack incoming-webhook messages?

Python – How Can I Color Part Of Slack Incoming-Webhook Messages?

python – How can I color part of Slack incoming-webhook messages?

Unfortunately it’s in the intervening time not doable to color textual content of a Slack message with the API. You can use completely different kinds, e.g. daring and italic, however not colours. (See Message Formatting in Slack documentation on how one can use kinds.)

You can use colours on your attachments. That will nonetheless lead to a vertical color bar marker for the entire attachment, however not in coloured textual content. (See Attachment Parameters in Slack documentation on how one can color your attachments.)

Here is an instance on how one can use colours for Slack attachments (taken from the Slack documentation):

{
    attachments: [
        {
            fallback: New ticket from Andrea Lee - Ticket #1943: Cant rest my password - https://groove.hq/path/to/ticket/1943,
            pretext: New ticket from Andrea Lee,
            title: Ticket #1943: Cant reset my password,
            title_link: https://groove.hq/path/to/ticket/1943,
            text: Help! I tried to reset my password but nothing happened!,
            color: #7CD197
        }
    ]
}

What you can do (as an admittedly clumsy workaround till/until Slack helps greater than primitive formatting) is:

  • Create your message as a small graphic picture in your server
  • add the photographs net handle to the slack channel utilizing the webhook
  • the message is now displayed in channel

You can use ImageMagick for this.

READ :  How To Fix Error in eval(family$initialize) : y values must be 0 <= y <= 1 In R

.png photographs enable for transparency, so that you dont have to fret an excessive amount of about background matching.

This is, of course, a very inefficient solution to go about it, but it surely has the agreeable attribute of doing what you need.

python – How can I color part of Slack incoming-webhook messages?

Related posts on python :

pymysql Error: File “/usr/local/lib/python2.7/site-packages/PyMySQL-1.0.2-py2.7.egg/pymysql/connections.py”, line 167 SyntaxError: invalid syntax

raceback (most up-to-date name final): File "log2user-real.py", line 49, in <module> db = create_engine("mysql+pymysql://root:{m_pass}@10.157.2.25:8306/log_user?charset=utf8".format(m_pass=m_pass)) File "<string>", line 2, in create_engine File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/deprecations.py", line 309,...
Avatar Of Budi Setiawan Budi Setiawan
31 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *