Skip to content

Commit

Permalink
command-manager: add ability to define aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlucas committed Mar 17, 2016
1 parent 312d324 commit ee2fd09
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/command-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,27 @@ Manager.prototype.add = function add(name, desc, args) {
this._names.sort()
}

Manager.prototype.alias = function alias(name, orig) {
const obj = this.commands.get(orig)
if (!obj)
throw new Error('Cannot create alias. Original does not exist')

this.add(name, obj.description, obj.args)
}

Manager.prototype.addDefaults = function addDefaults() {
this.add('/action', 'Send action to target', '[channel|nickname] [msg]')
this.add('/action', 'Send action to target', '[target] [msg]')
this.add('/away', 'Set away status', '[away msg]')
this.add('/join', 'Join a channel', '([channel[,channel]], [key[,key]]) || 0')
this.add('/kick', 'Kick user from channel', '<channel> <user>')
this.add('/leave', 'Leave a channel', '[channel] [msg]')
this.alias('/me', '/action')
this.add('/mode', 'Set mode for target', '<nickname|channel> <mode>')
this.add('/motd', 'Get the MOTD for the target', '[target]')
this.add('/msg', 'Send message to target', '[nickname|channel] [msg]')
this.add('/nick', 'Set/change your nickname', '<nickname>')
this.add('/notice', 'Send notice to target', '[nickname|channel] [msg]')
this.add('/part', '(or /leave) Part from a channel', '[channel] [msg]')
this.alias('/part', '/leave')
this.add('/quit', 'Terminate session', '[msg]')
this.add('/topic', `Set/remove a channel's topic`, '[channel] [topic]')
}
Expand Down

0 comments on commit ee2fd09

Please sign in to comment.