From f50e1111b0957df73dd67721c12b5ae28f16a630 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 5 Jun 2012 14:26:20 +0200 Subject: wip --- dynobot-irc.js | 8 +++++--- echo-bot/index.js | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/dynobot-irc.js b/dynobot-irc.js index 24dd2ee..8258930 100644 --- a/dynobot-irc.js +++ b/dynobot-irc.js @@ -80,7 +80,9 @@ function info(a, b, c) { var reallyConnect = true; if(reallyConnect) { - irc = new IrcClient(nick, realName, ident, 'irc.freenode.net', 6667); + var host = 'localhost'; + // host = 'irc.freenode.net'; + irc = new IrcClient(nick, realName, ident, host, 6667); } else { var msgHandler = function(line) { @@ -107,8 +109,8 @@ function Plugin(name, script) { } var plugins = [ -// new Plugin('echo', './echo-bot/index.js') - new Plugin('atom', './atom-bot/index.js') + new Plugin('echo', './echo-bot/index.js') +// new Plugin('atom', './atom-bot/index.js') ]; _.each(plugins, function(plugin) { diff --git a/echo-bot/index.js b/echo-bot/index.js index 8c932a8..de3ea54 100644 --- a/echo-bot/index.js +++ b/echo-bot/index.js @@ -8,15 +8,21 @@ var irc = function() { return new Proxy(IrcClient.prototype, 'irc', channel); }(); +function notice() { + irc.notice.apply(irc, arguments); + console.log.apply(null, arguments); +} + irc.on('privmsg', function(nick, channel, message) { -// console.log('privmsg: ', arguments); - irc.notice(channel, nick + ': ' + message); + notice(channel, nick + ': ' + message); }); -irc.join('#bitraf2', function() { - console.log('joined channel!'.green); +irc.on('join', function(nick, channel) { + notice(channel, 'hello ' + nick + '!'); }); -console.log("echo bot started".green); +irc.join('#bitraf2', function(nick, channel) { + notice(('on join: nick=' + nick + ', channel=' + channel).green); +}); -// process.exit(0); +console.log("echo bot started".green); -- cgit v1.2.3