Skip to content
Browse files

Fixed pm event and added more to example bot

  • Loading branch information...
1 parent be4f98a commit 39cd6cd779db9e5d1710c4110e20268cd4700d1d @martynsmith committed
Showing with 10 additions and 3 deletions.
  1. +1 −1 API.md
  2. +8 −1 example/bot.js
  3. +1 −1 lib/irc.js
View
2 API.md
@@ -97,7 +97,7 @@ As per 'message' event but only emits for the subscribed channel
### Event: 'pm'
-`function (text) { }`
+`function (nick, text) { }`
As per 'message' event but only emits when the message is direct to the client
View
9 example/bot.js
@@ -9,7 +9,11 @@ var http = require('http');
var bot = new irc.Client('irc.dollyfish.net.nz', 'nodebot', {
debug: true,
- channels: ['#blah'],
+ channels: ['#blah', '#test'],
+});
+
+bot.addListener('message#blah', function (from, message) {
+ sys.puts('<' + from + '> ' + message);
});
bot.addListener('message', function (from, to, message) {
@@ -31,6 +35,9 @@ bot.addListener('message', function (from, to, message) {
// private message
}
});
+bot.addListener('pm', function(nick, message) {
+ sys.puts('Got private message from ' + nick + ': ' + message);
+});
bot.addListener('join', function(channel, who) {
sys.puts(who + ' has joined ' + channel);
});
View
2 lib/irc.js
@@ -663,7 +663,7 @@ function Client(server, nick, opt) {
var text = message.args[1];
self.emit('message', from, to, text);
if ( to.match(/^[&#]/) ) self.emit('message' + to, from, text);
- if ( to == self.nick ) self.emit('pm', text);
+ if ( to == self.nick ) self.emit('pm', from, text);
if ( self.opt.debug && to == self.nick )
sys.log('GOT MESSAGE from ' + from + ': ' + text);

0 comments on commit 39cd6cd

Please sign in to comment.
Something went wrong with that request. Please try again.