Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

53 lines (38 sloc) 1.596 kb
marshmallow = require("./lib/marshmallow").marshmallow
fs = require('fs')
yaml = require('yaml')
users_out = { }
fs.readFile 'config.yml', "utf8", (e, data) ->
throw e if e
try
config = yaml.eval(data).campfire
console.log "Crankybot is alive with the following settings:"
console.log config
catch e
console.log "Failed to load #{config}"
throw e
marshmallow config, (bot) ->
bot.on '^!blame (.*)', (blamee, speaker) ->
this.speak "It's all #{blamee}'s fault"
bot.on '^!out (.*)', (reason, speaker) ->
this.speak "Have fun, #{speaker.name}"
this.campfire.announce "#{speaker.name} is out: #{reason}"
users_out[speaker.id] = reason
# PT story link
bot.on '^!pt (.+)', (story_id, speaker) ->
this.speak "https://www.pivotaltracker.com/story/show/#{story_id}"
bot.on '^!hello', (command, speaker) ->
this.speak "Hello there, #{speaker.name}"
# Basic ping function
bot.on '^!ping', (command, speaker) ->
this.speak 'Pong!'
# Spit out what tricks this doggy knows
bot.on '^!tricks', (command, speaker) ->
tricks = for trick of bot.tricks() when trick != 'catchAll'
trick.replace(/\^/, '').split(' ')[0]
this.speak "I know the following tricks: #{tricks.join(', ')}"
bot.on 'catchAll', (rawMessage, speaker) ->
if users_out[speaker.id]
this.speak "Welcome back, #{speaker.name}"
this.campfire.announce "#{speaker.name} is back from: #{users_out[speaker.id]}"
users_out[speaker.id] = null
Jump to Line
Something went wrong with that request. Please try again.