feat: customizable message for required params #36

Merged
amovah merged 4 commits from master into master 2017-09-12 16:04:27 +00:00
Showing only changes of commit bc5f14ebde - Show all commits

View File

@ -117,12 +117,7 @@ export default class Bot extends EventEmitter {
* gets the update * gets the update
* @return {object} returns the bot object * @return {object} returns the bot object
*/ */
command(command, customMessage, listener) { command(command, listener, customMessage = {}) {
if (!listener) {
listener = customMessage;
customMessage = {};
}
const regex = /[^\s]+/; const regex = /[^\s]+/;
const cmd = command.match(regex)[0].trim(); const cmd = command.match(regex)[0].trim();
@ -130,8 +125,8 @@ export default class Bot extends EventEmitter {
this._userEvents.push({ this._userEvents.push({
pattern: new RegExp(`^/${cmd}`), pattern: new RegExp(`^/${cmd}`),
parse: argumentParser.bind(null, command), parse: argumentParser.bind(null, command),
customMessage, listener,
listener customMessage
}); });
return this; return this;