*** empty log message ***
authorMatthew Mondor <mmondor@pulsar-zone.net>
Mon, 27 Nov 2006 13:57:27 +0000 (13:57 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Mon, 27 Nov 2006 13:57:27 +0000 (13:57 +0000)
mmsoftware/js/js-sh/app/irclog/config.js [new file with mode: 0644]
mmsoftware/js/js-sh/app/irclog/irclog.js

diff --git a/mmsoftware/js/js-sh/app/irclog/config.js b/mmsoftware/js/js-sh/app/irclog/config.js
new file mode 100644 (file)
index 0000000..5920495
--- /dev/null
@@ -0,0 +1,39 @@
+/* $Id: config.js,v 1.1 2006/11/27 13:57:27 mmondor Exp $ */
+
+/* Configuration */
+var irc_channel = '#gurumeditation';
+var irc_servers = [
+       'irc.freenode.net:6667'
+       /*
+       'ginseng.xisop:6667',
+       'mudbug.org:6667'
+       */
+];
+var irc_nicknames = [
+       'nanobit',
+       'e-chemical',
+       'e-alchemy',
+       'nick_',
+       'nick__'
+];
+var irc_user = 'nanobit', irc_name = 'e-chemical e-alchemy';
+var irc_reconnect_delay = 10;
+var irc_op_passwd = 'somepassword', irc_quit_passwd = 'somepassword';
+var irc_part_message = 'Farewell';
+var irc_quit_message = 'Farewell';
+var irc_auto_whois = true;
+var irc_log_pings = false;
+
+/* XXX Would be more complex, but ideal
+var networks = [
+       {
+               name: "rubiks",
+               channels: [
+                       "#test"
+               ],
+               servers: [
+                       "ginseng.xisop:6667"
+               ]
+       }
+];
+*/
index 5114a9f..2de0e7d 100644 (file)
@@ -1,41 +1,34 @@
-/* $Id: irclog.js,v 1.7 2006/11/26 16:39:10 mmondor Exp $ */
-
-/* Configuration */
-var irc_channel = '#gurumeditation';
-var irc_servers = [
-       'irc.freenode.net:6667'
-       /*
-       'ginseng.xisop:6667',
-       'mudbug.org:6667'
-       */
-];
-var irc_nicknames = [
-       'nanobit',
-       'e-chemical',
-       'e-alchemy',
-       'nick_',
-       'nick__'
-];
-var irc_user = 'nanobit', irc_name = 'e-chemical e-alchemy';
-var irc_reconnect_delay = 10;
-var irc_version = '$Id: irclog.js,v 1.7 2006/11/26 16:39:10 mmondor Exp $';
-var irc_op_passwd = 'somepassword', irc_quit_passwd = 'somepassword';
-var irc_part_message = '$Id: irclog.js,v 1.7 2006/11/26 16:39:10 mmondor Exp $';
-var irc_quit_message = '$Id: irclog.js,v 1.7 2006/11/26 16:39:10 mmondor Exp $';
-
-/* XXX Would be more complex, but ideal
-var networks = [
-       {
-               name: "rubiks",
-               channels: [
-                       "#test"
-               ],
-               servers: [
-                       "ginseng.xisop:6667"
-               ]
+/* $Id: irclog.js,v 1.8 2006/11/27 13:57:27 mmondor Exp $ */
+
+var irc_version = '$Id: irclog.js,v 1.8 2006/11/27 13:57:27 mmondor Exp $';
+
+function file_read(name)
+{
+       var fh;
+       var data = '';
+
+       try {
+               fh = new File(name, 'r');
+       } catch (x) {
+               stderr.write('file_read() - open: ' + x + "\n");
+               return null;
        }
-];
-*/
+
+       try {
+               for (;;)
+                       data += fh.read(1, 16384);
+       } catch (x) {
+               if (!fh.eof()) {
+                       stderr.write('file_read() - read: ' + x + "\n");
+                       data = null;
+               }
+       }
+       fh.close();
+
+       return data;
+}
+
+eval (file_read('config.js'));
 
 
 
@@ -119,6 +112,9 @@ File.prototype.getline = function()
        /* Specifying false to gets() should strip these, but it's broken */
        line = line.substr(0, line.length - 2);
 
+       if (!irc_log_pings && line.match(/^PING :/) != null)
+               return line;
+
        /* Log input line as-is with timestamp immediately */
        stdout.write(log_timestamp() + ' < ' + line + "\n");
 
@@ -127,6 +123,11 @@ File.prototype.getline = function()
 
 File.prototype.putline = function(line)
 {
+       if (!irc_log_pings && line.match(/^PONG :/) != null) {
+               this.write(line + "\r\n");
+               return;
+       }
+
        stdout.write(log_timestamp() + ' > ' + line + "\n");
        this.write(line + "\r\n");
 }
@@ -174,7 +175,7 @@ File.prototype.state_nick = function()
 {
        var line, w;
 
-       stdout.write(log_timestamp() + ' -^- Entering state_nick()' + "\n");
+       stdout.write(log_timestamp() + ' -+- Entering state_nick()' + "\n");
 
        this.putline('NICK ' + select_nickname());
        for (;;) {
@@ -202,7 +203,7 @@ File.prototype.state_log = function()
 {
        var line, s, from, to, chan, msg, w;
 
-       stdout.write(log_timestamp() + ' -^- Entering state_log()' + "\n");
+       stdout.write(log_timestamp() + ' -+- Entering state_log()' + "\n");
 
        for (;;) {
                if (!on_channel) {
@@ -239,6 +240,9 @@ File.prototype.state_log = function()
                            msg.toLowerCase() == irc_channel.toLowerCase()) {
                                on_channel = true;
                                continue;
+                       } else if (irc_auto_whois) {
+                               this.putline('WHOIS ' + from);
+                               continue;
                        }
                }
 
@@ -326,7 +330,7 @@ function main()
                                   irc_part_message);
                fh.putline('QUIT :' + irc_quit_message);
        } catch (x) {
-               stdout.write(log_timestamp() + ' -*- Error: ' + x + "\n");
+               stdout.write(log_timestamp() + ' -+- Error: ' + x + "\n");
        }
        try {
                fh.close();