/**
 * Port of dbot/dbot's quotes feature
 */
var fs = require( 'fs' );
var quotes = {};
try {
	quotes = require( __rootdir + '/data/quotes.json' );
} catch ( e ) {
	//
}
module.exports = {
	commands: {
		qadd: {
			help: 'Add a quote',
			command: function ( bot, msg ) {
				var body = msg.body.split( '=' );
				var key = body.shift();
				body = body.join( '=' ); // so clunky
				if ( !body || !key ) {
					return 'Usage: ' + bot.config.irc.controlChar + 'qadd foo=bar';
				}
				if ( !quotes[key] ) {
					quotes[key] = [ body ];
				} else {
					quotes[key].push( body );
				}

				fs.writeFile( __rootdir + '/data/quotes.json', JSON.stringify( quotes, null, 4 ) );
				return 'Added quote "' + body + '" to "' + key + '".';
			}
		}
	}
};

@@ -729,10 +729,560 @@
 + '%22
-.'
+ (' + quotes%5Bkey%5D.length + ').';%0A%09%09%09%7D%0A%09%09%7D,%0A%09%09quote: %7B%0A%09%09%09help: 'Gets a quote',%0A%09%09%09command: function ( bot, msg ) %7B%0A%09%09%09%09try %7B%0A%09%09%09%09%09var q = quotes%5Bmsg.body%5D;%0A%09%09%09%09%09return q%5BMath.floor( Math.random()*q.length )%5D;%0A%09%09%09%09%7D catch ( e ) %7B%0A%09%09%09%09%09return e;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D,%0A%09%09quotel: %7B%0A%09%09%09help: 'Lists quote categories',%0A%09%09%09command: function () %7B%0A%09%09%09%09var str = '';%0A%09%09%09%09var keys = Object.keys( quotes );%0A%09%09%09%09for ( var i = 0; i %3C keys.length; i++ ) %7B%0A%09%09%09%09%09str += ' ' + keys%5Bi%5D + ' (' +quotes%5Bkeys%5Bi%5D%5D.length + ') %C2%B7';%0A%09%09%09%09%7D%0A%09%09%09%09return str.substring( 0, str.length - 1 )
 ;%0A%09%09

Add quote playback