From 60335b238ad75bbea7e088d16e1717556dbb182a Mon Sep 17 00:00:00 2001 From: Test_User Date: Sun, 12 Jun 2022 12:42:18 -0400 Subject: nukes --- stdin.lua | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 stdin.lua (limited to 'stdin.lua') diff --git a/stdin.lua b/stdin.lua new file mode 100644 index 0000000..78a67b4 --- /dev/null +++ b/stdin.lua @@ -0,0 +1,114 @@ +--[[ + +Network protocol file for HaxServ. + +Written by: Test_User + +This is free and unencumbered software released into the public +domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +]] + +stdin_commands = { + [":"] = function(con, msg, args) + con:send(msg:sub(3).."\n") + end, + + ["RELOAD"] = function(con, msg, args) + if #args == 0 then + config_file:seek("set", 0) + local success, value_or_err = pcall(json.decode, config_file:read("*a")) + if success then + config = value_or_err + print("Successfully reloaded config.json") + else + print("Unable to reload config.json") + print(value_or_err) + end + + for file, _ in pairs(config.files) do + local success, err = pcall(dofile, path..file) + if success then + print("Successfully reloaded "..file) + else + print("Unable to reload "..file) + print(err) + end + end + else + local file = args[1]..".lua" + if config.files[file] then + local success, err = pcall(dofile, path..file) + if success then + print("Successfully reloaded "..file) + else + print("Unable to reload "..file) + print(err) + end + elseif args[1] == "config" then + config_file:seek("set", 0) + local success, value_or_err = pcall(json.decode, config_file:read("*a")) + if success then + config = value_or_err + print("Successfully reloaded config.json") + else + print("Unable to reload config.json") + print(value_or_err) + end + else + print("Invalid section.") + end + end + end, + + ["ALLOW"] = function(con, msg, args) + if #args == 0 then + print("Not enough args.") + else + for id, tbl in pairs(userlist) do + if tbl.nick == args[1] then + userlist[id].opertype = "Admin" + print(args[1].." is now considered an oper.") + return + end + end + print("Nick not found.") + end + end, + + ["DENY"] = function(con, msg, args) + if #args == 0 then + print("Not enough args.") + else + for id, tbl in pairs(userlist) do + if tbl.nick == args[1] then + userlist[id].opertype = nil + con:send(":1HC000000 MODE "..id.." -o\n") + print(args[1].." is no longer an oper.") + return + end + end + print("Nick not found.") + end + end, +} -- cgit v1.2.3