Skip to content

Commit

Permalink
Merge pull request #3 from nicktu12/giphy-int
Browse files Browse the repository at this point in the history
Giphy int
  • Loading branch information
nicktu12 authored Nov 28, 2018
2 parents 8790e22 + c42938b commit 4a6be63
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ default_events:
# - project_card
# - project_column
# - public
# - pull_request
- pull_request
# - pull_request_review
# - pull_request_review_comment
# - push
Expand Down Expand Up @@ -82,7 +82,7 @@ default_permissions:

# Pull requests and related comments, assignees, labels, milestones, and merges.
# https://developer.github.com/v3/apps/permissions/#permission-on-pull-requests
# pull_requests: read
pull_requests: write

# Manage the post-receive hooks for a repository.
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-hooks
Expand Down
19 changes: 17 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
module.exports = app => {
// Your code here
const fetch = require('node-fetch');
app.log('Yay, the app was loaded!')

const triggerWords = ["Bey", "Beyonce", "Beyoncé", "Yonce", "Yoncé", "Mrs. Carter", "Mrs Carter", "JayZ", "Jay-Z", "Jay Z", "Sasha Fierce", "Destiny's Child", "Destinys Child", "Solange", "Knowles"];

const getBeyGif = () => {
return fetch(`https://api.giphy.com/v1/gifs/random?api_key=${process.env.GIPHY}&tag=beyonce&rating=PG-13`)
.then(response => response.json())
.then(json => json.data.id)
.catch(error => { app.log(error) });
}

app.on('issues.opened', async context => {
const triggerWords = ["Bey", "Beyonce", "Beyoncé", "Yonce", "Yoncé", "Mrs. Carter", "Mrs Carter", "JayZ", "Jay-Z", "Jay Z", "Sasha Fierce", "Destiny's Child", "Destinys Child", "Solange", "Knowles"];
const issueBody = context.payload.issue.body;

const issueTitle = context.payload.issue.title;
Expand All @@ -15,12 +24,18 @@ module.exports = app => {
);

if (containsArray.includes(true)) {
const issueComment = context.issue({ body: '![](https://media.giphy.com/media/n4WpP39mwWrmg/giphy.gif)' })
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 => {
app.log('suuuuuh;')
})

// For more information on building apps:
// https://probot.github.io/docs/

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BeyBot",
"version": "1.0.0",
"version": "1.0.1",
"description": "A probot that worships Queen Beyoncé",
"author": "Nick Teets <[email protected]>",
"license": "ISC",
Expand All @@ -20,6 +20,7 @@
"test:watch": "jest --watch --notify --notifyMode=change --coverage"
},
"dependencies": {
"node-fetch": "^2.3.0",
"probot": "^7.2.0"
},
"devDependencies": {
Expand Down

0 comments on commit 4a6be63

Please sign in to comment.