Last active
April 2, 2016 14:46
-
-
Save williamherry/9b230e2f9ca54b889074 to your computer and use it in GitHub Desktop.
集成到倍洽(bearychat)的hook代码
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
{TextMessage} = require '../node_modules/hubot/src/message' | |
module.exports = (robot) -> | |
robot.router.post '/hubot/bearychat/:room', (req, res) -> | |
data = if req.body.payload? then JSON.parse req.body.payload else req.body | |
robot._send ?= robot.adapter.send; | |
robot.adapter.send = (user,strings...) -> | |
res.send {text: strings.toString()} if user.user.name is "http" | |
robot.adapter.send = robot._send if user.user.name isnt "http" | |
user = robot.brain.userForId '1', name: 'http', room: 'http' | |
robot.receive new TextMessage user, data.text, 'messageId' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/coderofsalvation/hubot-script-http