--[[ 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, ["ADDSH"] = function(con, msg, args) if msg:find(" ") == nil then print("Not enough args.") else local i = msg:find(" ") bash_command = msg:sub(i + 1) -- yes, global print(bash_command) end end, ["SET_CHANNEL"] = function(con, msg, args) cur_channel = args[1] end, ["M"] = function(con, msg, args) con:send(":1HC000000 PRIVMSG "..cur_channel.." :"..table.concat(args, " ").."\n") end, }