diff --git a/art/themes/luciano_blocktronics/autosig.ans b/art/themes/luciano_blocktronics/autosig.ans new file mode 100644 index 00000000..1af14a63 Binary files /dev/null and b/art/themes/luciano_blocktronics/autosig.ans differ diff --git a/art/themes/luciano_blocktronics/theme.hjson b/art/themes/luciano_blocktronics/theme.hjson index 86f1ed3b..6d8490dc 100644 --- a/art/themes/luciano_blocktronics/theme.hjson +++ b/art/themes/luciano_blocktronics/theme.hjson @@ -447,6 +447,20 @@ } } + editAutoSignature: { + 0: { + mci: { + MT1: { + height: 8 + width: 73 + } + BT2: { + focusTextStyle: upper + } + } + } + } + messageSearch: { 0: { mci: { diff --git a/core/autosig_edit.js b/core/autosig_edit.js new file mode 100644 index 00000000..c9995280 --- /dev/null +++ b/core/autosig_edit.js @@ -0,0 +1,76 @@ +/* jslint node: true */ +'use strict'; + +// ENiGMA½ +const { MenuModule } = require('./menu_module.js'); +const UserProps = require('./user_property.js'); + +// deps +const async = require('async'); +const _ = require('lodash'); + +exports.moduleInfo = { + name : 'User Auto-Sig Editor', + desc : 'Module for editing auto-sigs', + author : 'NuSkooler', +}; + +const FormIds = { + edit : 0, +}; + +const MciViewIds = { + editor : 1, + save : 2, +}; + +exports.getModule = class UserAutoSigEditorModule extends MenuModule { + constructor(options) { + super(options); + this.config = Object.assign({}, _.get(options, 'menuConfig.config'), { extraArgs : options.extraArgs }); + + this.menuMethods = { + saveChanges : (formData, extraArgs, cb) => { + return this.saveChanges(cb); + } + }; + } + + mciReady(mciData, cb) { + super.mciReady(mciData, err => { + if(err) { + return cb(err); + } + + async.series( + [ + (callback) => { + return this.prepViewController('edit', FormIds.edit, mciData.menu, callback); + }, + (callback) => { + const requiredCodes = [ MciViewIds.editor, MciViewIds.save ]; + return this.validateMCIByViewIds('edit', requiredCodes, callback); + }, + (callback) => { + const sig = this.client.user.getProperty(UserProps.AutoSignature) || ''; + this.setViewText('edit', MciViewIds.editor, sig); + return callback(null); + } + ], + err => { + return cb(err); + } + ); + }); + } + + saveChanges(cb) { + const sig = this.getView('edit', MciViewIds.editor).getData().trim(); + this.client.user.persistProperty(UserProps.AutoSignature, sig, err => { + if(err) { + this.client.log.error( { error : err.message }, 'Could not save auto-sig'); + } + return this.prevMenu(cb); + }); + } +}; diff --git a/core/fse.js b/core/fse.js index d77fbfed..8b2214d8 100644 --- a/core/fse.js +++ b/core/fse.js @@ -325,20 +325,21 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul buildMessage(cb) { const headerValues = this.viewControllers.header.getFormData().value; + const area = getMessageAreaByTag(this.messageAreaTag); const getFromUserName = () => { - const area = getMessageAreaByTag(this.messageAreaTag); return (area && area.realNames) ? this.client.user.getProperty(UserProps.RealName) || this.client.user.username : this.client.user.username; }; + let messageBody = this.viewControllers.body.getView(MciViewIds.body.message).getData( { forceLineTerms : this.replyIsAnsi } ); + const msgOpts = { areaTag : this.messageAreaTag, toUserName : headerValues.to, fromUserName : getFromUserName(), subject : headerValues.subject, - message : this.viewControllers.body.getView(MciViewIds.body.message).getData( { forceLineTerms : this.replyIsAnsi } ), }; if(this.isReply()) { @@ -351,11 +352,20 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul // to packetAnsiMsgEncoding (generally cp437) as various boards // really don't like ANSI messages in UTF-8 encoding (they should!) // - msgOpts.meta = { System : { 'explicit_encoding' : _.get(Config(), 'scannerTossers.ftn_bso.packetAnsiMsgEncoding', 'cp437') } }; - msgOpts.message = `${ansi.reset()}${ansi.eraseData(2)}${ansi.goto(1,1)}\r\n${ansi.up()}${msgOpts.message}`; + msgOpts.meta = { System : { 'explicit_encoding' : _.get(Config(), 'scannerTossers.ftn_bso.packetAnsiMsgEncoding', 'cp437') } }; + messageBody = `${ansi.reset()}${ansi.eraseData(2)}${ansi.goto(1,1)}\r\n${ansi.up()}${messageBody}`; } } + if(false != area.autoSignatures) { + const sig = this.client.user.getProperty(UserProps.AutoSignature); + if(sig) { + messageBody += `\r\n-- \r\n${sig}`; + } + } + + msgOpts.message = messageBody; + this.message = new Message(msgOpts); return cb(null); diff --git a/core/user_property.js b/core/user_property.js index 88ac11b1..cc68ef09 100644 --- a/core/user_property.js +++ b/core/user_property.js @@ -27,6 +27,7 @@ module.exports = { LastLoginTs : 'last_login_timestamp', LoginCount : 'login_count', UserComment : 'user_comment', // NYI + AutoSignature : 'auto_signature', DownloadQueue : 'dl_queue', // download_queue.js