Skip to content

Instantly share code, notes, and snippets.

@insom
Created January 18, 2012 16:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save insom/1633778 to your computer and use it in GitHub Desktop.
Save insom/1633778 to your computer and use it in GitHub Desktop.
A Hubot HTTP -> talking script
module.exports = (robot) ->
robot.router.post "/hubot/say", (req, res) ->
room = req.body.room
message = req.body.message
robot.logger.info "Message '#{message}' received for room #{room}"
user = robot.userForId 'broadcast'
user.room = room
user.type = 'groupchat'
robot.send user, "#{message}"
res.writeHead 200, {'Content-Type': 'text/plain'}
res.end 'Thanks'
@insom
Copy link
Author

insom commented Jan 18, 2012

This code requires that you run master of Hubot, so something like:

"dependencies": {
  "hubot-xmpp": "git://github.com/markstory/hubot-xmpp.git",
  "hubot": "git://github.com/github/hubot",
  "hubot-scripts": "2.0.2",
  "optparse": "1.0.3"
}

@luxflux
Copy link

luxflux commented Jan 26, 2013

Check https://gist.github.com/4643449 for a version which runs with hubot 2.4.6.

@luxflux
Copy link

luxflux commented Jan 26, 2013

I opened a pull request to add this to the hubot-scripts repo: github/hubot-scripts#730 . Hope you are okay with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment