Created
March 5, 2015 19:25
-
-
Save perplexes/8e39456eae20ed458883 to your computer and use it in GitHub Desktop.
Flowdock groups for hubot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put in scripts/ | |
# Be sure to have "redis-brain.coffee" in your hubot-scripts.json | |
# @hubot, Colin is a dev | |
# Hubot: Ok, Colin is a dev | |
# @hubot, who is Colin | |
# Hubot: Colin is a dev. | |
# @dev, testing? | |
# (in same flow) Hubot: @Colin :arrow_up: | |
_ = require("underscore") | |
`function escapeRegExp(str) { | |
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); | |
}` | |
module.exports = (robot) -> | |
robot.brain.data.roles ||= {} | |
_.each robot.brain.data.users, (k, v) -> | |
if v && v.roles && v.name | |
_.each roles, (role) -> | |
robot.brain.data.roles[role] ||= {} | |
robot.brain.data.roles[role][v.name] ||= true | |
robot.hear /(.*)/, (msg) -> | |
text = msg.match[1] | |
console.log("text", text) | |
text = text.replace(/verbot: /i, "") | |
console.log("text2", text) | |
group_m = text.match(/@(\w+)/) | |
console.log("group_m", group_m) | |
unless group_m | |
return | |
group = group_m[1] | |
console.log(group: group) | |
unless group | |
return | |
unless robot.brain.data.roles? | |
return | |
console.log("msg", text) | |
console.log("group", group) | |
console.log("roles", robot.brain.data.roles) | |
group_regex = new RegExp(escapeRegExp(group), "i") | |
users = _.find robot.brain.data.roles, (v, k, o) -> | |
k.match(group_regex) | |
if _.isEmpty(users) | |
console.log("empty") | |
return | |
ats = _.map _.keys(users), (user) -> | |
"@#{user}" | |
msg.send(ats.join(" ") + " :arrow_up:") | |
robot.respond /list groups/, (msg) -> | |
msg.send _.keys(robot.brain.data.roles).join(", ") | |
robot.respond /list members of (.*)/, (msg) -> | |
msg.send _.keys(robot.brain.data.roles[msg.match[1]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "hosted-hubot", | |
"version": "2.5.1", | |
"author": "GitHub Inc.", | |
"keywords": [ | |
"github", | |
"hubot", | |
"campfire", | |
"bot" | |
], | |
"description": "A simple helpful robot for your Company", | |
"licenses": [{ | |
"type": "MIT", | |
"url": "http://github.com/github/hubot/raw/master/LICENSE" | |
}], | |
"repository" : { | |
"type": "git", | |
"url": "https://github.com/github/hubot.git" | |
}, | |
"dependencies": { | |
"hubot": ">= 2.5.1", | |
"hubot-flowdock": ">= 0.5.0", | |
"hubot-scripts": ">= 2.4.2", | |
"underscore": "", | |
"node-skill": "" | |
}, | |
"engines": { | |
"node": ">= 0.8.x", | |
"npm": ">= 1.1.x" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: bin/hubot -a flowdock -n <<<bot name>>> --enable-slash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
heroku create | |
name=$(git remote -v | grep fetch | sed 's/.*:\(.*\)\.git.*/\1/') | |
heroku config:add HEROKU_URL=http://$name.herokuapp.com | |
heroku addons:add redistogo:nano | |
heroku config:add HUBOT_FLOWDOCK_LOGIN_EMAIL=<<<<bot email>>>> | |
heroku config:add HUBOT_FLOWDOCK_LOGIN_PASSWORD=<<<<bot password>>>> | |
git push heroku master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment