Permalink
Browse files

Merge pull request #140 from qsheets/part-message

Added user message support for PART
  • Loading branch information...
2 parents 3f8e1c9 + 3ab737f commit 71c21e5543f2bbaa594156e9859d2f0fadedd5b3 @martynsmith committed Sep 6, 2013
Showing with 13 additions and 4 deletions.
  1. +2 −1 docs/API.rst
  2. +11 −3 lib/irc.js
View
@@ -82,11 +82,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
@@ -766,7 +766,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);
}
@@ -776,8 +780,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 71c21e5

Please sign in to comment.