Permalink
Browse files

Added user message support for PART

  • Loading branch information...
1 parent e145543 commit 3ab737f93b97d254c1ac7d8bf76ee3ee48411408 @qsheets committed Jan 21, 2013
Showing with 13 additions and 4 deletions.
  1. +2 −1 docs/API.rst
  2. +11 −3 lib/irc.js
View
@@ -78,11 +78,12 @@ Client
supports multiple JOIN arguments as a space separated string (similar to
the IRC protocol).
-.. js:function:: Client.part(channel, callback)
+.. js:function:: Client.part(channel, message, callback)
Parts the specified channel.
:param string channel: Channel to part
+ :param string message: Optional message to send upon leaving the channel
:param function callback: Callback to automatically subscribed to the
`part#channel` event, but removed after the first invocation.
View
@@ -743,7 +743,11 @@ Client.prototype.join = function(channel, callback) { // {{{
});
this.send.apply(this, ['JOIN'].concat(channel.split(' ')));
} // }}}
-Client.prototype.part = function(channel, callback) { // {{{
+Client.prototype.part = function(channel, message, callback) { // {{{
+ if ( typeof(message) === 'function' ) {
+ callback = message;
+ message = undefined;
+ }
if ( typeof(callback) == 'function' ) {
this.once('part' + channel, callback);
}
@@ -753,8 +757,12 @@ Client.prototype.part = function(channel, callback) { // {{{
if (this.opt.channels.indexOf(channel) != -1) {
this.opt.channels.splice(this.opt.channels.indexOf(channel), 1);
}
-
- this.send('PART', channel);
+
+ if (message) {
+ this.send('PART', channel, message);
+ } else {
+ this.send('PART', channel);
+ }
} // }}}
Client.prototype.say = function(target, text) { // {{{
var self = this;

0 comments on commit 3ab737f

Please sign in to comment.