-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slack.gs
80 lines (72 loc) · 4.3 KB
/
Slack.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function postForm(startDate, endDate, form) {
var payload = {
"channel": "#priv-consensys-member",
"username": "Time Tracking: " + startDate + ' - ' + endDate,
"icon_emoji": ":chilling:",
"link_names": 1,
"attachments": [
{
"fallback": "Time tracking form now available to fill out. Please do so at your earliest convenience.",
"pretext": "<!channel>: Every second week, ConsenSys will be measuring the effort spent by its members on projects via the Coordination teams’ Time Tracker. Please <" + form + "|click this link> and enter the percentage of your time spent on projects for the period indicated. If you have questions, please ask in <https://consensys.slack.com/archives/priv-consensys-member|#priv-consensys-member>.",
"mrkdwn_in": ["pretext"],
"color": "#D00000"
}
]
}
var url = 'https://hooks.slack.com/services/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';
var options = {
'method': 'post',
'payload': JSON.stringify(payload)
};
var response = UrlFetchApp.fetch(url, options);
var body = "Hi Everyone! <br><br>";
body += "Every second week, ConsenSys will be measuring the effort spent by its members on projects via the Coordination teams’ Time Tracker.<br><br>"
body += "Please <a href='" + form + "'>click this link</a> and enter the percentage of your time spent on projects for the period of <b>" + startDate + ' - ' + endDate + "</b>. If you have questions, please ask in <a href='https://consensys.slack.com/archives/priv-consensys-member'>#priv-consensys-member</a>.<br><br>"
body += "-The Mesh Services Team";
MailApp.sendEmail({
to: 'everyone@consensys.net',
subject: "Time Tracking: " + startDate + ' - ' + endDate,
htmlBody: body
});
var ui = SpreadsheetApp.getUi();
ui.alert('You have posted the form link to Slack');
}
function reminderMessage(missing, form, startDate, endDate, ui) {
for(var i = 0; i < missing.length; i++) {
if( missing[i].slack ) {
var slackHandle = missing[i].slack;
var payload = {
"channel": "@" + slackHandle,
"username": "Please fill out Time Tracking form",
"icon_emoji": ":justdoit:",
"link_names": 1,
"attachments": [
{
"fallback": "According to our logs, you have not filled in the ConsenSys Time Tracker for the period " + startDate + " - " + endDate + ".",
"pretext": "According to our logs, you have not filled in the ConsenSys Time Tracker for the period " + startDate + " - " + endDate + ". Every second Friday, the Time Tracker posts a link in <https://consensys.slack.com/archives/priv-consensys-member|#priv-consensys-member> which you must have missed this time around. Please <" + form + "|click this link> and enter the percentage of your time spent on projects for the period indicated. If you have questions, please ask in <https://consensys.slack.com/archives/priv-consensys-member|#priv-consensys-member>.",
"mrkdwn_in": ["pretext"],
"color": "#D00000"
}
]
}
var url = 'https://hooks.slack.com/services/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';
var options = {
'method': 'post',
'payload': JSON.stringify(payload)
};
var response = UrlFetchApp.fetch(url, options);
}
if( missing[i].email ) {
var body = "Hi " + missing[i].fullName + "<br><br>";
body += "According to our logs, you have not filled in the <b>ConsenSys Time Tracker</b> for the period <b>" + startDate + " - " + endDate + "</b>.<br><br>";
body += "Every second Friday, the Time Tracker posts a link in <a href='https://consensys.slack.com/archives/priv-consensys-member'>#priv-consensys-member</a> which you must have missed this time around. Please <a href='" + form + "'>click this link</a> and enter the percentage of your time spent on projects for the period indicated. If you have questions, please ask in <a href='https://consensys.slack.com/archives/priv-consensys-member'>#priv-consensys-member</a>.<br><br>"
body += "-The Mesh Services Team";
MailApp.sendEmail({
to: missing[i].email,
subject: "Missing Time Tracking: " + startDate + ' - ' + endDate + " Form",
htmlBody: body
});
}
}
ui.alert('You have sent a remind for ' + startDate + ' - ' + endDate);
}