From ed2444f539111617bbd545199f163a7c2424cc7a Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Tue, 15 Mar 2022 18:21:23 -0700
Subject: [PATCH] Optional channel list per server configured in modopts.ini

So you have multiple IRC servers configured in modopts.ini and
you want different channel list per server? Just add more
keys to the modopts.ini [chat_sec] section of the form:
<server>=<channel_list>

Where <server> is the IRC server's host name (e.g. irc.synchro.net)
and <channel_list> is a comma-separated list of channels to override
the default list of channels (set with the "irc_channel" key).

For DesotoFireflite (VALHALLA)
---
 exec/chat_sec.js | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/exec/chat_sec.js b/exec/chat_sec.js
index e560a02c1a..d12a828e9d 100644
--- a/exec/chat_sec.js
+++ b/exec/chat_sec.js
@@ -109,19 +109,26 @@ while(bbs.online && !console.aborted) {
 				if(console.aborted || server.length < 4)
 					break;
 			}
-			if(server.indexOf(' ') < 0)
-				server += " 6667";
-			if(irc_channels.length > 1) {
-				for(var i = 0; i < irc_channels.length; i++)
-					console.uselect(i, "IRC Channel", irc_channels[i]);
+			// Optional list of channels per server (e.g. irc.synchro.net = #synchronet, #bbs)
+			var channel_list = irc_channels;
+			if(options[server] !== undefined)
+				channel_list = options[server].split(',');
+			var channel;
+			if(channel_list.length > 1) {
+				for(var i = 0; i < channel_list.length; i++) {
+					channel_list[i] = channel_list[i].trim();
+					console.uselect(i, "IRC Channel", channel_list[i]);
+				}
 				var i = console.uselect();
 				if(i < 0)
 					break;
-				channel = irc_channels[i];
+				channel = channel_list[i];
 			} else {
 				write("\r\n\x01n\x01y\x01hIRC Channel: ");
-				var channel = console.getstr(options.irc_channel, 40, K_EDIT|K_LINE|K_AUTODEL);
+				channel = console.getstr(channel_list[0], 40, K_EDIT|K_LINE|K_AUTODEL);
 			}
+			if(server.indexOf(' ') < 0)
+				server += " 6667";
 			if(!console.aborted && channel.length) {
 				log("IRC to " + server + " " + channel);
 				bbs.exec("?irc -a " + server + " " + channel); // can't be load()ed because it calls exit()
-- 
GitLab