Skip to content

provide message object to ctcp events #130

Merged
merged 3 commits into from Sep 6, 2013
View
13 docs/API.rst
@@ -303,28 +303,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
14 lib/irc.js
@@ -206,7 +206,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);
@@ -465,7 +465,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);
@@ -811,16 +811,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)
}
Something went wrong with that request. Please try again.