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

Commit

Permalink
add new types
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebrown201 committed Apr 1, 2020
1 parent f2342d4 commit 5c2a07f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
12 changes: 11 additions & 1 deletion data/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,35 @@ module.exports = {
{
keywords: ["ill", "sick"],
emoji: [":ill:", ":face_with_head_bandage:", ":face_with_thermometer:"],
defaultEmoji: "ill",
type: "ill",
message: ":ill: *Off sick:*"
},
{
keywords: ["ooo", "office", "out", "busy", "conference", "training"],
emoji: [":no_entry_sign:"],
defaultEmoji: "no_entry_sign",
type: "ooo",
message: ":no_entry_sign: *Out of office:*"
},
{
keywords: ["home", "wfh", "working", "work"],
emoji: [":house:", ":house_with_garden:", ":computer:", ":wfh:"],
defaultEmoji: "house",
type: "wfh",
message: ":house_with_garden: *WFH:*"
},
{
keywords: ["birthday", "cake", ":cake:"],
emoji: [":birthday:", ":cake:", ":cupcake:"],
defaultEmoji: "birthday",
type: "cake",
message: "`:cake: *Would like some cake:*"
},
{
keywords: ["mat", "maternity", "pat", "paternity", "parental"],
emoji: [":baby:", ":baby_bottle:", ":pregnant_woman:"],
defaultEmoji: "baby",
type: "parent",
message: ":baby: *On parental leave:*"
},
Expand All @@ -45,6 +50,7 @@ module.exports = {
"traveling"
],
emoji: [":palm_tree:", ":airplane:", ":desert_island", ":sunny:"],
defaultEmoji: "palm_tree",
type: "holiday",
message: ":palm_tree: *On holiday:*"
},
Expand All @@ -60,25 +66,29 @@ module.exports = {
"breakfast",
"snacking"
],
emoji: [":spagbol:", ":spaghetti:", ":desert_island", ":yum:"],
emoji: [":spagbol:", ":spaghetti:", ":yum:"],
type: "lunch",
defaultEmoji: "spagbol",
message: ":spagbol: *On lunch:*"
},
{
keywords: ["walk", "walking", "break", "breaking", "air"],
emoji: [":walking:", ":woman-walking:", ":man-walking:"],
defaultEmoji: "walking",
type: "walking",
message: ":walking: *Getting some fresh air:*"
},
{
keywords: ["caring", "child", "childcare", "entertaining"],
emoji: [":child:"],
defaultEmoji: "child",
type: "caring",
message: ":child: *Looking after someone else:*"
},
{
keywords: ["unavailable"],
emoji: [":blockers:, :no_entry:"],
defaultEmoji: "blockers",
type: "unavailable",
message: ":blockers: *Unavailable:*"
}
Expand Down
2 changes: 1 addition & 1 deletion emojiReact.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function addNameToMessage({ text, name, message }) {
const originalNames = lastPart[1];
let newNames;
if (originalNames.trim()) {
newNames = name + "," + originalNames;
newNames = name + ", " + originalNames;
} else {
newNames = name;
}
Expand Down
18 changes: 8 additions & 10 deletions post.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async function postUpdate({ text, channel, test }) {
console.log(
`Successfully send message ${result.ts} in conversation ${postingChannel}`
);
return result.ts;
} catch (error) {
if (error.code === ErrorCode.PlatformError) {
console.log(error.data);
Expand All @@ -35,20 +36,21 @@ async function getMembers({ channel, test }) {

const memberSelection = await getStatuses(members);
const awayMessage = prepMessage(memberSelection);

let posting;
if (awayMessage !== "") {
const posting = await postUpdate({
posting = await postUpdate({
text: `In the this channel today: \n\n ${awayMessage}`,
channel,
test
});
} else {
const posting = await postUpdate({
posting = await postUpdate({
text: `No one in this channel has a status set`,
channel,
test
});
}
return posting;
} catch (error) {
console.log("getting into error");
if (error.code === ErrorCode.PlatformError) {
Expand Down Expand Up @@ -208,21 +210,17 @@ function prepMessage(statuses) {
return message;
}

const times = x => f => {
if (x > 0) {
f();
times(x - 1)(f);
}
};
async function addReactions({ channel, post }) {}

exports.post = async function(event, context) {
try {
console.log("message", event.Records[0].Sns.Message);
const { channel, test } = JSON.parse(event.Records[0].Sns.Message);
await getMembers({
const result = await getMembers({
channel,
test
});
await addReactions({ channel, post: result });
return {
statusCode: 200,
body: "success"
Expand Down

0 comments on commit 5c2a07f

Please sign in to comment.