Skip to content

Commit

Permalink
Add pr functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktu12 committed Jan 4, 2019
1 parent 6075b24 commit 67af3b4
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,57 @@ module.exports = app => {
.catch(error => { app.log(error) });
};

app.on('issues.opened', async context => {
const issueBody = context.payload.issue.body;
const postBeyGif = () => {

};

app.on('issues.opened', async context => {
const issueTitle = context.payload.issue.title;

const issueBody = context.payload.issue.body;
const issue = issueBody + ' ' + issueTitle;

const containsArray = triggerWords.map(word =>
issue.toLowerCase().includes(word.toLowerCase());
issue.toLowerCase().includes(word.toLowerCase())
);

if (containsArray.includes(true)) {
const bey = await getBeyGif();
console.log(bey);
const issueComment = context.issue({ body: `![](https://media.giphy.com/media/${bey}/giphy.gif)` });
return context.github.issues.createComment(issueComment);
};

});

app.on('pull_request.opened', async context => {
const prTitle = context.payload.pull_request.title;
const prBody = context.payload.pull_request.body;
const pr = prTitle + ' ' + prBody;

const containsArray = triggerWords.map(word =>
pr.toLowerCase().includes(word.toLowerCase())
);

if (containsArray.includes(true)) {
const bey = await getBeyGif();
const issueComment = context.issue({ body: `![](https://media.giphy.com/media/${bey}/giphy.gif)` });
return context.github.issues.createComment(issueComment);
};
});

app.on('pull_request_review_comment.created', async context => {
const prComment = context.payload.comment.body;


const containsArray = triggerWords.map(word =>
prComment.toLowerCase().includes(word.toLowerCase())
);

if (containsArray.includes(true)) {
const bey = await getBeyGif();
app.log(context);
const issueComment = context.issue({ body: `![](https://media.giphy.com/media/${bey}/giphy.gif)` });
return context.github.issues.createComment(issueComment);
};
});

// For more information on building apps:
Expand Down

0 comments on commit 67af3b4

Please sign in to comment.