Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
@atomist/slack-messages
Advanced tools
Node module @atomist/slack-messages
helps rendering well formatted Slack messages sent by @atomist
from your Rug event and command handlers. This module also lets you add
actions to your Slack messages that execute Rug instructions.
See the Atomist Documentation for more information.
Construct message as a plain map following Slack message formatting API:
https://api.slack.com/docs/message-formatting
// A very simple message
const msg: SlackMessage = { text: "Simple message" };
// Here is an example of a message with a Slack action (button) that launches
// a rug instruction when clicked.
// This assumes user, issue and instruction objects are defined elsewhere.
const msg: SlackMessage = {
text: `${url(user.url, "@" + user.name)} opened issue: ${url(issue.url, issue.title)}`,
attachments: [
{
text: escape(issue.body),
fallback: escape(issue.title),
mrkdwn_in: ["text"],
actions: [
rugButtonFrom({ text: "Close issue" }, instruction),
],
},
],
};
And then simply render message. This will construct JSON string representation of the message:
const renderedMsg = render(msg);
Or to produce pretty JSON string:
const renderedMsg = render(msg, true);
This will produce the following JSON string (pretty version):
{
"text": "<https://github.com/anna|@anna> opened issue: <https://github.com/someorg/somerepo/issues/484|This issue title contains <unsafe> characters and &>",
"attachments": [
{
"text": "This is a very important issue with body containing <unsafe> characters and even &",
"fallback": "This issue title contains <unsafe> characters and &",
"mrkdwn_in": [
"text"
],
"callback_id": "cllbck1",
"actions": [
{
"text": "Close issue",
"type": "button",
"name": "rug",
"value": "somebuttonid"
}
]
}
]
}
Note that render
function will automatically assign unique callback_id
to each attachments that has actions.
But, if you provide your custom callback_id
it will be preserved as is.
Special characters
escape("Slack requires you to escape <, > and &");
=> "Slack requires you to escape <, > and &"
Links
// Simple link
url("https://www.atomist.com");
=> "<https://www.atomist.com>"
// Link with label
url("https://www.atomist.com", "atomist");
=> "<https://www.atomist.com|atomist>"
User & channel links
// @some-user (Slack will display user name for provided user ID)
user("U123");
=> "<@U123>"
// #some-channel (Slack will display channel name for provided channel ID)
channel("C123");
=> "<#C123>"
Special variables
// @channel
atChannel();
=> "<!channel>"
// @here
atHere();
=> "<!here>"
// @everyone
atEveryone();
=> "<!everyone>"
Emoji
emoji("smile");
=> ":smile:";
Markdown
Slack will render markdown if field where markdown is present is included in mrkdwn_in
array.
bold("This text will appear bold");
=> "*This text will appear bold*"
italic("This text will appear italic");
=> "_This text will appear italic_"
strikethrough("This text will appear strike-through");
=> "~This text will appear strike-through~"
// Single line code block
codeLine("var a = new A();");
=> "`var a = new A();`"
// Multi line code block
codeBlock("var a = new A();\nvar b = new B();");
=> "```var a = new A();\nvar b = new B();```"
// List
listItem("Item 1");
=> "• Item 1"
GitHub and Slack markdown are different enough to make your GitHub issues or GitHub PRs look quite bad in Slack by default. You can use githubToSlack
function from Markdown
to convert text that uses GitHub markdown to text that will look good in Slack:
githubToSlack("* list item 1\n* list item 2\n\**some bold text** and *some italic text* with a link [click here](http://someplace.com)");
=> "• list item 1\n• list item 2\n*some bold text* and _some italic text_ with a link <http://someplace.com|click here>"
General support questions should be discussed in the #support
channel on our community Slack team
at atomist-community.slack.com.
If you find a problem, please create an issue.
You will need to install npm, yarn, and TypeScript so that you can run the following commands from the command line.
Command | Reason |
---|---|
$ yarn | to install all the required packages |
$ tsc -w | to continually compile your TypeScript files (run in a different terminal) |
$ yarn test | to run tests and ensure everything is working |
$ yarn autotest | run tests continuously (you also need to run tsc -w ) |
Test using the standard approach for Node modules.
$ yarn test
To create a new release of the project, simply push a tag of the form
M.N.P
where M
, N
, and P
are integers that form the next
appropriate semantic version for release. The version in
the package.json is replaced by the build and is totally ignored! For
example:
$ git tag -a 1.2.
$ git push --tags
The Travis CI build (see badge at the top of this page) will publish the NPM module and automatically create a GitHub release using the tag name for the release and the comment provided on the annotated tag as the contents of the release notes.
Created by Atomist. Need Help? Join our Slack team.
0.9.0 - 2017-08-14
FAQs
Atomist utilities for creating formatted Slack messages
The npm package @atomist/slack-messages receives a total of 23,800 weekly downloads. As such, @atomist/slack-messages popularity was classified as popular.
We found that @atomist/slack-messages demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.