-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.sh
More file actions
41 lines (34 loc) · 1.05 KB
/
cli.sh
File metadata and controls
41 lines (34 loc) · 1.05 KB
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
#!/usr/bin/env python
import codecs
import sys
import os
def createEvent(event_name):
event_name_capitalized = event_name.capitalize()
event_template = """const {Event} = require('./event');
const {ErrorCodeHelper, Responses} = require('../helper');
const ech = new ErrorCodeHelper();
exports.EVN = class extends Event {
/**
* @param {Game} game
*/
trigger(game) {
for (let i = 0; i !== game.players.length; i++) {
const player = game.players[i];
const websocket = player.websocket;
websocket.send(ech.sendResponse(Responses.RESPONSE_HERE, null));
}
}
};
""".replace("EVN", event_name_capitalized)
path = os.path.join(os.getcwd(), "src", "events", event_name + ".js")
print(path)
file = codecs.open(path, "w", "utf-8")
file.write(event_template)
file.close()
args = sys.argv[1::]
if str(args[0]).lower() == "createevent":
if len(args) != 2:
print("[!] Please enter a event name.")
else:
print(args[1])
createEvent(str(args[1]))