Last active
September 30, 2015 21:57
-
-
Save logemann/7ba18a2c3dc71babb6f6 to your computer and use it in GitHub Desktop.
ICB Part 1 Reminder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function icb1reminder(hook) { | |
console.log("Starting Hook: "+hook.params.hook); | |
var channel = "general"; | |
var request = require('request'); | |
var jsonRequest = jsonRequest = createJson("#"+channel, "Nicht vergessen...", "", | |
"Das ICB Meeting (Teil 1) steht in 5 Minuten an.", "Das ICB Meeting (Teil 1) steht in 5 Minuten an!", | |
hook.env.PICTURE_BASE_URL + "/icblogo.png"); | |
var resp = request( | |
{ | |
method: 'POST', | |
uri: hook.env.SLACKBOT_URL+"&channel=%23"+channel, | |
body: "Hallo an @everyone, aufgepasst..." | |
}, function(error, response, body) { | |
if(error) { | |
hook.res.end("Ended with error: "+error); | |
} | |
var resp = request( | |
{ | |
method: 'POST', | |
json: true, | |
uri: hook.env.SLACK_WEBHOOK_URL, | |
body: jsonRequest | |
}, function (error, response, body) { | |
if(error) { | |
hook.res.end("Ended with error: "+error); | |
} | |
hook.res.end("normally ended"); | |
}); | |
}); | |
}; | |
function createJson(channel, author, title, titlelink, body, image) { | |
return { | |
"channel": channel, | |
"username": "Reminder-BOT", | |
"icon_emoji": ":watch:", | |
"attachments": [{ | |
"image_url": image, | |
"fallback": "", | |
"color": "#990000", | |
"author_name": author, | |
"title": title, | |
"title_link": titlelink, | |
"text": body, | |
}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment