summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--echo-bot/index.js13
-rw-r--r--irc-client.js4
2 files changed, 11 insertions, 6 deletions
diff --git a/echo-bot/index.js b/echo-bot/index.js
index de3ea54..234e450 100644
--- a/echo-bot/index.js
+++ b/echo-bot/index.js
@@ -1,4 +1,5 @@
require('tinycolor');
+var util = require('util');
var irc = function() {
var Proxy = require('../node_modules/dynobot/proxy');
var Channel = require('../node_modules/dynobot/channel');
@@ -8,9 +9,9 @@ var irc = function() {
return new Proxy(IrcClient.prototype, 'irc', channel);
}();
-function notice() {
- irc.notice.apply(irc, arguments);
- console.log.apply(null, arguments);
+function notice(channel, message) {
+ irc.notice(channel, message);
+ console.log(('NOTICE ' + channel + ' :' + message).green);
}
irc.on('privmsg', function(nick, channel, message) {
@@ -18,11 +19,11 @@ irc.on('privmsg', function(nick, channel, message) {
});
irc.on('join', function(nick, channel) {
- notice(channel, 'hello ' + nick + '!');
+ notice(channel, 'on join: hello ' + nick + '!');
});
-irc.join('#bitraf2', function(nick, channel) {
- notice(('on join: nick=' + nick + ', channel=' + channel).green);
+irc.join('#bitraf2', function(channel) {
+ notice(channel, 'join(): channel=' + channel);
});
console.log("echo bot started".green);
diff --git a/irc-client.js b/irc-client.js
index 9d0e616..275ee72 100644
--- a/irc-client.js
+++ b/irc-client.js
@@ -57,6 +57,10 @@ IrcClient.prototype.init = function(irc) {
client.connect();
}, 1000);
});
+ /**
+ * Make sure that client.join() calls are respected even across
+ * reconnects.
+ */
irc.on('join', function(nick, channelName) {
if(nick != irc.whoami()) {
return;