Skip to content

Instantly share code, notes, and snippets.

@williamherry
Last active April 2, 2016 14:46
Show Gist options
  • Save williamherry/9b230e2f9ca54b889074 to your computer and use it in GitHub Desktop.
Save williamherry/9b230e2f9ca54b889074 to your computer and use it in GitHub Desktop.
集成到倍洽(bearychat)的hook代码
{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'
@williamherry
Copy link
Author

@yuanbohan
Copy link

你好,不过 BearyChat 的中文名是倍洽,而不是 简聊。 简聊的地址是 这里

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