-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (58 loc) · 1.99 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const { Notification } = require('electron');
const versionChecker = require('sw-exporter-plugin-version-checker');
module.exports = {
defaultConfig: {
enabled: true,
cairos: true,
scenario: true,
raid: true,
rift: true,
toa: true,
dimension: true,
},
defaultConfigDetails: {
cairos: { label: 'Cairos Dungeon' },
scenario: { label: 'Scenario' },
raid: { label: 'Rift of World' },
rift: { label: 'Elemental Beasts' },
toa: { label: 'Trial of Ascension' },
dimension: { label: 'Dimension Hole' },
},
pluginName: 'RunNotifier',
pluginDescription: 'Receive a notification when a run has finished.',
init (proxy, config) {
const pluginConfig = config.Config.Plugins[this.pluginName];
if (pluginConfig.enabled) {
versionChecker.proceed({
name: this.pluginName,
config: require('./package.json'),
proxy: proxy
});
}
Object.entries(this.events())
.forEach(([mode, event]) => {
proxy.on(event, (request, response) => {
if (! pluginConfig.enabled || ! pluginConfig[mode]) {
return;
}
const notification = new Notification({
title: 'Summoners War',
body: response.win_lose == 1
? 'The run has finished.'
: 'The run has failed.',
});
notification.show();
});
});
},
events () {
return {
'cairos': 'BattleDungeonResult',
'scenario': 'BattleScenarioResult',
'raid': 'BattleRiftOfWorldsRaidResult',
'rift': 'BattleRiftDungeonResult',
'toa': 'BattleTrialTowerResult_v2',
'dimension': 'BattleDimensionHoleDungeonResult',
};
},
};