-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpm.raider.js
131 lines (113 loc) · 3.13 KB
/
pm.raider.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
let fs = require('fs');
const path = require('path');
const appDataPath = process.env.APPDATA;
const scriptsPath = '/Firebot/firebot-data/user-settings/scripts/';
const platysIncFolder = 'pm.includes';
exports.getScriptManifest = () => {
return {
name: "Platys Raider Script",
description: "Bounces a bar across screen",
version: "2",
author: "PlatypusMuerte",
website: "https://twitter.com/PlatypusMuerte"
};
};
function getDefaultParameters() {
return new Promise((resolve, reject) => {
resolve({
delayTime: {
type: "number",
description: "Seconds before clearing effect",
default: 20
},
message: {
type: "string",
description: "The raid message. Use token {raider} for the name.",
default: "IT'S A {raider} RAID ! ! !"
}
});
});
}
exports.getDefaultParameters = getDefaultParameters;
function getHead() {
let jsContent;
let file = path.join(appDataPath,scriptsPath + "/" + platysIncFolder + "/jqueryui/jquery-ui.min.js");
return new Promise((resolve, reject) => {
fs.readFile(file,(err,data) => {
if(err) {
jsContent = err;
} else {
jsContent = data;
}
resolve(`<script>` + jsContent + `</script>`);
});
});
}
function getCSS() {
let fileContent;
let file = path.join(appDataPath,scriptsPath + "/" + platysIncFolder + "/raider/raider.css");
return new Promise((resolve, reject) => {
fs.readFile(file,(err,data) => {
if(err) {
fileContent = err;
} else {
fileContent = data;
}
resolve(`<style>` + fileContent + `</style>`);
});
});
}
function jsEffects() {
let fileContent;
let file = path.join(appDataPath,scriptsPath + "/" + platysIncFolder + "/raider/main.js");
return new Promise((resolve, reject) => {
fs.readFile(file,(err,data) => {
if(err) {
fileContent = err;
} else {
fileContent = data;
}
resolve(`<script>` + fileContent + `</script>`);
});
});
}
function run(runRequest) {
let raider = runRequest.command.args[0].toUpperCase().replace('@','');
let delayTime = runRequest.parameters.delayTime*1;
let raidMsg = runRequest.parameters.message.replace('{raider}',`<span>`+raider+`</span>`);
return new Promise((resolve, reject) => {
getHead().then((jsHead) => {
getCSS().then((css) => {
jsEffects().then((jsEffs) => {
resolve({
success: true,
effects: [
{
type: EffectType.HTML,
enterAnimation: "none",
exitAnimation: "none",
html:`<div id="raiderWrapper" class="raiderWrapper"><div class="pmRaiderThrowAwayDiv"></div>` + jsHead + css + `
<div class="raiderBar">
<div id="raiderName" class="raiderName">${raidMsg}</div>
</div>` + jsEffs + `</div>`,
length: 5,
removal: "pmRaiderThrowAwayDiv"
},{
type: EffectType.DELAY,
delay: delayTime
},{
type: EffectType.HTML,
enterAnimation: "none",
exitAnimation: "none",
html: `<div class="pmRaiderThrowAwayDiv"><script>$(".raiderWrapper,.ui-effects-placeholder").remove();</script></div>`,
length: 5,
removal: "pmRaiderThrowAwayDiv"
}
]
});
});
});
});
});
}
exports.run = run;