Find file
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (38 sloc) 1.56 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
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, #{}"
this.campfire.announce "#{} is out: #{reason}"
users_out[] = reason
# PT story link
bot.on '^!pt (.+)', (story_id, speaker) ->
this.speak "{story_id}"
bot.on '^!hello', (command, speaker) ->
this.speak "Hello there, #{}"
# 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[]
this.speak "Welcome back, #{}"
this.campfire.announce "#{} is back from: #{users_out[]}"
users_out[] = null