Code cleanup

This commit is contained in:
Pedro Pombeiro 2018-02-22 21:58:54 +01:00
parent 2efe7e508c
commit fef64a854b
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
3 changed files with 16 additions and 10 deletions

View File

@ -23,7 +23,7 @@ module.exports = async (robot) => {
} }
async function setupSlack (robot) { async function setupSlack (robot) {
Slack(robot, slack => {}) Slack.setup(robot, slack => {})
await new Promise(resolve => { await new Promise(resolve => {
robot.on('slack.connected', event => { robot.on('slack.connected', event => {

View File

@ -7,12 +7,14 @@
// Author: // Author:
// PombeirP // PombeirP
module.exports.getPullRequestReviewStates = _getPullRequestReviewStates module.exports = {
module.exports.getReviewApprovalState = _getReviewApprovalState getPullRequestReviewStates: _getPullRequestReviewStates,
module.exports.getProjectCardForIssue = _getProjectCardForIssue getReviewApprovalState: _getReviewApprovalState,
module.exports.getOrgProjectByName = _getOrgProjectByName getProjectCardForIssue: _getProjectCardForIssue,
module.exports.getRepoProjectByName = _getRepoProjectByName getOrgProjectByName: _getOrgProjectByName,
module.exports.getProjectColumnByName = _getProjectColumnByName getRepoProjectByName: _getRepoProjectByName,
getProjectColumnByName: _getProjectColumnByName
}
async function _getPullRequestReviewStates (github, prInfo) { async function _getPullRequestReviewStates (github, prInfo) {
let finalReviewsMap = new Map() let finalReviewsMap = new Map()

View File

@ -21,9 +21,13 @@ const RTM_EVENTS = require('@slack/client').RTM_EVENTS
const BOT_TOKEN = process.env.SLACK_BOT_TOKEN || '' const BOT_TOKEN = process.env.SLACK_BOT_TOKEN || ''
module.exports.BotUserName = 'probot' module.exports = {
BotUserName: 'probot',
setup: _setup,
sendMessage: _sendMessage
}
module.exports = (robot, connectCallback) => { function _setup (robot, connectCallback) {
if (!BOT_TOKEN) { if (!BOT_TOKEN) {
robot.log.error('SLACK_BOT_TOKEN missing, skipping Slack integration') robot.log.error('SLACK_BOT_TOKEN missing, skipping Slack integration')
return return
@ -82,7 +86,7 @@ module.exports = (robot, connectCallback) => {
SlackAPI.connect('https://slack.com/api/rtm.connect') SlackAPI.connect('https://slack.com/api/rtm.connect')
} }
module.exports.sendMessage = async (robot, room, message) => { async function _sendMessage (robot, room, message) {
// Send message to Slack // Send message to Slack
if (robot.slack) { if (robot.slack) {
// TODO BOUNTY migrate away from datastore: // TODO BOUNTY migrate away from datastore: