Skip to content

Commit

Permalink
Merge branch 'master' into email
Browse files Browse the repository at this point in the history
Conflicts:
	package.json
  • Loading branch information
atmos committed Oct 28, 2011
2 parents 80088f2 + f90834c commit 5c76e7c
Show file tree
Hide file tree
Showing 34 changed files with 1,264 additions and 198 deletions.
49 changes: 49 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,49 @@
v1.1.2
======
* Fix the optparse npm install anomaly

v1.1.1
======
* Fix campfire adapter getting duplicate messages - atmos

v1.1.0
======

* Explicity errors for misconfigured campfire setup - Damien Mathieu <damien.mathieu@shazino.com>
* Support '-v' as a CLI opt to display version - Damien Mathieu <damien.mathieu@shazino.com>
* Tons of fixups to the hipchat adapter - Codafoo <cesar@webzense.net>, Assaf Arkin <assaf@labnotes.org>
* Various IRC adapter fixups - Mark Paschal <markpasc@markpasc.org>, Jesse Szwedko
* Enter/Leave events for adapters - Brian Donovan <me@brian-donovan.com>
* XMPP adapter fixups - codec <codec@fnord.cx>,
* Break out persistence layer to make it easier to have multiple backends - technoweenie
* Various refactorings/cleanups - Tom Bell <tomb@tombell.org.uk>
* translation script enhancements - OiNutter <willmckenzie@oinutter.co.uk>
* XMPP user persistence fixups - Andy Fowler <andy@andyfowler.com>

Upgrading
---------
If you're using the redis persistence you're going to need to enable
'redis-brain.coffee' in your hubot-scripts.json file. It was moved
there and the brain now supports events allowing you to use any
persistence backend you want.

v1.0.5
======

* Remove infinite loop script to keep things alive - atmos

v1.0.4
======

* HipChat adapter support - Assaf Arkin <assaf@labnotes.org>
* XMPP adapter support - Andy Fowler <andy@andyfowler.com>
* Twilio adapter fixups - Jesse Newland <jesse@jnewland.com>
* Fixup hubot-scripts.json template examples - Mike Skalnik <mike.skalnik@gmail.com>

v1.0.3
======

* Fix IRC adapter replies - Scott Moak <scott.moak@gmail.com>
* Ensure people are running node 0.4.x - Corey Donohoe <atmos@atmos.org>
* Doc fixups - Aitor García Rey <aitor@linkingpaths.com>
* Twilio adapter support - Tom Bell <tomb@tombell.org.uk>
8 changes: 8 additions & 0 deletions Makefile
@@ -1,3 +1,7 @@
NPM_EXECUTABLE_HOME := node_modules/.bin

PATH := ${NPM_EXECUTABLE_HOME}:${PATH}

test: deps
@find test -name '*_test.coffee' | xargs -n 1 -t coffee

Expand All @@ -7,6 +11,10 @@ dev: generate-js
generate-js:
@find src -name '*.coffee' | xargs coffee -c -o lib

package:
@bin/hubot -c hubot
@chmod 0755 hubot/bin/hubot

remove-js:
@rm -fr lib/

Expand Down
36 changes: 23 additions & 13 deletions README.md
@@ -1,25 +1,35 @@
Hubot
=====
# Hubot

This is a version of GitHub's Campfire bot, hubot. He's pretty cool.
This is a version of GitHub's Campfire bot, hubot. He's pretty cool.

Getting Your Own
================
You'll probably never have to hack on this repo directly. Instead this
repo provides a library that's distributed by npm that you simply
require in your project.

% hubot -c ~/eptics
## Getting Your Own

