summaryrefslogtreecommitdiff
path: root/stdin.lua
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2022-06-12 12:42:18 -0400
committerTest_User <hax@andrewyu.org>2022-06-12 12:42:18 -0400
commit60335b238ad75bbea7e088d16e1717556dbb182a (patch)
tree83e15f1a1231d82768c5ce99d2abaebb33aa9fa2 /stdin.lua
parent1b60aa9b97c9aea9aa842da3f8dea8816721ad3d (diff)
downloadcoupserv-60335b238ad75bbea7e088d16e1717556dbb182a.tar.gz
coupserv-60335b238ad75bbea7e088d16e1717556dbb182a.zip
nukes
Diffstat (limited to 'stdin.lua')
-rw-r--r--stdin.lua114
1 files changed, 114 insertions, 0 deletions
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 <hax@andrewyu.org>
+
+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,
+}