Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use the new Hubot loader to load adapters

  • Loading branch information...
commit 4bcd66279ba99e90a3d9ee365f386ea3d08a1a33 1 parent 686382d
@technoweenie technoweenie authored
View
21 bin/hubot
@@ -7,6 +7,7 @@
require.paths.unshift __dirname + "/../node_modules"
require.paths.unshift __dirname + "/../src"
+Hubot = require '..'
Fs = require 'fs'
Path = require 'path'
HTTP = require 'http'
@@ -14,6 +15,7 @@ Creator = require 'creator'
OptParse = require 'optparse'
PortNumber = parseInt(process.env.PORT) || 8080
+Adapters = ["irc", "campfire", "hipchat", "twilio", "xmpp"]
Switches = [
[ "-h", "--help", "Display the help information"],
[ "-a", "--adapter ADAPTER", "The Adapter to use"],
@@ -74,23 +76,14 @@ else if Options.version
process.exit 0
else
- switch Options.adapter
- when "irc"
- Hubot = require("hubot/irc").IrcBot
- when "campfire"
- Hubot = require("hubot/campfire").Campfire
- when "hipchat"
- Hubot = require("hubot/hipchat").HipChat
- when "twilio"
- Hubot = require("hubot/twilio").Twilio
- when "xmpp"
- Hubot = require("hubot/xmpp").XmppBot
- else
- Hubot = require("hubot/shell").Shell
+ adapter = if Options.adapter in Adapters
+ Options.adapter
+ else
+ 'shell'
scriptsPath = Path.resolve "./scripts"
console.log "Loading deploy-local scripts at #{scriptsPath}"
- robot = new Hubot scriptsPath, Options.name
+ robot = Hubot.robot adapter, scriptsPath, Options.name
robot.enableSlash = Options.enableSlash
scriptsPath = Path.resolve __dirname, "..", "src", "hubot", "scripts"
View
7 index.coffee
@@ -1,6 +1,7 @@
-# Loads the basic Hubot robot.
-exports.robot = ->
- require './src/robot'
+# Loads a Hubot robot
+exports.robot = (adapterName, path, botName) ->
+ robot = require "./src/hubot/#{adapterName}"
+ new robot path, botName
# Loads the Hubot test harness.
exports.tests = ->
View
2  src/hubot/campfire.coffee
@@ -45,7 +45,7 @@ class Campfire extends Robot
@bot = bot
-exports.Campfire = Campfire
+module.exports = Campfire
class CampfireStreaming extends EventEmitter
constructor: (options) ->
View
3  src/hubot/hipchat.coffee
@@ -122,4 +122,5 @@ class HipChat extends Robot
console.log err.stack
callback err
-exports.HipChat = HipChat
+module.exports = HipChat
+
View
3  src/hubot/irc.coffee
@@ -77,6 +77,5 @@ class IrcBot extends Robot
@bot = bot
-exports.IrcBot = IrcBot
+module.exports = IrcBot
-# vim: ts=2 sw=2 et :
View
3  src/hubot/shell.coffee
@@ -26,4 +26,5 @@ class Shell extends Robot
holman = @userForId('3', {name: "Zach Holman"})
, 3000
-exports.Shell = Shell
+module.exports = Shell
+
View
3  src/hubot/twilio.coffee
@@ -88,4 +88,5 @@ class Twilio extends Robot
request.write params
request.end()
-exports.Twilio = Twilio
+module.exports = Twilio
+
View
2  src/hubot/xmpp.coffee
@@ -84,5 +84,5 @@ class XmppBot extends Robot
strings.forEach (str) =>
@send user, "#{user.name}: #{str}"
+module.exports = XmppBot
-exports.XmppBot = XmppBot
Please sign in to comment.
Something went wrong with that request. Please try again.