2015-08-12 23:26:05 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
const messageArea = require('../core/message_area.js');
|
2016-08-04 01:48:45 +00:00
|
|
|
|
2015-08-12 23:26:05 +00:00
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
exports.MessageAreaConfTempSwitcher = Sup => class extends Sup {
|
2018-01-15 19:22:11 +00:00
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
tempMessageConfAndAreaSwitch(messageAreaTag) {
|
2016-08-04 01:48:45 +00:00
|
|
|
messageAreaTag = messageAreaTag || this.messageAreaTag;
|
|
|
|
if(!messageAreaTag) {
|
|
|
|
return; // nothing to do!
|
|
|
|
}
|
2017-01-26 05:18:05 +00:00
|
|
|
|
2016-08-04 01:48:45 +00:00
|
|
|
this.prevMessageConfAndArea = {
|
|
|
|
confTag : this.client.user.properties.message_conf_tag,
|
2018-01-15 19:22:11 +00:00
|
|
|
areaTag : this.client.user.properties.message_area_tag,
|
2016-08-04 01:48:45 +00:00
|
|
|
};
|
2017-01-26 05:18:05 +00:00
|
|
|
|
2016-08-04 01:48:45 +00:00
|
|
|
if(!messageArea.tempChangeMessageConfAndArea(this.client, this.messageAreaTag)) {
|
|
|
|
this.client.log.warn( { messageAreaTag : messageArea }, 'Failed to perform temporary message area/conf switch');
|
|
|
|
}
|
2017-01-26 05:18:05 +00:00
|
|
|
}
|
2016-08-04 01:48:45 +00:00
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
tempMessageConfAndAreaRestore() {
|
2016-08-04 01:48:45 +00:00
|
|
|
if(this.prevMessageConfAndArea) {
|
|
|
|
this.client.user.properties.message_conf_tag = this.prevMessageConfAndArea.confTag;
|
2018-01-15 19:22:11 +00:00
|
|
|
this.client.user.properties.message_area_tag = this.prevMessageConfAndArea.areaTag;
|
2016-08-04 01:48:45 +00:00
|
|
|
}
|
2017-01-26 05:18:05 +00:00
|
|
|
}
|
2016-08-04 01:48:45 +00:00
|
|
|
};
|