Introduced shutdown privilege.
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ var buttonsIfOffline = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
var buttonsIfOnline = `
|
var buttonsIfOnline = `
|
||||||
<button onclick="hiddenFunctionClick(this, 'action/?shutdown', 3)" class="button-osu button-osu-management button-negative" disabled>
|
<button onclick="hiddenFunctionClick(this, 'action/?shutdown', 3)" class="button-osu button-osu-management button-negative">
|
||||||
<div class="button-symbol">🔌</div>
|
<div class="button-symbol">🔌</div>
|
||||||
<div class="button-label">Shut down</div>
|
<div class="button-label">Shut down</div>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
+12
-4
@@ -85,6 +85,8 @@ local_secret = "unset"
|
|||||||
|
|
||||||
current_shutdown_timer = 0
|
current_shutdown_timer = 0
|
||||||
|
|
||||||
|
global_session_admin = ""
|
||||||
|
|
||||||
# folder structure setup
|
# folder structure setup
|
||||||
os.makedirs(lobbies_dir, exist_ok=True)
|
os.makedirs(lobbies_dir, exist_ok=True)
|
||||||
|
|
||||||
@@ -421,6 +423,9 @@ while running:
|
|||||||
|
|
||||||
for request in request_json:
|
for request in request_json:
|
||||||
if "type" in request:
|
if "type" in request:
|
||||||
|
if global_session_admin == "" and "issuer" in request and "username" in request["issuer"]:
|
||||||
|
global_session_admin = request["issuer"]["username"]
|
||||||
|
|
||||||
if request["type"] == "invite" and "target" in request:
|
if request["type"] == "invite" and "target" in request:
|
||||||
the_filter = False
|
the_filter = False
|
||||||
if "filter" in request:
|
if "filter" in request:
|
||||||
@@ -455,9 +460,11 @@ while running:
|
|||||||
elif request["type"] == "register" and "target" in request:
|
elif request["type"] == "register" and "target" in request:
|
||||||
print("Registering lobby: " + str(request["target"]))
|
print("Registering lobby: " + str(request["target"]))
|
||||||
irc_start_managing(request["target"], join=True)
|
irc_start_managing(request["target"], join=True)
|
||||||
# elif request["type"] == "shutdown":
|
elif request["type"] == "shutdown":
|
||||||
# running = False
|
if global_session_admin != "" and "issuer" in request and "username" in request["issuer"] and global_session_admin == request["issuer"]["username"]:
|
||||||
# break
|
running = False
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.cmd in [ "001" ]:
|
if line.cmd in [ "001" ]:
|
||||||
@@ -727,7 +734,8 @@ while running:
|
|||||||
temp_output["boot"] = boot_timestamp
|
temp_output["boot"] = boot_timestamp
|
||||||
temp_output["delay"] = global_irc_send_timeout
|
temp_output["delay"] = global_irc_send_timeout
|
||||||
temp_output["maxLobbies"] = global_max_lobbies
|
temp_output["maxLobbies"] = global_max_lobbies
|
||||||
temp_output["current_mapset"] = current_mapset
|
temp_output["currentMapset"] = current_mapset
|
||||||
|
temp_output["sessionAdmin"] = global_session_admin
|
||||||
|
|
||||||
# uncomment to expose commands to the public
|
# uncomment to expose commands to the public
|
||||||
# temp_output["command_queue"] = global_irc_send_queue
|
# temp_output["command_queue"] = global_irc_send_queue
|
||||||
|
|||||||
@@ -136,6 +136,10 @@ function updateUnalikeDisplay(unalikeJson) {
|
|||||||
if (unalikeJson.shutdownTimer) {
|
if (unalikeJson.shutdownTimer) {
|
||||||
newStatus += "</p><p>If nothing happens, Unalike will shut down in " + unalikeJson.shutdownTimer + " seconds.";
|
newStatus += "</p><p>If nothing happens, Unalike will shut down in " + unalikeJson.shutdownTimer + " seconds.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (unalikeJson.sessionAdmin) {
|
||||||
|
newStatus += "</p><p>" + unalikeJson.sessionAdmin + " was the first to interact with Unalike. Only he/she can shut it down on command.";
|
||||||
|
}
|
||||||
// dynamicJsonElement = document.getElementById("dynamic-json");
|
// dynamicJsonElement = document.getElementById("dynamic-json");
|
||||||
// dynamicJsonElement.innerHTML = JSON.stringify(unalikeJson);
|
// dynamicJsonElement.innerHTML = JSON.stringify(unalikeJson);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user