• How to create options for

    From martylake@VERT to All on Mon Dec 6 20:31:00 2021
    Dear All,

    Following up on today's (yesterday?) discussion on IRC, I am trying to load modpots.js for irc.js to have a new option utf8_support. However, I get an error typeerror options is null.

    How do you create new option types or category ?

    Best,
    martylake

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Digital Man@VERT to martylake on Tue Dec 7 07:54:00 2021
    Re: How to create options for modopt
    By: martylake to All on Tue Dec 07 2021 01:31 am

    Dear All,

    Following up on today's (yesterday?) discussion on IRC, I am trying to load modpots.js for irc.js to have a new option utf8_support. However, I get an error typeerror options is null.

    How do you create new option types or category ?

    Did you read this: http://wiki.synchro.net/config:modopts.ini ?
    --
    digital man (rob)

    This Is Spinal Tap quote #30:
    Big bottom, big bottom / Talk about mud flaps, my girl's got 'em!
    Norco, CA WX: 59.6øF, 80.0% humidity, 3 mph NW wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From martylake@VERT to Digital Man on Tue Dec 7 18:40:00 2021
    Re: How to create options for modopt
    By: martylake to All on Tue Dec 07 2021 01:31 am

    Did you read this: http://wiki.synchro.net/config:modopts.ini ?

    Not yet ! Thank you very much for the link.

    Here is a patch for fixing irc.js encoding scrambling, it consists of two parts:
    * convert incoming UTF8 to CP437 when communicating with a server, but the client is not UTF8
    * convert to UTF8 when sending messages to the client, if supported

    Not sure if it's the optimal way of implementing this, I had the expected behavior with thes two test setup:
    * synchronet's irc server:
    * syncterm
    * ubuntu terminal utf8 ssh
    * irc client via znc utf8
    * inspircd server
    * syncterm
    * ubuntu terminal utf8 ssh
    * irc client via znc utf8

    Best,
    martylake



    From 1414ee4803d1e71749a160a56d783df68668b4a5 Mon Sep 17 00:00:00 2001
    From: martylake <redactedmail@example.com>
    Date: Wed, 8 Dec 2021 08:15:12 +0100
    Subject: [PATCH 1/2] When the user console is not UTF8, encode and decode
    from/to CP437

    ---
    exec/irc.js | 9 +++++++++
    1 file changed, 9 insertions(+)

    diff --git a/exec/irc.js b/exec/irc.js
    index 233bbef77..ad1afd246 100644
    --- a/exec/irc.js
    +++ b/exec/irc.js
    @@ -34,6 +34,8 @@ var real_names=true;
    js.on_exit("console.ctrlkey_passthru = " + console.ctrlkey_passthru);
    console.ctrlkey_passthru=~(134217728);

    +var options = load('modopts.js', 'fseditor');
    +var utf8_support = ((options && options.utf8_support) || true) && console.term_supports(USER_UTF8); //default to true
    // Commands to send...
    var client_cmds = {
    'PASS':{minparam:1,maxparam:1}, // Must be sent before NICK/USER
    @@ -223,6 +225,10 @@ function send_cmd(command, params)
    screen.print_line("\x01H\x01R!! \x01N\x01R"+command+" requires at least "+cmd.minparam+" parameters\x01N\x01W");
    return;
    }
    + if(!utf8_support)
    + {
    + snd = utf8_encode(snd);
    + }
    sock.send(snd+"\r\n");
    }

    @@ -566,6 +572,9 @@ function get_command()
    line=sock.recvline();
    if(!line)
    return;
    + if(!utf8_support){
    + line=utf8_decode(line);
    + }

    if (line[0] == '@') {
    tag = line.slice(1, line.indexOf(" "));
    --
    2.32.0




    From aa423963801089e80dfb0a7fb8fe89385e4f3ff2 Mon Sep 17 00:00:00 2001
    From: martylake <redactedmail@example.com>
    Date: Wed, 8 Dec 2021 08:16:29 +0100
    Subject: [PATCH 2/2] When the user console is UTF8, use UTF8 pmode for console
    prints.

    ---
    exec/irc.js | 27 ++++++++++++++++-----------
    1 file changed, 16 insertions(+), 11 deletions(-)

    diff --git a/exec/irc.js b/exec/irc.js
    index ad1afd246..672dc73c0 100644
    --- a/exec/irc.js
    +++ b/exec/irc.js
    @@ -33,9 +33,14 @@ var loading=true;
    var real_names=true;
    js.on_exit("console.ctrlkey_passthru = " + console.ctrlkey_passthru);
    console.ctrlkey_passthru=~(134217728);
    +var pmode = 0;

    var options = load('modopts.js', 'fseditor');
    var utf8_support = ((options && options.utf8_support) || true) && console.term_supports(USER_UTF8); //default to true
    +if(utf8_support)
    +{
    + pmode |= P_UTF8;
    +}
    // Commands to send...
    var client_cmds = {
    'PASS':{minparam:1,maxparam:1}, // Must be sent before NICK/USER
    @@ -1072,9 +1077,9 @@ function Screen_update_statline() {
    cname=channels.current.display;
    topic=channels.current.topic;
    }
    - console.print(this.topicline);
    + console.print(this.topicline, pmode);
    console.crlf();
    - console.print(this.statusline);
    + console.print(this.statusline, pmode);
    console.crlf();
    this.update_input_line();
    }
    @@ -1225,12 +1230,12 @@ function Screen_print_line(line) {
    if(lastspace==linestart-1) {
    lastspace=j;
    }
    -
    console.print(prev_colour+line.substring(linestart,lastspace+1));
    +
    console.print(prev_colour+line.substring(linestart,lastspace+1), pmode);
    prev_colour=last_colour;
    console.cleartoeol();
    console.crlf();
    this.line.shift();
    -
    this.line.push(prev_colour+line.substring(linestart,lastspace+1));
    +
    this.line.push(prev_colour+line.substring(linestart,lastspace+1), pmode);
    linestart=lastspace+1;
    j=lastspace;
    i=0;
    @@ -1240,10 +1245,10 @@ function Screen_print_line(line) {
    }
    }
    if(i<=78) {
    - console.print(prev_colour+line.substr(linestart));
    + console.print(prev_colour+line.substr(linestart), pmode);
    console.cleartoeol();
    this.line.shift();
    - this.line.push(prev_colour+line.substr(linestart));
    + this.line.push(prev_colour+line.substr(linestart), pmode);
    console.crlf();
    }
    if(!connected) {
    @@ -1262,9 +1267,9 @@ function Screen_print_line(line) {
    cname=channels.current.display;
    topic=channels.current.topic;
    }
    - console.print(this.topicline);
    + console.print(this.topicline, pmode);
    console.crlf();
    - console.print(this.statusline);
    + console.print(this.statusline, pmode);
    console.crlf();
    this.update_input_line();
    }
    @@ -1299,7 +1304,7 @@ function Screen_update_input_line() {
    console.line_counter=0; // defeat pause
    console.ansi_gotoxy(1,console.screen_rows);
    console.clearline();
    - printf("%s",line_str);
    + console.print(line_str, pmode);
    console.ansi_gotoxy(line_pos+1,console.screen_rows);
    }

    @@ -1431,9 +1436,9 @@ function Screen_handle_key(key) {

    console.ansi_gotoxy(1,console.screen_rows-2);
    console.clearline();
    console.handle_ctrlkey(key,0); // for now
    - console.print(this.topicline);
    + console.print(this.topicline, pmode);
    console.crlf();
    - console.print(this.statusline);
    + console.print(this.statusline, pmode);
    console.crlf();
    this.update_input_line();
    }
    --
    2.32.0
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Digital Man@VERT to martylake on Wed Dec 8 04:33:00 2021
    Re: Re: How to create options for modopt
    By: martylake to Digital Man on Tue Dec 07 2021 11:40 pm

    +var utf8_support = ((options && options.utf8_support) || true) && console.term_supports(USER_UTF8); //default to true

    Did you try setting utf8_support = false in the modopts.ini file? It doesn't look like this logic would work to me. The "|| true" would make the UTF-8 support *always* enabled (when the terminal supports UTF-8).
    --
    digital man (rob)

    Breaking Bad quote #39:
    Vacuum cleaner repair? What did you expect? Haji's quick vanish? - Saul
    Norco, CA WX: 55.7øF, 94.0% humidity, 0 mph S wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From martylake@VERT to Digital Man on Wed Dec 8 16:28:00 2021
    Re: Re: How to create options for modopt
    By: martylake to Digital Man on Tue Dec 07 2021 11:40 pm

    Did you try setting utf8_support = false in the modopts.ini file? It doesn't look like this logic would work to me. The "|| true" would make the UTF-8 support *always* enabled (when the terminal supports UTF-8).

    No I had not tried to set utf8_support in the modopt.ini . After trying, the option is indeed ignored by " || true".
    What I wanted to express is: "true unless the option exists and is set". See diff below, this time I manually tested that it works for all 3 cases: option section missing, option disabled and option enabled.

    Also the option should probably sit in "chat_sec" section, not "fseditor". Reflected in bellow's diff.



    diff --git a/exec/irc.js b/exec/irc.js
    index 672dc73c0..44e21620c 100644
    --- a/exec/irc.js
    +++ b/exec/irc.js
    @@ -35,8 +35,12 @@ js.on_exit("console.ctrlkey_passthru = " + console.ctrlkey_passthru);
    console.ctrlkey_passthru=~(134217728);
    var pmode = 0;

    -var options = load('modopts.js', 'fseditor');
    +var options = load('modopts.js', 'chat_sec');
    -var utf8_support = ((options && options.utf8_support) || true) && console.term_supports(USER_UTF8); //default to true
    +var utf8_support = true;
    +if(options && options.utf8_support)
    +{
    + utf8_support = console.term_supports(USER_UTF8);
    +}
    if(utf8_support)
    {
    pmode |= P_UTF8;
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Digital Man@VERT to martylake on Thu Dec 9 06:55:00 2021
    Re: Re: How to create options for modopt
    By: martylake to Digital Man on Wed Dec 08 2021 09:28 pm

    Re: Re: How to create options for modopt
    By: martylake to Digital Man on Tue Dec 07 2021 11:40 pm

    Did you try setting utf8_support = false in the modopts.ini file? It doesn't look like this logic would work to me. The "|| true" would make the UTF-8 support *always* enabled (when the terminal supports UTF-8).

    No I had not tried to set utf8_support in the modopt.ini . After trying, the option is indeed ignored by " || true".
    What I wanted to express is: "true unless the option exists and is set". See diff below, this time I manually tested that it works for all 3 cases: option section missing, option disabled and option enabled.

    Also the option should probably sit in "chat_sec" section, not "fseditor". Reflected in bellow's diff.

    Actually, the appropriate module name would be "irc" (and thus the section in modopts.ini would be [irc]). :-)
    --
    digital man (rob)

    Breaking Bad quote #11:
    My apologies to the HR department: Grow tumescent with anticipation. - Hank Norco, CA WX: 53.7øF, 92.0% humidity, 8 mph N wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Digital Man@VERT to martylake on Thu Jan 6 17:20:00 2022
    Re: Re: How to create options for modopt
    By: martylake to Digital Man on Wed Dec 08 2021 09:28 pm

    Re: Re: How to create options for modopt
    By: martylake to Digital Man on Tue Dec 07 2021 11:40 pm

    Did you try setting utf8_support = false in the modopts.ini file? It doesn't look like this logic would work to me. The "|| true" would make the UTF-8 support *always* enabled (when the terminal supports UTF-8).

    No I had not tried to set utf8_support in the modopt.ini . After trying, the option is indeed ignored by " || true".
    What I wanted to express is: "true unless the option exists and is set". See diff below, this time I manually tested that it works for all 3 cases: option section missing, option disabled and option enabled.

    Also the option should probably sit in "chat_sec" section, not "fseditor". Reflected in bellow's diff.



    diff --git a/exec/irc.js b/exec/irc.js
    index 672dc73c0..44e21620c 100644
    --- a/exec/irc.js
    +++ b/exec/irc.js
    @@ -35,8 +35,12 @@ js.on_exit("console.ctrlkey_passthru = " + console.ctrlkey_passthru);
    console.ctrlkey_passthru=~(134217728);
    var pmode = 0;

    -var options = load('modopts.js', 'fseditor');
    +var options = load('modopts.js', 'chat_sec');
    -var utf8_support = ((options && options.utf8_support) || true) && console.term_supports(USER_UTF8); //default to true
    +var utf8_support = true;
    +if(options && options.utf8_support)
    +{
    + utf8_support = console.term_supports(USER_UTF8);
    +}
    if(utf8_support)
    {
    pmode |= P_UTF8;

    Did you ever get this patch into a final state? The ideal thing would be to submit a merge request at gitlab.synchro.net. I'd be happy to accept/merge it into our master branch if you're happy with it.
    --
    digital man (rob)

    Rush quote #41:
    Angels and demons dancing in my head, lunatics and monsters underneath my bed Norco, CA WX: 57.4øF, 71.0% humidity, 2 mph E wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Digital Man@VERT to martylake on Mon Jan 17 17:18:00 2022
    Re: Re: How to create options for modopt
    By: Digital Man to martylake on Thu Jan 06 2022 10:20 pm

    Did you ever get this patch into a final state? The ideal thing would be to submit a merge request at gitlab.synchro.net. I'd be happy to accept/merge it into our master branch if you're happy with it.

    I never heard back, so I went ahead and committed a change base mostly on your patch set. Hopefully that works as expected for everyone.
    --
    digital man (rob)

    Synchronet "Real Fact" #57:
    Synchronet introduced Telnet, FTP, SMTP and POP3 support w/v3.00a-Win32 in 2000 Norco, CA WX: 55.9øF, 91.0% humidity, 0 mph SE wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net