removing dependencies

pull/188/head
Gabriel Engel 10 years ago
parent c500357133
commit bb2544b8e8
  1. 41
      packages/rocketchat-hubot/hubot.coffee
  2. 12
      packages/rocketchat-hubot/package.js

@ -1,9 +1,11 @@
CoffeeScript = Npm.require('coffee-script')
CoffeeScript.register()
HubotScripts = Npm.require('codex-blackboard-hubot-scripts');
Hubot = Npm.require('hubot')
fs = require('fs')
path = require('path')
# Start a hubot, connected to our chat room.
'use strict'
@ -134,6 +136,41 @@ class RocketBotReceiver
console.log 'RocketBot: ', RocketBot if DEBUG
return message
class HubotScripts
constructor: (robot) ->
# load all scripts in scripts/
scriptPath = path.resolve __dirname, 'scripts'
for file in fs.readdirSync(scriptPath)
continue unless /\.(coffee|js)$/.test(file)
robot.loadFile scriptPath, file
# load all scripts from hubot-scripts
scriptPath = path.resolve __dirname, 'node_modules', 'hubot-scripts', 'src', 'scripts'
scripts = require './hubot-scripts.json'
robot.loadHubotScripts scriptPath, scripts
robot.parseHelp path.join scriptPath, 'meme_captain.coffee'
# load all hubot-* modules from package.json
packageJson = require './package.json'
pkgs = (pkg for own pkg, version of packageJson.dependencies when !/^(coffee-script|hubot-scripts|hubot-help)$/.test(pkg))
pkgs.forEach (p) -> (require p)(robot)
# A special hack for hubot-help: ensure it replies via pm
privRobot = Object.create robot
privRobot.respond = (regex, cb) ->
robot.respond regex, (resp) ->
resp.message.private = true
cb(resp)
(require 'hubot-help')(privRobot)
# A special hack for meme_captain: change its "respond" invocations to "hear" so that it memes everywhere.
memecaptain = require './node_modules/hubot-scripts/src/scripts/meme_captain'
memecaptain
respond: (regex, cb) ->
robot.hear regex, (msg) ->
cb(msg) if msg.envelope.room is 'general/0' or /^\s*[@]?(rocket)?bot\b/i.test(msg.message.text)
sendHelper = Meteor.bindEnvironment (robot, envelope, strings, map) ->
while strings.length > 0
string = strings.shift()
@ -165,7 +202,7 @@ RocketChat.callbacks.add 'afterSaveMessage', RocketBotReceiver, RocketChat.callb
# share.hubot[scriptName](robot)
# # register our nick
# n = Meteor.call 'newNick', {name: 'rocketbot'}
# Meteor.call 'setTag', {type:'nicks', object:n._id, name:'Gravatar', value:'codex@printf.net', who:n.canon}
# Meteor.call 'setTag', {type:'nicks', object:n._id, name:'Gravatar', value:'rocket@printf.net', who:n.canon}
# # register our presence in general chat
# keepalive = -> Meteor.call 'setPresence',
# u:

@ -24,9 +24,15 @@ Package.onUse(function(api) {
});
Npm.depends({
"coffee-script": "1.9.3",
"codex-blackboard-hubot-scripts": "https://github.com/cscott/codex-blackboard-hubot-scripts/tarball/f57c178a2faee9b36d07a7905c29093b9824e0b0",
"hubot": "2.13.1"
"coffee-script": "^1.9.3",
"hubot": "^2.13.1"
"hubot-calculator": "^0.4.0",
"hubot-google-hangouts": "^0.7.1",
"hubot-google-images": "^0.1.1",
"hubot-google-translate": "^0.1.0",
"hubot-help": "^0.1.1",
"hubot-scripts": "^2.5.16",
"hubot-youtube": "^0.1.2",
});
Package.onTest(function(api) {});

Loading…
Cancel
Save