Permalink
Browse files

Merge pull request #130 from damianb/master

provide message object to ctcp events
  • Loading branch information...
2 parents bafa696 + aa07660 commit eb24a0aabdf7b19861ab3865ce9ae9ef7d917478 @martynsmith committed Sep 6, 2013
Showing with 15 additions and 12 deletions.
  1. +8 −5 docs/API.rst
  2. +7 −7 lib/irc.js
View
@@ -313,28 +313,31 @@ Events
.. js:data:: 'ctcp'
- `function (from, to, text, type) { }`
+ `function (from, to, text, type, message) { }`
Emitted when a CTCP notice or privmsg was received (`type` is either `'notice'`
- or `'privmsg'`).
+ or `'privmsg'`). See the `raw` event for details on the `message` object.
.. js:data:: 'ctcp-notice'
- `function (from, to, text) { }`
+ `function (from, to, text, message) { }`
Emitted when a CTCP notice was received.
+ See the `raw` event for details on the `message` object.
.. js:data:: 'ctcp-privmsg'
- `function (from, to, text) { }`
+ `function (from, to, text, message) { }`
Emitted when a CTCP privmsg was received.
+ See the `raw` event for details on the `message` object.
.. js:data:: 'ctcp-version'
- `function (from, to) { }`
+ `function (from, to, message) { }`
Emitted when a CTCP VERSION request was received.
+ See the `raw` event for details on the `message` object.
.. js:data:: 'nick'
View
@@ -207,7 +207,7 @@ function Client(server, nick, opt) {
}
var text = message.args[1];
if (text[0] === '\1' && text.lastIndexOf('\1') > 0) {
- self._handleCTCP(from, to, text, 'notice');
+ self._handleCTCP(from, to, text, 'notice', message);
break;
}
self.emit('notice', from, to, text, message);
@@ -467,7 +467,7 @@ function Client(server, nick, opt) {
var to = message.args[0];
var text = message.args[1];
if (text[0] === '\1' && text.lastIndexOf('\1') > 0) {
- self._handleCTCP(from, to, text, 'privmsg');
+ self._handleCTCP(from, to, text, 'privmsg', message);
break;
}
self.emit('message', from, to, text, message);
@@ -836,16 +836,16 @@ Client.prototype._clearWhoisData = function(nick) { // {{{
delete this._whoisData[nick];
return data;
} // }}}
-Client.prototype._handleCTCP = function(from, to, text, type) {
+Client.prototype._handleCTCP = function(from, to, text, type, message) {
text = text.slice(1)
text = text.slice(0, text.indexOf('\1'))
var parts = text.split(' ')
- this.emit('ctcp', from, to, text, type)
- this.emit('ctcp-'+type, from, to, text)
+ this.emit('ctcp', from, to, text, type, message)
+ this.emit('ctcp-'+type, from, to, text, message)
if (type === 'privmsg' && text === 'VERSION')
- this.emit('ctcp-version', from, to)
+ this.emit('ctcp-version', from, to, message)
if (parts[0] === 'ACTION' && parts.length > 1)
- this.emit('action', from, to, parts.slice(1).join(' '))
+ this.emit('action', from, to, parts.slice(1).join(' '), message)
if (parts[0] === 'PING' && type === 'privmsg' && parts.length > 1)
this.ctcp(from, 'notice', text)
}

0 comments on commit eb24a0a

Please sign in to comment.