Then follow the instructions in the ~/eptics folder
Make sure you have [node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.

Local Testing
=============
Download the [latest version of hubot](https://github.com/github/hubot/downloads).

Install all of the required dependencies by running `npm install`
Then follow the instructions in the README in the `hubot` directory.

It's easy to test scripts locally with the shell:
## Scripts

Hubot ships with a couple of default scripts, but there's a growing
number of extras in the [hubot-scripts](https://github.com/github/hubot-scripts)
repository. `hubot-scripts` is a way to share scripts with the entire
community. Check out the [README](https://github.com/github/hubot-scripts#readme)
for more help on installing individual scripts.

## Local Testing

Install all of the required dependencies by running `npm install`.

It's easy to test scripts locally with an interactive shell:

% bin/hubot

Run tests:
...and to run tests:

% make test

65 changes: 38 additions & 27 deletions bin/hubot
Expand Up @@ -4,21 +4,23 @@
#
# Launch an interactive hubot
#
require.paths.unshift __dirname + "/../node_modules"
require.paths.unshift __dirname + "/../src"

Hubot = require '..'
Fs = require 'fs'
Path = require 'path'
HTTP = require 'http'
Creator = require 'creator'
Creator = require '../src/creator'
OptParse = require 'optparse'
PortNumber = parseInt(process.env.PORT) || 8080

Adapters = ["irc", "campfire", "hipchat", "twilio", "xmpp", "groupme"]
Switches = [
[ "-h", "--help", "Display the help information"],
[ "-a", "--adapter ADAPTER", "The Adapter to use"],
[ "-c", "--create PATH", "Create a deployable hubot"],
[ "-n", "--name NAME", "The name of the robot in chat" ]
[ "-s", "--enable-slash", "Enable replacing the robot's name with '/'"],
[ "-n", "--name NAME", "The name of the robot in chat" ],
[ "-v", "--version", "Displays the version of hubot installed"]
]

Options =
Expand All @@ -40,23 +42,47 @@ Parser.on "create", (opt, value) ->
Options.path = value
Options.create = true

Parser.on "enable-slash", (opt) ->
Options.enableSlash = true

Parser.on "help", (opt, value) ->
console.log Parser.toString()
process.exit 0

Parser.on "version", (opt, value) ->
Options.version = true

Parser.parse process.ARGV

process.on 'SIGTERM', -> process.exit(0)

if Options.create
creator = new Creator.Creator(Options.path)
creator.run()

else if Options.version
package_path = __dirname + "/../package.json"

Fs.readFile package_path, (err,data) ->
if err
console.error "Could not open package file : %s", err
process.exit 1

content = JSON.parse(data.toString('ascii'))
console.log content['version']

process.exit 0

else
switch Options.adapter
when "irc"
Hubot = require("hubot/irc").IrcBot
when "campfire"
Hubot = require("hubot/campfire").Campfire
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.loadBot adapter, scriptsPath, Options.name
robot.enableSlash = Options.enableSlash

scriptsPath = Path.resolve "src", "hubot", "scripts"
console.log "Loading hubot core scripts for relative scripts at #{scriptsPath}"
Expand All @@ -76,19 +102,4 @@ else

robot.run()

if webHost = process.env.HUBOT_WEB_HOST
server = HTTP.createServer( (req, res) ->
res.writeHead 200, 'Content-Type': 'text/plain'
res.end 'Hello from Hubot\n'
).listen PortNumber

setInterval ->
httpOpts = host: webHost

HTTP.get( httpOpts, (res) ->
console.log "Got response: #{res}" unless res.statusCode == 200
).on 'error', (e) ->
console.log "Got error: #{e.message}"
, 60000

# vim:ft=coffee ts=2 sw=2 et :
17 changes: 17 additions & 0 deletions index.coffee
@@ -0,0 +1,17 @@
# This is the Hubot Loading Bay. NPM uses it as an entry point.
#
# Hubot = require 'hubot'
# YourBot = Hubot.robot 'campfire', 'blah', 'yourbot'

# Loads a Hubot robot
exports.loadBot = (adapterName, path, botName) ->
robot = require "./src/hubot/#{adapterName}"
new robot path, botName

exports.robot = ->
require './src/robot'

# Loads the Hubot test harness.
exports.tests = ->
require './test/tests'

18 changes: 11 additions & 7 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "hubot",
"version": "0.1.0",
"author": "GitHub Inc.",
"version": "1.1.3",
"author": "hubot",
"keywords": "github hubot campfire bot",
"description": "A simple helpful Robot for your Company",
"licenses": [{
Expand All @@ -19,14 +19,18 @@
"optparse": "1.0.1",
"scoped-http-client": "0.9.0",
"irc": "0.2",
"scoped-http-client": "0.9.4",
"irc": "0.2",
"node-xmpp": ">=0.2.6",
"wobot": "0.3.0",
"imap": "0.2.5"
},

"directories": {
"lib": "./src"
},
"main": "./src/hubot",
"main": "./index",

"bin": {
"hubot": "./bin/hubot"
}
},

"engine": "node >= 0.4.1 < 0.5.0"
}
31 changes: 17 additions & 14 deletions src/creator.coffee
Expand Up @@ -34,30 +34,33 @@ class Creator
# they want. It also provides them with a few examples and a top
# level scripts folder
#
# path - The destination
# path - The destination
copyDefaultScripts: (path) ->
copy = @copy
scriptsDir = @scriptsDir
Fs.readdirSync(scriptsDir).forEach (file) ->
copy "#{scriptsDir}/#{file}", "#{path}/#{file}"
for file in Fs.readdirSync(@scriptsDir)
@copy "#{@scriptsDir}/#{file}", "#{path}/#{file}"

# Run the creator process
#
# Setup a ready to deploy folder that uses the hubot npm package
# Overwriting basic hubot files if they exist
run: ->
path = @path
copy = @copy
templates = @templateDir
console.log "Creating a hubot install at #{@path}"

console.log "Creating a hubot install at #{path}"
@mkdirDashP(@path)
@mkdirDashP("#{@path}/bin")
@mkdirDashP("#{@path}/scripts")

@mkdirDashP(path)
@mkdirDashP("#{path}/scripts")
@copyDefaultScripts("#{@path}/scripts")

@copyDefaultScripts("#{path}/scripts")
files = [
"Procfile",
"package.json",
"README.md",
".gitignore",
"bin/hubot",
"hubot-scripts.json"
]

["Procfile", "package.json", "README.md"].forEach (file) ->
copy "#{templates}/#{file}", "#{path}/#{file}"
@copy "#{@templateDir}/#{file}", "#{@path}/#{file}" for file in files

exports.Creator = Creator

0 comments on commit 5c76e7c

Please sign in to comment.