Skip to content

Commit

Permalink
src: add cleverbot initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
maletor committed Nov 14, 2015
1 parent f0a0cc8 commit b7204b8
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright (c) 2015 Ellis Berner

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 12 additions & 0 deletions index.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fs = require 'fs'
path = require 'path'

module.exports = (robot, scripts) ->
scriptsPath = path.resolve(__dirname, 'src')
fs.exists scriptsPath, (exists) ->
if exists
for script in fs.readdirSync(scriptsPath)
if scripts? and '*' not in scripts
robot.loadFile(scriptsPath, script) if script in scripts
else
robot.loadFile(scriptsPath, script)
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "hubot-cleverbot",
"description": "Turns your bot into a snarky little shit",
"version": "1.0.0",
"author": "Ellis Berner <eberner@gmail.com>",
"license": "MIT",

"keywords": [
"hubot",
"hubot-scripts",
"clever",
"bot",
"cleverbot"
],

"repository": {
"type": "git",
"url": "git://github.com/maletor/hubot-cleverbot.git"
},

"bugs": {
"url": "https://github.com/maletor/hubot-cleverbot/issues"
},

"dependencies": {
"coffee-script": "~1.6",
"cleverbot-node": "~0.2.1"
},

"devDependencies": {
"mocha": "*",
"chai": "*"
},

"main": "index.coffee",

"scripts": {
"test": "script/test"
}
}
18 changes: 18 additions & 0 deletions script/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Make sure everything is development forever
export NODE_ENV=development

# Load environment specific environment variables
if [ -f .env ]; then
source .env
fi

if [ -f .env.${NODE_ENV} ]; then
source .env.${NODE_ENV}
fi

npm install

# Make sure coffee and mocha are on the path
export PATH="node_modules/.bin:$PATH"
6 changes: 6 additions & 0 deletions script/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# bootstrap environment
source script/bootstrap

mocha --compilers coffee:coffee-script
23 changes: 23 additions & 0 deletions src/cleverbot.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Description:
# Turns your bot into a snarky little shit
#
# Dependencies:
# "cleverbot-node": "0.2.1"
#
# Configuration:
# None
#
# Commands:
# hubot c <input>
#
# Author:
# maletor

cleverbot = require("cleverbot-node")

module.exports = (robot) ->
c = new cleverbot()

robot.respond /c (.*)/i, (msg) ->
data = msg.match[1].trim()
cleverbot.prepare(( -> c.write(data, (c) => msg.send(c.message))))
5 changes: 5 additions & 0 deletions test/cleverbot_test.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
chai = require 'chai'

expect = chai.expect

describe 'hello-world', ->

0 comments on commit b7204b8

Please sign in to comment.