Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added user message support for PART #140

Merged
merged 1 commit into from
Sep 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 11 additions & 3 deletions lib/irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down