Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebrown201 committed Feb 20, 2020
1 parent 016515a commit 93a4667
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# channel-status-notifier
# Channel Status Notifier

CSN (Channel Status Notifier) is a small node script, running on AWS Lambda (+ CloudWatch, for cron jobs). It fetches all the members of a specified Slack Channel, analyses their status (based on keyword first, then emoji), and produces an absence report for the day.

Absence categories include:

- On holiday
- Out of office (e.g. conference, training, etc.)
- Off sick
- Work from home
- On parental leave

Note: this report is dependent on members of the channel updating their Slack status regularly; and before the alert is triggered.
21 changes: 9 additions & 12 deletions post.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,13 @@ function prepMessage(statuses) {
}

exports.post = async function(event, context) {
console.log("EVENT: \n" + JSON.stringify(event, null, 2));
console.log(
"JSON.parse(event.body).event.channel",
JSON.parse(event.body).event.channel
);
const result = await getMembers({
channel: JSON.parse(event.body).event.channel
});
return {
statusCode: 200,
body: "success"
};
try {
await getMembers({
channel: JSON.parse(event.body).event.channel
});
return {
statusCode: 200,
body: "success"
};
} catch (err) {}
};
10 changes: 10 additions & 0 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ service: channel-status-notifier
provider:
name: aws
runtime: nodejs12.x
profile: csn
environment:
NODE_ENV: "${file(./serverless.env.yml):NODE_ENV}"
SLACK_TOKEN: "${file(./serverless.env.yml):SLACK_TOKEN}"

plugins:
- serverless-offline

stackTags:
teamDL: [email protected]
environment: p
systemCode: channel-status-notifier
tags:
teamDL: [email protected]
environment: p
systemCode: channel-status-notifier

functions:
post:
handler: post.post
Expand Down

0 comments on commit 93a4667

Please sign in to comment.