Fix MRC prettyBoardName and /INFO
This commit is contained in:
parent
2b2b1ef3bc
commit
65b48a2af2
|
@ -36,6 +36,7 @@ exports.getModule = class MrcModule extends ServerModule {
|
||||||
this.log = Log.child( { server : 'MRC' } );
|
this.log = Log.child( { server : 'MRC' } );
|
||||||
|
|
||||||
const config = Config();
|
const config = Config();
|
||||||
|
this.boardName = config.general.prettyBoardName || config.general.boardName;
|
||||||
this.mrcConnectOpts = {
|
this.mrcConnectOpts = {
|
||||||
host : config.chatServers.mrc.serverHostname || 'mrc.bottomlessabyss.net',
|
host : config.chatServers.mrc.serverHostname || 'mrc.bottomlessabyss.net',
|
||||||
port : config.chatServers.mrc.serverPort || 5000,
|
port : config.chatServers.mrc.serverPort || 5000,
|
||||||
|
@ -44,11 +45,9 @@ exports.getModule = class MrcModule extends ServerModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
_connectionHandler() {
|
_connectionHandler() {
|
||||||
const config = Config();
|
|
||||||
const boardName = config.general.prettyBoardName || config.general.boardName;
|
|
||||||
const enigmaVersion = 'ENiGMA½-BBS_' + require('../../../package.json').version;
|
const enigmaVersion = 'ENiGMA½-BBS_' + require('../../../package.json').version;
|
||||||
|
|
||||||
const handshake = `${boardName}~${enigmaVersion}/${os.platform()}.${os.arch()}/${protocolVersion}`;
|
const handshake = `${this.boardName}~${enigmaVersion}/${os.platform()}.${os.arch()}/${protocolVersion}`;
|
||||||
this.log.debug({ handshake : handshake }, 'Handshaking with MRC server');
|
this.log.debug({ handshake : handshake }, 'Handshaking with MRC server');
|
||||||
|
|
||||||
this.sendRaw(handshake);
|
this.sendRaw(handshake);
|
||||||
|
@ -209,9 +208,7 @@ exports.getModule = class MrcModule extends ServerModule {
|
||||||
* Processes messages received from the central MRC server
|
* Processes messages received from the central MRC server
|
||||||
*/
|
*/
|
||||||
receiveFromMRC(message) {
|
receiveFromMRC(message) {
|
||||||
|
|
||||||
const config = Config();
|
const config = Config();
|
||||||
const siteName = slugify(config.general.boardName);
|
|
||||||
|
|
||||||
if (message.from_user == 'SERVER' && message.body == 'HELLO') {
|
if (message.from_user == 'SERVER' && message.body == 'HELLO') {
|
||||||
// reply with extra bbs info
|
// reply with extra bbs info
|
||||||
|
@ -223,7 +220,7 @@ exports.getModule = class MrcModule extends ServerModule {
|
||||||
|
|
||||||
} else if (message.from_user == 'SERVER' && message.body.toUpperCase() == 'PING') {
|
} else if (message.from_user == 'SERVER' && message.body.toUpperCase() == 'PING') {
|
||||||
// reply to heartbeat
|
// reply to heartbeat
|
||||||
this.sendToMrcServer('CLIENT', '', 'SERVER', 'ALL', '', `IMALIVE:${siteName}`);
|
this.sendToMrcServer('CLIENT', '', 'SERVER', 'ALL', '', `IMALIVE:${this.boardName}`);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// if not a heartbeat, and we have clients then we need to send something to them
|
// if not a heartbeat, and we have clients then we need to send something to them
|
||||||
|
@ -263,12 +260,10 @@ exports.getModule = class MrcModule extends ServerModule {
|
||||||
* Converts a message back into the MRC format and sends it to the central MRC server
|
* Converts a message back into the MRC format and sends it to the central MRC server
|
||||||
*/
|
*/
|
||||||
sendToMrcServer(fromUser, fromRoom, toUser, toSite, toRoom, messageBody) {
|
sendToMrcServer(fromUser, fromRoom, toUser, toSite, toRoom, messageBody) {
|
||||||
const config = Config();
|
|
||||||
const siteName = slugify(config.general.boardName);
|
|
||||||
|
|
||||||
const line = [
|
const line = [
|
||||||
fromUser,
|
fromUser,
|
||||||
siteName,
|
this.boardName,
|
||||||
sanitiseRoomName(fromRoom),
|
sanitiseRoomName(fromRoom),
|
||||||
sanitiseName(toUser || ''),
|
sanitiseName(toUser || ''),
|
||||||
sanitiseName(toSite || ''),
|
sanitiseName(toSite || ''),
|
||||||
|
@ -307,14 +302,3 @@ function sanitiseMessage(message) {
|
||||||
return message.replace(/[^\x20-\x7D]/g, '');
|
return message.replace(/[^\x20-\x7D]/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* SLugifies the BBS name for use as an MRC "site name"
|
|
||||||
*/
|
|
||||||
function slugify(text) {
|
|
||||||
return text.toString()
|
|
||||||
.replace(/\s+/g, '_') // Replace spaces with _
|
|
||||||
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
|
||||||
.replace(/\-\-+/g, '_') // Replace multiple - with single -
|
|
||||||
.replace(/^-+/, '') // Trim - from start of text
|
|
||||||
.replace(/-+$/, ''); // Trim - from end of text
|
|
||||||
}
|
|
Loading…
Reference in New Issue