diff --git a/art/general/erc.ans b/art/general/erc.ans deleted file mode 100644 index d2f336d2..00000000 Binary files a/art/general/erc.ans and /dev/null differ diff --git a/config/menu.hjson b/config/menu.hjson index 0a57414c..1ee13d07 100644 --- a/config/menu.hjson +++ b/config/menu.hjson @@ -1019,10 +1019,6 @@ value: { command: "R" } action: @menu:mainMenuRumorz } - { - value: { command: "CHAT"} - action: @menu:ercClient - } { value: { command: "BBS"} action: @menu:bbsList @@ -1473,58 +1469,6 @@ } } - ercClient: { - art: erc - module: erc_client - config: { - host: localhost - port: 5001 - bbsTag: CHANGEME - } - - form: { - 0: { - mci: { - MT1: { - width: 79 - height: 21 - mode: preview - autoScroll: true - } - ET3: { - autoScale: false - width: 77 - argName: inputArea - focus: true - submit: true - } - } - - submit: { - *: [ - { - value: { inputArea: null } - action: @method:inputAreaSubmit - } - ] - } - actionKeys: [ - { - keys: [ "tab" ] - } - { - keys: [ "up arrow" ] - action: @method:scrollDown - } - { - keys: [ "down arrow" ] - action: @method:scrollUp - } - ] - } - } - } - bbsList: { desc: Viewing BBS List module: bbs_list diff --git a/core/erc_client.js b/core/erc_client.js deleted file mode 100644 index 018c9372..00000000 --- a/core/erc_client.js +++ /dev/null @@ -1,179 +0,0 @@ -/* jslint node: true */ -'use strict'; - -const MenuModule = require('./menu_module.js').MenuModule; -const stringFormat = require('./string_format.js'); - -// deps -const async = require('async'); -const _ = require('lodash'); -const net = require('net'); - -/* - Expected configuration block example: - - config: { - host: 192.168.1.171 - port: 5001 - bbsTag: SOME_TAG - } - -*/ - -exports.getModule = ErcClientModule; - -exports.moduleInfo = { - name : 'ENiGMA Relay Chat Client', - desc : 'Chat with other ENiGMA BBSes', - author : 'Andrew Pamment', -}; - -var MciViewIds = { - ChatDisplay : 1, - InputArea : 3, -}; - -// :TODO: needs converted to ES6 MenuModule subclass -function ErcClientModule(options) { - MenuModule.prototype.ctorShim.call(this, options); - - const self = this; - this.config = options.menuConfig.config; - - this.chatEntryFormat = this.config.chatEntryFormat || '[{bbsTag}] {userName}: {message}'; - this.systemEntryFormat = this.config.systemEntryFormat || '[*SYSTEM*] {message}'; - - this.finishedLoading = function() { - async.waterfall( - [ - function validateConfig(callback) { - if(_.isString(self.config.host) && - _.isNumber(self.config.port) && - _.isString(self.config.bbsTag)) - { - return callback(null); - } else { - return callback(new Error('Configuration is missing required option(s)')); - } - }, - function connectToServer(callback) { - const connectOpts = { - port : self.config.port, - host : self.config.host, - }; - - const chatMessageView = self.viewControllers.menu.getView(MciViewIds.ChatDisplay); - - chatMessageView.setText('Connecting to server...'); - chatMessageView.redraw(); - - self.viewControllers.menu.switchFocus(MciViewIds.InputArea); - - // :TODO: Track actual client->enig connection for optional prevMenu @ final CB - self.chatConnection = net.createConnection(connectOpts.port, connectOpts.host); - - self.chatConnection.on('data', data => { - data = data.toString(); - - if(data.startsWith('ERCHANDSHAKE')) { - self.chatConnection.write(`ERCMAGIC|${self.config.bbsTag}|${self.client.user.username}\r\n`); - } else if(data.startsWith('{')) { - try { - data = JSON.parse(data); - } catch(e) { - return self.client.log.warn( { error : e.message }, 'ERC: Error parsing ERC data from server'); - } - - let text; - try { - if(data.userName) { - // user message - text = stringFormat(self.chatEntryFormat, data); - } else { - // system message - text = stringFormat(self.systemEntryFormat, data); - } - } catch(e) { - return self.client.log.warn( { error : e.message }, 'ERC: chatEntryFormat error'); - } - - chatMessageView.addText(text); - - if(chatMessageView.getLineCount() > 30) { // :TODO: should probably be ChatDisplay.height? - chatMessageView.deleteLine(0); - chatMessageView.scrollDown(); - } - - chatMessageView.redraw(); - self.viewControllers.menu.switchFocus(MciViewIds.InputArea); - } - }); - - self.chatConnection.once('end', () => { - return callback(null); - }); - - self.chatConnection.once('error', err => { - self.client.log.info(`ERC connection error: ${err.message}`); - return callback(new Error('Failed connecting to ERC server!')); - }); - } - ], - err => { - if(err) { - self.client.log.warn( { error : err.message }, 'ERC error'); - } - - self.prevMenu(); - } - ); - }; - - this.scrollHandler = function(keyName) { - const inputAreaView = self.viewControllers.menu.getView(MciViewIds.InputArea); - const chatDisplayView = self.viewControllers.menu.getView(MciViewIds.ChatDisplay); - - if('up arrow' === keyName) { - chatDisplayView.scrollUp(); - } else { - chatDisplayView.scrollDown(); - } - - chatDisplayView.redraw(); - inputAreaView.setFocus(true); - }; - - - this.menuMethods = { - inputAreaSubmit : function(formData, extraArgs, cb) { - const inputAreaView = self.viewControllers.menu.getView(MciViewIds.InputArea); - const inputData = inputAreaView.getData(); - - if('/quit' === inputData.toLowerCase()) { - self.chatConnection.end(); - } else { - try { - self.chatConnection.write(`${inputData}\r\n`); - } catch(e) { - self.client.log.warn( { error : e.message }, 'ERC error'); - } - inputAreaView.clearText(); - } - return cb(null); - }, - scrollUp : function(formData, extraArgs, cb) { - self.scrollHandler(formData.key.name); - return cb(null); - }, - scrollDown : function(formData, extraArgs, cb) { - self.scrollHandler(formData.key.name); - return cb(null); - } - }; -} - -require('util').inherits(ErcClientModule, MenuModule); - -ErcClientModule.prototype.mciReady = function(mciData, cb) { - this.standardMCIReadyHandler(mciData, cb); -};