From: Matthew Mondor Date: Sun, 26 Nov 2006 15:42:06 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: pgsql-branch-merge~69 X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=05db97dc73a1d2af852e1d27b5dc29ec44700c07;p=mmondor.git *** empty log message *** --- diff --git a/mmsoftware/js/js-sh/app/irclog/irclog.js b/mmsoftware/js/js-sh/app/irclog/irclog.js index 53d7679..2451519 100644 --- a/mmsoftware/js/js-sh/app/irclog/irclog.js +++ b/mmsoftware/js/js-sh/app/irclog/irclog.js @@ -1,4 +1,4 @@ -/* $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'; @@ -18,7 +18,10 @@ var irc_nicknames = [ ]; 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 = [ @@ -160,8 +163,8 @@ File.prototype.state_all = function(line) this.putline('NOTICE ' + from + " :\001" + 'TIME ' + (new Date()).toUTCString() + "\001"); + return true; } - return true; } return false; @@ -197,7 +200,7 @@ File.prototype.state_nick = function() 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"); @@ -206,7 +209,7 @@ File.prototype.state_log = function() sleep(++join_attempts); if (join_attempts > 10) join_attempts = 10; - this.putline('JOIN :' + irc_channel); + this.putline('JOIN ' + irc_channel); } line = this.getline(); @@ -253,9 +256,38 @@ File.prototype.state_log = function() continue; } } + + /* :!@ PRIVMSG : */ + 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; } @@ -267,6 +299,7 @@ function main() var line; log_init(); + should_quit = false; for (;;) { try { on_channel = false; @@ -287,6 +320,10 @@ function main() 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"); } @@ -296,6 +333,8 @@ function main() } catch (x) {} stdout.write(log_timestamp() + ' -+- Disconnected from ' + server.address + ':' + server.port + "\n"); + if (should_quit) + break; sleep(irc_reconnect_delay); } }