var fs = require( 'fs' );
module.exports = {
	commands: {
		tumblr: {
			help: 'Returns a random question from a selection of viral Tumblr questions.',
			aliases: [ 'truth', 'question', 'conversationprompt' ],
			command: function ( bot, msg ) {
				var file = fs.readFileSync( __rootdir + '/data/tumblr.txt', { encoding: 'utf-8' } );
				var questions = file.split( '\n' );
				var index = msg.args[1] || Math.floor( Math.random() * questions.length );
				var question = questions[index];
				if ( question ) {
					return '[Question ' + index + '] ' + questions[index];
				}
				return 'Question not found.';
			}
		}
	}
};

@@ -1,250 +1,818 @@
-var fs = require( 'fs' );%0Amodule.exports = %7B%0A%09commands: %7B%0A%09%09tumblr: %7B%0A%09%09%09help: 'Returns a random question from a selection of viral Tumblr questions.',%0A%09%09%09aliases: %5B 'truth', 'question', 'conversationprompt' %5D,%0A%09%09%09command: function ( bot, msg ) %7B
+/**%0A * Select a random question from a list, and display it.%0A *%0A * If an ID is given, display that question.%0A * If it isn't, give the last question, plus one.%0A * If that's not possible, show a random question.%0A *%0A * This module needs rewriting.%0A */%0Avar fs = require( 'fs' );%0Avar id = null; // TODO do this properly%0Amodule.exports = %7B%0A%09commands: %7B%0A%09%09tumblr: %7B%0A%09%09%09help: 'Returns a random question from a selection of viral Tumblr questions.',%0A%09%09%09aliases: %5B 'truth', 'question', 'conversationprompt' %5D,%0A%09%09%09command: function ( bot, msg ) %7B%0A%09%09%09%09if ( msg.args%5B1%5D === 'clear' ) %7B%0A%09%09%09%09%09id = null;%0A%09%09%09%09%09return 'Wiped history.';%0A%09%09%09%09%7D else if ( msg.args%5B1%5D === 'set' ) %7B%0A%09%09%09%09%09if ( msg.args%5B2%5D ) %7B%0A%09%09%09%09%09%09id = parseInt( msg.args%5B2%5D, 10 );%0A%09%09%09%09%09%09return 'Set counter to ' + id;%0A%09%09%09%09%09%7D%0A%09%09%09%09%09return 'Unable to set counter.';%0A%09%09%09%09%7D
 %0A%09%09%09
@@ -949,30 +949,14 @@
 var 
-index = msg.args%5B1%5D %7C%7C
+rand =
  Mat
@@ -996,24 +996,103 @@
 s.length );%0A
+%09%09%09%09var index = msg.args%5B1%5D %7C%7C id %7C%7C rand;%0A%09%09%09%09id = parseInt( index, 10 ) + 1;%0A
 %09%09%09%09var ques
@@ -1125,16 +1125,17 @@
 %09%09%09if ( 
+!
 question
@@ -1148,61 +1148,69 @@
 %09%09%09%09
-return '%5BQuestion ' + index + '%5D ' + questions%5Bindex%5D
+id = null;%0A%09%09%09%09%09question = questions%5Brand%5D;%0A%09%09%09%09%09index = rand
 ;%0A%09%09
@@ -1225,16 +1225,17 @@
 return '
+%5B
 Question
@@ -1239,19 +1239,60 @@
 ion 
-not found.'
+' + index + '/' + questions.length + '%5D ' + question
 ;%0A%09%09

Remember question history