summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-06-14 18:42:09 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-06-14 18:42:09 +0200
commite971ae61c99c8a602a1d60c95e9f8f908d4cf053 (patch)
treecda91535e2d7d0b7183709939910c1b05534afd5
parentf50e1111b0957df73dd67721c12b5ae28f16a630 (diff)
downloaddynobot-irc-e971ae61c99c8a602a1d60c95e9f8f908d4cf053.tar.gz
dynobot-irc-e971ae61c99c8a602a1d60c95e9f8f908d4cf053.tar.bz2
dynobot-irc-e971ae61c99c8a602a1d60c95e9f8f908d4cf053.tar.xz
dynobot-irc-e971ae61c99c8a602a1d60c95e9f8f908d4cf053.zip
wip
-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;