Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sprusr committed Jun 15, 2018
0 parents commit 1f6f595
Show file tree
Hide file tree
Showing 9 changed files with 1,350 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# GitHub
HUBOT_GITHUB_TOKEN=TODO
HUBOT_GITHUB_USER=JoinColony
HUBOT_GITHUB_REPO=colonyDapp

# Figma
HUBOT_FIGMA_TOKEN=TODO
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.DS_Store*
.hubot_history
.env
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Chewie

Chewie is a handy bot for doing Colony things. It's built on Hubot and is very extensible!
5 changes: 5 additions & 0 deletions external-scripts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
"hubot-diagnostics",
"hubot-help",
"hubot-github-status"
]
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "chewie",
"version": "0.0.0",
"private": true,
"author": "Scott Street <[email protected]>",
"description": "A handy bot for doing Colony things",
"scripts": {
"start": "env-cmd .env yarn run hubot --name chewie -a slack",
"dev": "env-cmd .env yarn run hubot --name chewie"
},
"dependencies": {
"env-cmd": "^8.0.2",
"figma-js": "^1.3.4",
"githubot": "^1.0.1",
"hubot": "^3.0.1",
"hubot-diagnostics": "0.0.2",
"hubot-github-status": "^0.2.1",
"hubot-help": "^0.2.2",
"hubot-slack": "^4.4.0"
},
"engines": {
"node": "0.10.x"
}
}
31 changes: 31 additions & 0 deletions scripts/figma-preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Description:
// Post Figma previews when linked
//
// Commands:
// https://www.figma.com/file/... - display a Figma preview
//
// Dependencies:
// 'figma-js': '1.3.x'
//
// Author:
// sprusr

const Figma = require('figma-js')

module.exports = (robot) => {
const figma = Figma.Client({
personalAccessToken: process.env.HUBOT_FIGMA_TOKEN
})

robot.hear(/https:\/\/www.figma.com\/file\/([A-z0-9]*)\/?/, async msg => {
try {
const fileId = msg.match[1]
const file = await figma.file(fileId)
const name = file.data.name
const thumbnail = file.data.thumbnailUrl
msg.send(`${name} ${thumbnail}`)
} catch (error) {
console.error(error)
}
})
}
42 changes: 42 additions & 0 deletions scripts/github-issue-link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Description:
// Links to GitHub issues when posted in the shorthand user/repo#nnn
// Adapted from https://github.com/github/hubot-scripts/blob/master/src/scripts/github-issue-link.coffee
//
// Dependencies:
// 'githubot': '0.4.x'
//
// Configuration:
// HUBOT_GITHUB_REPO
// HUBOT_GITHUB_TOKEN
//
// Commands:
// #nnn - link to GitHub issue nnn for HUBOT_GITHUB_REPO project
// repo#nnn - link to GitHub issue nnn for repo project
// user/repo#nnn - link to GitHub issue nnn for user/repo project
//
// Author:
// sprusr

module.exports = function(robot) {
const github = require('githubot')(robot)
const ignoreUsers = 'github|hubot'
const apiUrl = 'https://api.github.com'

robot.hear(/((\S*|^)?#(\d+)).*/, msg => {
const issue = msg.match[3]

if (msg.message.user.name.match(new RegExp(ignoreUsers, 'gi'))) return
if (isNaN(issue)) return

const repo = msg.match[2]
? github.qualified_repo(msg.match[2])
: github.qualified_repo(process.env.HUBOT_GITHUB_REPO)

github.get(`${apiUrl}/repos/${repo}/issues/${issue}`, res => {
const title = res.title
const url = res.html_url
const type = res.pull_request ? "PR" : "Issue"
msg.send(`${type} ${issue}: ${title} ${url}`)
})
})
}
Loading

0 comments on commit 1f6f595

Please sign in to comment.