Skip to content

Commit

Permalink
Revert "adding some alerts and notifier optimizations and customizati…
Browse files Browse the repository at this point in the history
…ons"

This reverts commit 8c8edde.
  • Loading branch information
TobiTenno committed Jan 15, 2018
1 parent e1f3155 commit 688c386
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 39 deletions.
23 changes: 3 additions & 20 deletions src/commands/Worldstate/Alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,16 @@ class Alerts extends Command {
*/
constructor(bot) {
super(bot, 'warframe.worldstate.alerts', 'alert', 'Display the currently active alerts');
this.regex = new RegExp(`^${this.call}s?\\s?(?:(compact))?(?:on\\s+([pcsxb14]{2,3}))?`, 'i');
this.regex = new RegExp(`^${this.call}s?(?:\\s+on\\s+([pcsxb14]{2,3}))?`, 'i');
}

async run(message) {
const matches = message.strippedContent.match(this.regex);
const param1 = (matches[1] || '').toLowerCase();
const param2 = (matches[2] || '').toLowerCase();
const compact = /compact/ig.test(param1) || /compact/ig.test(param2);
let platformParam;
if (this.platforms.indexOf(param2) > -1) {
platformParam = param2;
} else if (this.platforms.indexOf(param1) > -1) {
platformParam = param1;
}

const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const alerts = ws.alerts.filter(a => !a.expired);

if (compact) {
await this.messageManager
await this.messageManager
.embed(message, new AlertEmbed(this.bot, alerts, platform), true, false);
} else {
await Promise.all(alerts.map(alert => this.messageManager
.embed(message, new AlertEmbed(this.bot, [alert], platform), true, false)));
}

return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
24 changes: 9 additions & 15 deletions src/embeds/AlertEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,33 @@ class AlertEmbed extends BaseEmbed {
url: 'http://i.imgur.com/KQ7f9l7.png',
};
this.color = 0xF1C40F;
// compact
if (alerts.length > 1) {
this.fields = alerts.map(a => ({
name: `${a.mission.reward.asString} | ${a.eta} left`,
name: `${a.mission.reward.asString} - ${a.eta} left`,
value: `${a.mission.faction} ${a.mission.type} on ${a.mission.node}\n` +
`level ${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}\n\u200B`,
`level ${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}`,
}));
this.title = `[${platform.toUpperCase()}] Worldstate - Alerts`;
} else { // divided
} else {
const a = alerts[0];
this.title = `[${platform.toUpperCase()}] ${a.mission.reward.itemString || `${a.mission.reward.credits} Credits`}`;
this.title = `[${platform.toUpperCase()}] ${a.mission.reward.itemString}`;
this.color = a.mission.reward.color;
this.thumbnail.url = a.mission.reward.thumbnail;
const summary = `${a.mission.faction} ${a.mission.type} on ${a.mission.node}`;
this.description = a.description;

this.description = a.description || summary;
this.fields = [];
if (this.description !== summary) {
this.fields.push({ name: 'Mission', value: `${a.mission.faction} ${a.mission.type}`, inline: true });
this.fields.push({ name: 'Location', value: a.mission.node, inline: true });
this.fields.push({ name: '_ _', value: `${a.mission.faction} ${a.mission.type} on ${a.mission.node}` });
}
this.fields.push({ name: 'Levels:', value: `${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}`, inline: true });

this.fields.push({ name: 'Archwing Required', value: a.mission.archwingRequired ? 'Yes' : 'No', inline: true });

if (this.title.indexOf('Cr') === -1) {
this.fields.push({ name: '_ _', value: `**Credits:** ${a.mission.reward.credits}`, inline: true });
if (this.title.indexOf('cr') === -1) {
this.fields.push({ name: '_ _', value: `**Credits:** ${a.mission.reward.credits}cr`, inline: true });
}
this.footer.text = `${a.eta} remaining | Expires `;
this.timestamp = a.expiry;
this.footer.text = `${a.eta} remaining`;
}
}
}

module.exports = AlertEmbed;

4 changes: 2 additions & 2 deletions src/notifications/Notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Notifier {
const acolytesToNotify = newData.persistentEnemies
.filter(e => !ids.includes(e.pid) && e.isDiscovered);
const alertsToNotify = newData.alerts
.filter(a => !ids.includes(a.id) && !a.expired);
.filter(a => !ids.includes(a.id) && a.rewardTypes.length && !a.expired);
const baroToNotify = newData.voidTrader && !ids.includes(newData.voidTrader.psId) ?
newData.voidTrader : undefined;
const conclaveToNotify = newData.conclaveChallenges.filter(cc =>
Expand Down Expand Up @@ -245,7 +245,7 @@ class Notifier {
} catch (e) {
this.logger.error(e);
} finally {
await this.broadcast(embed, platform, 'alerts', a.rewardTypes || ['a.credits'], fromNow(a.expiry));
await this.broadcast(embed, platform, 'alerts', a.rewardTypes, fromNow(a.expiry));
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/resources/trackables.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"kavatGene",
"kubrowEgg",
"traces",
"other",
"credits"
"other"
],
"eventTypes": [
"alerts",
Expand Down

0 comments on commit 688c386

Please sign in to comment.