/* !
 * hotbot
 * Copyright (c) 2016 Guillaume RUCH <shirase.dev@gmail.com>
 * MIT Licensed
 */

const EventEmitter = require('events');
const defaultConfig = {
	name: 'Command Name',
	args: {},
	help: 'describe args usage here',
	logLevel: 1
};

class Command extends EventEmitter {

	constructor(dataStore, config) {
		super();
		this.store = dataStore;
		this.config = Object.assign(defaultConfig, config);
		this.expected = {};
	}

	init() {
		if (this.config.logLevel > 0) {
			console.log('Placeholder - You may want to override the init() method of this Command.');
		}
	}

	requestModuleComponent(to, component, method) {
		this.emit('requestModuleComponent', {
			to,
			component,
			method
		});
	}

	execute(msg) {
		if (this.config.logLevel > 0) {
			console.log('Default - You may want to override the execute() method of this Command.');
		}

		const args = msg.text;

		if (args.length > 1) {
			this[args.shift()](args, msg.channel);
		}else {
			this[args[0]](msg.channel);
		}
	}

	send(m, c, cb) {
		const msg = m.replace(/(^")|("$)/g, '');

		this.emit('msg', {msg, chan: c});
		if (cb) {cb();}
	}

	sendMulti(m, chans) {
		chans.forEach(chan => this.send(m, chan));
	}

	reply() {
		if (this.config.logLevel > 0) {
			console.log('Placeholder - You may want to override the reply() method of this Command.');
		}
	}

	expect(id, obj, method) {
		this.expected[id] = obj;
		this.emit('expect', {chan: id, method: method || 'reply'});
	}

	rmExpect(chan) {
		this.expected[chan] = null;
		this.emit('rmExpect', chan);
	}

	log(log) {
		this.emit('log', log);
	}

	isExpected(chan) {
		return this.expected[chan];
	}

	getExpected(chan) {
		return this.expected[chan];
	}

	log(log) {
		this.emit('log', log);
	}

	blockify(msg) {
		return `\`\`\`${msg}\`\`\``;
	}

}

module.exports = Command;

@@ -130,16 +130,102 @@
 ents');%0A
+%0Aclass Command extends EventEmitter %7B%0A%0A%09constructor(dataStore, config) %7B%0A%09%09super();%0A%09%09
 const de
@@ -240,16 +240,18 @@
 fig = %7B%0A
+%09%09
 %09name: '
@@ -265,16 +265,18 @@
  Name',%0A
+%09%09
 %09args: %7B
@@ -278,16 +278,18 @@
 gs: %7B%7D,%0A
+%09%09
 %09help: '
@@ -315,16 +315,18 @@
  here',%0A
+%09%09
 %09logLeve
@@ -334,95 +334,14 @@
 : 1%0A
+%09%09
 %7D;%0A%0A
-class Command extends EventEmitter %7B%0A%0A%09constructor(dataStore, config) %7B%0A%09%09super();%0A
 %09%09th

fix breaking Command config