jarvis-bot
Version:
A JARVIS for your team - your most powerful bot and loyal butler.
31 lines (26 loc) • 769 B
text/coffeescript
_ = require 'lomath'
module.exports = (robot) ->
robot.respond /_\.(\w+)(.*)$/i, (msg) ->
fn = msg.match[1]
strargs = msg.match[2]
res = 'Syntax error in your lomath: '+'`_.'+fn+strargs+'`'
if fn is 'fn'
res = '```'+_.functions(_).join('\n')+'```'
else if fn is 'api'
res = '`lomath api:` _ http://kengz.github.io/lomath/ _'
else
try
args = JSON.parse strargs.replace('(', '[').replace(')', ']')
res = '`'+JSON.stringify(_[fn].apply(_, args))+'`'
catch e
msg.send res