Generate Chatops RPC compatible servers for Hubot and more
npm install hubot-rpc-genGenerate Chatops RPC compatible servers for Hubot and more! Compatible with Express v4.
```
npm install [--save] hubot-rpc-gen
Assuming you already have an express server:
`javascript`
const express = require('express')
const app = express()
you can add a CRPC endpoint easily! For example, to mount the endpoint at /_chatops with the namespace 'mynamespace':
`javascript`
const crpc = require('hubot-rpc-gen')
const endpoint = crpc.endpoint(app, 'mynamespace', '/_chatops')
You can then add methods using the method method:
`javascriptUser ${user} asked for method ${method} with option ${params.option} in ${room_id}
endpoint.method('name', {
help: 'An optional help message',
regex: 'command regex (?)`
})
If you want to provide more advanced options, like title and color in the response, pass them as a second option to respond:
`javascripthttps://github.com/${params.query}
rpc.method('github-lookup', {
help: 'github me
regex: 'github me (?
params: ['query', 'color']
}, ({user, method, params, room_id}, respond) => {
respond(,, {https://github.com/${params.query}
title: params.query,
title_link: ,https://github.com/${params.query}.png
image_url: ,``
color: '0000ff'
})
})