-/* $Id: irclog.js,v 1.4 2006/11/26 06:28:09 mmondor Exp $ */
+/* $Id: irclog.js,v 1.5 2006/11/26 15:42:06 mmondor Exp $ */
/* Configuration */
var irc_channel = '#gurumeditation';
];
var irc_user = 'nanobit', irc_name = 'e-chemical e-alchemy';
var irc_reconnect_delay = 10;
-var irc_version = '$Id: irclog.js,v 1.4 2006/11/26 06:28:09 mmondor Exp $';
+var irc_version = '$Id: irclog.js,v 1.5 2006/11/26 15:42:06 mmondor Exp $';
+var irc_op_passwd = 'somepassword', irc_quit_passwd = 'somepassword';
+var irc_part_message = 'Part message!';
+var irc_quit_message = 'Quit message!';
/* XXX Would be more complex, but ideal
var networks = [
this.putline('NOTICE ' + from + " :\001" +
'TIME ' + (new Date()).toUTCString() +
"\001");
+ return true;
}
- return true;
}
return false;
File.prototype.state_log = function()
{
- var line, from, to, chan, msg, w;
+ var line, s, from, to, chan, msg, w;
stdout.write(log_timestamp() + ' -^- Entering state_log()' + "\n");
sleep(++join_attempts);
if (join_attempts > 10)
join_attempts = 10;
- this.putline('JOIN :' + irc_channel);
+ this.putline('JOIN ' + irc_channel);
}
line = this.getline();
continue;
}
}
+
+ /* :<nick>!<user>@<host> PRIVMSG <to> :<message> */
+ if ((s = line.match(
+ /^:[^\b!:]*![^\b@:]*@[^\b:]* PRIVMSG [^\b:]* :/))
+ != null) {
+ s = s.toString();
+ msg = line.substr(s.length);
+ from = line.substr(1, line.indexOf('!') - 1);
+ w = line.split(' ');
+ to = w[2];
+ if (to.toLowerCase() == irc_nickname.toLowerCase()) {
+ if (on_channel &&
+ msg.match(/^!OP [\b]* [\b]*/) != null) {
+ w = msg.split(' ');
+ if (w[1] == irc_op_passwd)
+ this.putline('MODE ' +
+ irc_channel + ' +o ' +
+ from);
+ continue;
+ } else if (msg.match(/^!QUIT [\b]*/)
+ != null) {
+ w = msg.split(' ');
+ if (w[1] == irc_quit_passwd) {
+ should_quit = true;
+ break;
+ }
+ continue;
+ }
+ }
+ }
}
- this.putline('QUIT :' + irc_quit_message);
return false;
}
var line;
log_init();
+ should_quit = false;
for (;;) { try {
on_channel = false;
if (!fh.state())
break;
}
+ if (on_channel)
+ fh.putline('PART ' + irc_channel + ' :' +
+ irc_part_message);
+ fh.putline('QUIT :' + irc_quit_message);
} catch (x) {
stdout.write(log_timestamp() + ' -*- Error: ' + x + "\n");
}
} catch (x) {}
stdout.write(log_timestamp() + ' -+- Disconnected from ' +
server.address + ':' + server.port + "\n");
+ if (should_quit)
+ break;
sleep(irc_reconnect_delay);
}
}