1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | const slack_messages_1 = require("@atomist/slack-messages");
|
19 | const util_1 = require("./util");
|
20 |
|
21 | function slackSuccessMessage(title, text, ctx, options = {}) {
|
22 | const msg = {
|
23 | attachments: [Object.assign({ author_icon: `https://images.atomist.com/rug/check-circle.gif?gif=${util_1.guid()}`, author_name: title, text, fallback: text, color: "#37A745", mrkdwn_in: ["text"], footer: slackFooter(ctx), ts: slackTs() }, options)],
|
24 | };
|
25 | return msg;
|
26 | }
|
27 | exports.slackSuccessMessage = slackSuccessMessage;
|
28 | function slackQuestionMessage(title, text, ctx, options = {}) {
|
29 | const msg = {
|
30 | attachments: [Object.assign({ author_icon: `https://images.atomist.com/rug/question.png`, author_name: title, text, fallback: text, color: "#B5B5B5", mrkdwn_in: ["text"], footer: slackFooter(ctx), ts: slackTs() }, options)],
|
31 | };
|
32 | return msg;
|
33 | }
|
34 | exports.slackQuestionMessage = slackQuestionMessage;
|
35 | function slackInfoMessage(title, text, ctx, options = {}) {
|
36 | const msg = {
|
37 | attachments: [Object.assign({ author_icon: `https://images.atomist.com/rug/info.png`, author_name: title, text, fallback: text, color: "#B5B5B5", mrkdwn_in: ["text"], footer: slackFooter(ctx), ts: slackTs() }, options)],
|
38 | };
|
39 | return msg;
|
40 | }
|
41 | exports.slackInfoMessage = slackInfoMessage;
|
42 | function slackWarningMessage(title, text, ctx, options = {}) {
|
43 | const msg = {
|
44 | attachments: [Object.assign({ author_icon: `https://images.atomist.com/rug/warning-yellow.png`, author_name: title, text, fallback: text, color: "#D7B958", mrkdwn_in: ["text"], footer: slackSupportLink(ctx), ts: slackTs() }, options)],
|
45 | };
|
46 | return msg;
|
47 | }
|
48 | exports.slackWarningMessage = slackWarningMessage;
|
49 | function slackErrorMessage(title, text, ctx, options = {}) {
|
50 | const msg = {
|
51 | attachments: [Object.assign({ author_icon: "https://images.atomist.com/rug/error-circle.png", author_name: title, text, fallback: text, color: "#BC3D33", mrkdwn_in: ["text"], footer: slackSupportLink(ctx), ts: slackTs() }, options)],
|
52 | };
|
53 | return msg;
|
54 | }
|
55 | exports.slackErrorMessage = slackErrorMessage;
|
56 | function slackSupportLink(ctx) {
|
57 | const supportUrl = `https://atomist.typeform.com/to/yvnyOj?message_id=${Buffer.from(ctx.correlationId).toString("base64")}`;
|
58 | return `${slackFooter(ctx)} \u00B7 ${slack_messages_1.url(supportUrl, "Support")}`;
|
59 | }
|
60 | exports.slackSupportLink = slackSupportLink;
|
61 | function slackFooter(ctx) {
|
62 | return `${ctx.skill.namespace}/${ctx.skill.name}`;
|
63 | }
|
64 | exports.slackFooter = slackFooter;
|
65 | function slackTs() {
|
66 | return Math.floor(Date.now() / 1000);
|
67 | }
|
68 | exports.slackTs = slackTs;
|
69 | function slackSeparator() {
|
70 | return "\u00B7";
|
71 | }
|
72 | exports.slackSeparator = slackSeparator;
|
73 |
|
\ | No newline at end of file |