2018-01-23 14:27:25 +00:00
|
|
|
// Description:
|
|
|
|
// Configuration-related functionality
|
|
|
|
//
|
|
|
|
// Dependencies:
|
|
|
|
// probot-slack-status: "^0.2.2"
|
|
|
|
//
|
|
|
|
// Author:
|
|
|
|
// PombeirP
|
|
|
|
|
|
|
|
module.exports.sendMessage = async (robot, slackClient, room, message) => {
|
|
|
|
// Send message to Slack
|
|
|
|
if (slackClient != null) {
|
|
|
|
const channel = slackClient.dataStore.getChannelByName(room)
|
|
|
|
try {
|
2018-01-28 08:24:30 +00:00
|
|
|
if (process.env.DRY_RUN) {
|
|
|
|
robot.log.debug(`Would have sent '${message}' to '${room}' channel`)
|
|
|
|
} else {
|
2018-01-23 18:38:25 +00:00
|
|
|
await slackClient.sendMessage(message, channel.id)
|
|
|
|
}
|
2018-01-28 08:24:30 +00:00
|
|
|
} catch (err) {
|
|
|
|
robot.log.error(`Failed to send Slack message to '${room}' channel`)
|
2018-01-23 14:27:25 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-01-28 08:24:30 +00:00
|
|
|
robot.log.debug('Slack client not available')
|
2018-01-23 14:27:25 +00:00
|
|
|
}
|
|
|
|
}
|