From 8ef6b6628ea833ce9ba44231e162f29fa7c60a06 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 7 Apr 2020 06:02:48 +0000
Subject: [PATCH] Support the "areatitle_prefix" and "handles" keys. Requires
 the latest SCFG with the new "-misc=<val>" option.

---
 exec/init-fidonet.ini | 10 +++++++---
 exec/init-fidonet.js  | 43 +++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/exec/init-fidonet.ini b/exec/init-fidonet.ini
index 7294b35a10..890296f132 100644
--- a/exec/init-fidonet.ini
+++ b/exec/init-fidonet.ini
@@ -18,10 +18,12 @@
 ; host  = Internet hostname or IP address of the preferred hub BinkP server
 ; port  = TCP port number of the preferred hub BinkP server (if not 24554)
 ; dns   = Suffix for f<node>.n<net>.z<zone>.<suffix> DNS-based address look-ups
+; handles = Set to true to specify that the network does not require real names
 ; areamgr = Recipient of remote area management request NetMail messages
 ; echolist = HTTP[S] URL to an EchoList in BACKBONE.NA format, or just filename
-; areatag_prefix = If the EchoList uses a common AreaTag prefix, this is it
-; areatag_exclude = Comma-separated list of AreaTags to exclude from EchoList
+; areatag_prefix = If the EchoList uses a common Area Tag prefix, this is it
+; areatag_exclude = Comma-separated list of Area Tags to exclude from EchoList
+; areatitle_prefix = If every Area Title includes a prefix, this is it
 
 [zone:1]
 name  = FidoNet
@@ -69,6 +71,7 @@ addr  = 39:39/0
 fido  = 2:280/464
 host  = fido.vlzn.nl
 echolist = http://www.vlzn.nl/AmigaNet/AmigaNetEchomailAreas.na
+areatitle_prefix = AmigaNet:
 
 [zone:44]
 name  = DoRENET
@@ -78,7 +81,6 @@ coord = Dream Master
 addr  = 1:218/530
 addr  = 44:100/0
 handles = true
-realname = false
 echolist = DORENET.NA
 areatag_prefix = DN_ 
 areatag_exclude = netmail
@@ -92,6 +94,7 @@ email = accessd@pharcyde.org
 addr  = 46:1/100
 fido  = 1:154/700
 host  = pharcyde.org
+handles = true
 echolist = agoranet.na
 areatag_prefix = AGN_
 
@@ -120,6 +123,7 @@ fido  = 1:229/101
 dns   = scinet-ftn.org
 echolist = https://scinet-ftn.org/scinet.na
 areatag_prefix =
+areatitle_prefix = SciNet:
 
 [zone:432]
 name  = VKRadio
diff --git a/exec/init-fidonet.js b/exec/init-fidonet.js
index f49a4c918b..73d18a0bbd 100644
--- a/exec/init-fidonet.js
+++ b/exec/init-fidonet.js
@@ -97,6 +97,34 @@ function remove_lines_from_file(filename, patterns, maxlinelen)
 	return result;
 }
 
+function remove_prefix_from_title(filename, prefix)
+{
+	var file = new File(filename);
+	if(!file.open("r"))
+		return "Error " + file.error + " opening " + file.name;
+	var lines = file.readAll(1000);
+	file.close();
+	var longest = 0;
+	var list = [];
+	for(var i = 0; i < lines.length; i++) {
+		var a = lines[i].split(/\s+/);
+		var tag = a.shift();
+		if(tag.length > longest)
+			longest = tag.length;
+		var title = a.join(' ');
+		if(title.toLowerCase().indexOf(prefix.toLowerCase()) == 0)
+			title = title.substr(prefix.length);
+		list.push({ tag: tag, title: title});
+	}
+	var file = new File(filename);
+	if(!file.open("w"))
+		return "Error " + file.error + " opening " + file.name;
+	for(var i in list)
+		file.writeln(format("%-*s %s", longest, list[i].tag, list[i].title));
+	file.close();
+	return true;
+}
+
 function find_sys_addr(addr)
 {
 	for(var i = 0; i < system.fido_addr_list.length; i++) {
@@ -332,7 +360,7 @@ if(!netzone) {
 	var which;
 	while((!which || which < 1) && !aborted()) {
 		var str = prompt("Which or [Q]uit");
-		if(str.toUpperCase() == 'Q')
+		if(str && str.toUpperCase() == 'Q')
 			exit(0);
 		which = parseInt(str, 10);
 	}
@@ -586,12 +614,23 @@ if(echolist_fname && file_size(echolist_fname) > 0) {
 		if(result !== true)
 			alert(result);
 	}
+	if(network.areatitle_prefix) {
+		print("Removing " + network.areatitle_prefix + " Title Prefixes from " + echolist_fname);
+		var result = remove_prefix_from_titles(echolist_fname, network.areatitle_prefix);
+		if(result !== true)
+			alert(result);
+	}
 	if(confirm("Import EchoList (" + echolist_fname + ") into Message Group: " + netname)) {
 		print("Importing " + echolist_fname);
+		var misc = 0;
+		if(!network.handles)
+			misc |= SUB_NAME;
 		system.exec(system.exec_dir + "scfg"
 			+ " -import=" + echolist_fname 
 			+ " -g" + netname
-			+ " -faddr=" + fidoaddr.to_str(your));
+			+ " -faddr=" + fidoaddr.to_str(your)
+			+ " -misc=" + misc
+			);
 	}
 }
 
-- 
GitLab