diff --git a/src/handler.js b/src/handler.js index 0378cca..400f39c 100644 --- a/src/handler.js +++ b/src/handler.js @@ -55,7 +55,15 @@ module.exports.cron = rollbar.wrap(async () => { const prevLevel = getLevel(get(JSON.parse(previousData), "data.aqi", 0)); const curLevel = getLevel(get(JSON.parse(currentData), "data.aqi", 0)); if (prevLevel !== curLevel) { - await slack.message.channel(process.env.SLACK_CHANNEL, "hi"); + const info = levels[curLevel]; + const msg = [ + `*Air Quality Index*: \`${info.level}\``, + `_${info.impact}_`, + info.recommendation, + info.image, + `*Reference*: \`https://aqicn.org/city/${process.env.CITY}\`` + ].join("\\n\\n"); + await slack.message.channel(process.env.SLACK_CHANNEL, msg); return "changed"; } } diff --git a/src/levels.json b/src/levels.json index 0c8e876..3f04562 100644 --- a/src/levels.json +++ b/src/levels.json @@ -3,36 +3,42 @@ "level": "Good", "impact": "Air quality is considered satisfactory, and air pollution poses little or no risk", "recommendation": "None", - "color": "009966" + "color": "009966", + "image": "https://i.imgur.com/v9u61Jl.png" }, "51": { "level": "Moderate", "impact": "Air quality is acceptable; however, for some pollutants there may be a moderate health concern for a very small number of people who are unusually sensitive to air pollution.", "recommendation": "Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion.", - "color": "ffde33" + "color": "ffde33", + "image": "https://i.imgur.com/gYLQAnO.png" }, "101": { "level": "Unhealthy for Sensitive Groups", "impact": "Members of sensitive groups may experience health effects. The general public is not likely to be affected.", "recommendation": "Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion.", - "color": "ff9933" + "color": "ff9933", + "image": "https://i.imgur.com/r7Tt3tI.png" }, "151": { "level": "Unhealthy", "impact": "Everyone may begin to experience health effects; members of sensitive groups may experience more serious health effects", "recommendation": "Active children and adults, and people with respiratory disease, such as asthma, should avoid prolonged outdoor exertion; everyone else, especially children, should limit prolonged outdoor exertion", - "color": "cc0033" + "color": "cc0033", + "image": "https://i.imgur.com/Usn9IGl.png" }, "201": { "level": "Very Unhealthy", "impact": "Health warnings of emergency conditions. The entire population is more likely to be affected.", "recommendation": "Active children and adults, and people with respiratory disease, such as asthma, should avoid all outdoor exertion; everyone else, especially children, should limit outdoor exertion.", - "color": "660099" + "color": "660099", + "image": "https://i.imgur.com/Dk5mjog.png" }, "301": { "level": "Hazardous", "impact": "Health alert: everyone may experience more serious health effects", "recommendation": "Everyone should avoid all outdoor exertion", - "color": "7e0023" + "color": "7e0023", + "image": "https://i.imgur.com/6BkELwv.png" } }