summaryrefslogtreecommitdiff
path: root/commands.lua
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2023-05-03 22:57:53 -0400
committerTest_User <hax@andrewyu.org>2023-05-03 22:57:53 -0400
commite4b5445b3ca844e568a84abbf931a026a6ca6226 (patch)
tree9d9d615406c5a91036ebcd5b23bd8af30d3e8f3d /commands.lua
parentec8b1682e86535333c34966f6aafee349e609641 (diff)
downloadcoupserv-e4b5445b3ca844e568a84abbf931a026a6ca6226.tar.gz
coupserv-e4b5445b3ca844e568a84abbf931a026a6ca6226.zip
C HaxServ
Diffstat (limited to 'commands.lua')
-rw-r--r--commands.lua363
1 files changed, 0 insertions, 363 deletions
diff --git a/commands.lua b/commands.lua
deleted file mode 100644
index b758812..0000000
--- a/commands.lua
+++ /dev/null
@@ -1,363 +0,0 @@
---[[
-
-Commands 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.
-]]
-
-commands = {
- ["SANICK"] = {
- func = function(con, user, cmd, args, resp)
- if #args < 2 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
- else
- con:send("SANICK "..args[1].." :"..table.concat(args, " ", 2).."\n")
- end
- end,
- privs = {"Admin"},
- args = "<target> <new nick>",
- },
-
- ["RELOAD"] = {
- func = function(con, user, cmd, args, resp)
- 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
- con:send(":1HC000000 NOTICE "..resp.." :Successfully reloaded config.json\n")
- else
- con:send(":1HC000000 NOTICE "..resp.." :Unable to reload config.json, check /dev/stdout for details.\n")
- print("config.json")
- print(value_or_err)
- end
-
- for file, _ in pairs(config.files) do
- local success, err = pcall(dofile, path..file)
- if success then
- con:send(":1HC000000 NOTICE "..resp.." :Successfully reloaded "..file.."\n")
- else
- con:send(":1HC000000 NOTICE "..resp.." :Unable to reload "..file..", check /dev/stdout for details.\n")
- print(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
- con:send(":1HC000000 NOTICE "..resp.." :Successfully reloaded "..file.."\n")
- else
- con:send(":1HC000000 NOTICE "..resp.." :Unable to reload "..file..", check /dev/stdout for details.\n")
- print(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
- con:send(":1HC000000 NOTICE "..resp.." :Successfully reloaded config.json\n")
- else
- con:send(":1HC000000 NOTICE "..resp.." :Unable to reload config.json, check /dev/stdout for details.\n")
- print("CoupServConfig.json")
- print(value_or_err)
- end
- else
- con:send(":1HC000000 NOTICE "..resp.." :Invalid section.\n")
- end
- end
- end,
- privs = {"Admin"},
- args = "[<section>]",
- },
-
- ["RECONNECT"] = {
- func = function(con, user, cmd, args, resp)
- return true
- end,
- privs = {"Admin"},
- },
-
- [":"] = {
- func = function(con, user, cmd, args, resp)
- con:send(table.concat(args, " ").."\n")
- end,
- privs = {"Admin"},
- args = "<raw IRC message>",
- },
-
- ["HELP"] = {
- func = function(con, user, cmd, args, resp)
- for command, tbl in pairs(commands) do
- if has_permission(userlist[user], tbl.privs) then
- if tbl.args then
- con:send(":1HC000000 NOTICE "..resp.." :"..command.." "..tbl.args.."\n")
- else
- con:send(":1HC000000 NOTICE "..resp.." :"..command.."\n")
- end
- end
- end
- end,
- },
-
- ["SHUTDOWN"] = {
- func = function(con, user, cmd, args, resp)
- local crash_me = nil
- crash_me()
- end,
- privs = {"Owner"},
- },
-
- ["SPAM"] = {
- func = function(con, user, cmd, args, resp)
- if #args < 3 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
- elseif tonumber(args[2]) == nil then
- con:send(":1HC000000 NOTICE "..resp.." :"..args[2]..": Not a valid positive integer.\n")
- elseif tonumber(args[2]) < 1 then
- con:send(":1HC000000 NOTICE "..resp.." :"..args[2]..": Not a valid positive integer.\n")
- elseif tonumber(args[2]) > 65535 then
- con:send(":1HC000000 NOTICE "..resp.." :"..args[2]..": Too large of a number, max is 65535.\n")
- else
- local msg = ":1HC000000 PRIVMSG "..args[1].." :"..table.concat(args, " ", 3).."\n"
- for i=1, tonumber(args[2]), 1 do
- con:send(msg)
- end
- end
- end,
- privs = {"Admin"},
- args = "<target> <count> <message>",
- },
-
- ["OP"] = {
- func = function(con, user, cmd, args, resp)
- if resp:sub(1, 1) ~= "#" then
- con:send(":1HC000000 NOTICE "..resp.." :This command must be executed within a channel.\n")
- return
- end
-
- if #args == 0 then
- con:send(":1HC000000 MODE "..resp.." +o "..user.."\n")
- else
- con:send(":1HC000000 MODE "..resp.." +o "..args[1].."\n")
- end
- end,
- privs = {"Admin"},
- args = "[<target>]",
- },
-
- ["GETUID"] = {
- func = function(con, user, cmd, args, resp)
- if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :"..user.."\n")
- else
- local nick = table.concat(args, " ")
- for uid, tbl in pairs(userlist) do
- if tbl.nick == nick then
- con:send(":1HC000000 NOTICE "..resp.." :"..uid.."\n")
- return
- end
- end
- con:send(":1HC000000 NOTICE "..resp.." :Nick not found.\n")
- end
- end,
- args = "[<nick>]",
- },
-
- ["PRINT"] = {
- func = function(con, user, cmd, args, resp)
- if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
- else
- local list
- if args[1] == "userlist" then
- list = userlist
- elseif args[1] == "chanlist" then
- list = chanlist
- elseif args[1] == "servlist" then
- list = servlist
- else
- con:send(":1HC000000 NOTICE "..resp.." :Unknown list.\n")
- return
- end
-
- for k, v in pairs(list) do
- local msg = {}
- for key, val in pairs(v) do
- table.insert(msg, "["..(type(key) == "string" and ("%q"):format(key) or tostring(key)).."] = "..(type(val) == "string" and ("%q"):format(val) or tostring(val)))
- end
- print("["..(type(k) == "string" and ("%q"):format(k) or tostring(k)).."] = {"..table.concat(msg, ", ").."}")
- end
- end
- end,
- privs = {"Admin"},
- args = "<list>",
- },
-
- ["GETUSERINFO"] = {
- func = function(con, user, cmd, args, resp)
- if #args == 0 then
- args[1] = source
- end
-
- if userlist[args[1]] then
- local msg = {}
- for key, val in pairs(userlist[args[1]]) do
- table.insert(msg, "["..(type(key) == "string" and ("%q"):format(key) or tostring(key)).."] = "..(type(val) == "string" and ("%q"):format(val) or tostring(val)))
- end
- con:send(":1HC000000 PRIVMSG "..resp.." :{"..table.concat(msg, ", ").."}\n")
- else
- con:send(":1HC000000 PRIVMSG "..resp.." :Nonexistent UID\n")
- end
- end,
- privs = {"Admin"},
- args = "[<UID>]",
- },
-
- ["GETNICK"] = {
- func = function(con, user, cmd, args, resp)
- if userlist[args[1]] then
- con:send(":1HC000000 NOTICE "..resp.." :"..userlist[args[1]].nick.."\n")
- else
- con:send(":1HC000000 NOTICE "..resp.." :Nonexistent UID\n")
- end
- end,
- args = "[<UID>]",
- },
-
- ["JUPE"] = {
- func = function(con, user, cmd, args, resp)
- if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
- else
- for id, tbl in pairs(servlist) do
- if tbl.address == args[1] then
- con:send("RSQUIT "..args[1].." :"..table.concat(args, " ", 2).."\n")
- con:send(":1HC SERVER "..args[1].." * 0 "..id.." :Juped.\n")
- return
- end
- end
- con:send(":1HC000000 NOTICE "..resp.." :Server not found.\n")
- end
- end,
- privs = {"Admin"},
- args = "<server>",
- },
-
- ["ALLOW"] = {
- func = function(con, user, cmd, args, resp)
- if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
- else
- for id, tbl in pairs(userlist) do
- if tbl.nick == args[1] then
- userlist[id].opertype = "Admin"
- con:send(":1HC000000 NOTICE "..resp.." :"..args[1].." is now considered an oper.\n")
- return
- end
- end
- con:send(":1HC000000 NOTICE "..resp.." :Nick not found.\n")
- end
- end,
- privs = {"Admin"},
- args = "<user>",
- },
-
- ["DENY"] = {
- func = function(con, user, cmd, args, resp)
- if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
- 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")
- con:send(":1HC000000 NOTICE "..resp.." :"..args[1].." is no longer an oper.\n")
- return
- end
- end
- con:send(":1HC000000 NOTICE "..resp.." :Nick not found.\n")
- end
- end,
- privs = {"Admin"},
- args = "<user>",
- },
-
- ["SH"] = {
- func = function(con, user, cmd, args, resp)
- local command = table.concat(args, " ")
- if bash_command ~= nil and command == bash_command then
- local fd = io.popen(command)
- local message = fd:read("*a")
- for line in message:gmatch("[^\n]*") do
- if line == "" then
- con:send(":1HC000000 PRIVMSG "..resp.." : \n")
- else
- con:send(":1HC000000 PRIVMSG "..resp.." :"..line:gsub("\t", (" "):rep(8)).."\n")
- end
- end
- fd:close()
- bash_command = nil
- else
- if user:sub(1, 1) == "1" and resp:sub(1, 1) == "#" then
- con:send(":1HC000000 KICK "..resp.." "..user.." :Thought they could execute arbitrary code on hax's computer.)\n")
- else
- con:send(":1HC000000 KILL "..user.." :Killed (Thought they could execute arbitrary code on hax's computer.)\n")
- end
- end
- end,
- args = "<command>",
- },
-
- ["SUS"] = {
- func = function(con, user, cmd, args, resp)
- local lines = {
- ":1HC000000 PRIVMSG "..resp.." :Andrew is very sus.\n",
- ":1HC000000 PRIVMSG "..resp.." :I was the impostor, but you only know because I killed you.\n",
- ":1HC000000 PRIVMSG "..resp.." :\x1b(0\n",
- ":1HC000000 KILL "..user.." :Ejected (1 Impostor remains)\n",
- ":1HC000000 KILL "..user.." :Ejected, and the crewmates have won.\n",
- }
- con:send(lines[math.random(#lines)])
- end,
- },
-
- ["CR"] = {
- func = function(con, user, cmd, args, resp)
- local lines = {
- ":1HC000000 PRIVMSG "..resp.." :You are now a cruxian toxicpod, kill the sharded crewmates.\n",
- ":1HC000000 PRIVMSG "..resp.." :You are now a cruxian omura, kill the sharded crewmates.\n",
- ":1HC000000 PRIVMSG "..resp.." :You are now a cruxian oct, but you ran out of reactors.\n",
- ":1HC000000 KILL "..user.." :Eliminated (You became a cruxian eclipse, but were drawn to my bait reactor)\n",
- ":1HC000000 PRIVMSG "..resp.." :You attempted to change into a cruxian navanax, but were caught in the act.\n",
- }
- con:send(lines[math.random(#lines)])
- end,
- },
-}