summaryrefslogtreecommitdiff
path: root/commands.lua
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2024-06-17 18:40:14 -0400
committerTest_User <hax@andrewyu.org>2024-06-17 18:40:14 -0400
commit41dc6bfab38cabc2e2aa6ec5c78f878fafa0d108 (patch)
treec8d9533f1e5ddd0f8976924f64fa227cfc19b739 /commands.lua
parentec8b1682e86535333c34966f6aafee349e609641 (diff)
downloadlua_coupserv-41dc6bfab38cabc2e2aa6ec5c78f878fafa0d108.tar.gz
lua_coupserv-41dc6bfab38cabc2e2aa6ec5c78f878fafa0d108.zip
Lua CoupServ improvements
Diffstat (limited to 'commands.lua')
-rw-r--r--commands.lua108
1 files changed, 55 insertions, 53 deletions
diff --git a/commands.lua b/commands.lua
index b758812..133a509 100644
--- a/commands.lua
+++ b/commands.lua
@@ -29,11 +29,13 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
]]
+juped_list = juped_list or {}
+
commands = {
["SANICK"] = {
func = function(con, user, cmd, args, resp)
if #args < 2 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Not enough args.\n")
else
con:send("SANICK "..args[1].." :"..table.concat(args, " ", 2).."\n")
end
@@ -49,9 +51,9 @@ commands = {
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")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Successfully reloaded config.json\n")
else
- con:send(":1HC000000 NOTICE "..resp.." :Unable to reload config.json, check /dev/stdout for details.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Unable to reload config.json, check /dev/stdout for details.\n")
print("config.json")
print(value_or_err)
end
@@ -59,9 +61,9 @@ commands = {
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")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Successfully reloaded "..file.."\n")
else
- con:send(":1HC000000 NOTICE "..resp.." :Unable to reload "..file..", check /dev/stdout for details.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Unable to reload "..file..", check /dev/stdout for details.\n")
print(file)
print(err)
end
@@ -71,9 +73,9 @@ commands = {
if config.files[file] then
local success, err = pcall(dofile, path..file)
if success then
- con:send(":1HC000000 NOTICE "..resp.." :Successfully reloaded "..file.."\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Successfully reloaded "..file.."\n")
else
- con:send(":1HC000000 NOTICE "..resp.." :Unable to reload "..file..", check /dev/stdout for details.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Unable to reload "..file..", check /dev/stdout for details.\n")
print(file)
print(err)
end
@@ -82,14 +84,14 @@ commands = {
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")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Successfully reloaded config.json\n")
else
- con:send(":1HC000000 NOTICE "..resp.." :Unable to reload config.json, check /dev/stdout for details.\n")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Invalid section.\n")
end
end
end,
@@ -117,9 +119,9 @@ commands = {
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")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :"..command.." "..tbl.args.."\n")
else
- con:send(":1HC000000 NOTICE "..resp.." :"..command.."\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :"..command.."\n")
end
end
end
@@ -137,15 +139,15 @@ commands = {
["SPAM"] = {
func = function(con, user, cmd, args, resp)
if #args < 3 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 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"
+ local msg = ":"..config.sid.."000000 PRIVMSG "..args[1].." :"..table.concat(args, " ", 3).."\n"
for i=1, tonumber(args[2]), 1 do
con:send(msg)
end
@@ -158,14 +160,14 @@ commands = {
["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")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 MODE "..resp.." +o "..user.."\n")
else
- con:send(":1HC000000 MODE "..resp.." +o "..args[1].."\n")
+ con:send(":"..config.sid.."000000 MODE "..resp.." +o "..args[1].."\n")
end
end,
privs = {"Admin"},
@@ -175,16 +177,16 @@ commands = {
["GETUID"] = {
func = function(con, user, cmd, args, resp)
if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :"..user.."\n")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :"..uid.."\n")
return
end
end
- con:send(":1HC000000 NOTICE "..resp.." :Nick not found.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Nick not found.\n")
end
end,
args = "[<nick>]",
@@ -193,7 +195,7 @@ commands = {
["PRINT"] = {
func = function(con, user, cmd, args, resp)
if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Not enough args.\n")
else
local list
if args[1] == "userlist" then
@@ -203,7 +205,7 @@ commands = {
elseif args[1] == "servlist" then
list = servlist
else
- con:send(":1HC000000 NOTICE "..resp.." :Unknown list.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Unknown list.\n")
return
end
@@ -231,9 +233,9 @@ commands = {
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")
+ con:send(":"..config.sid.."000000 PRIVMSG "..resp.." :{"..table.concat(msg, ", ").."}\n")
else
- con:send(":1HC000000 PRIVMSG "..resp.." :Nonexistent UID\n")
+ con:send(":"..config.sid.."000000 PRIVMSG "..resp.." :Nonexistent UID\n")
end
end,
privs = {"Admin"},
@@ -243,9 +245,9 @@ commands = {
["GETNICK"] = {
func = function(con, user, cmd, args, resp)
if userlist[args[1]] then
- con:send(":1HC000000 NOTICE "..resp.." :"..userlist[args[1]].nick.."\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :"..userlist[args[1]].nick.."\n")
else
- con:send(":1HC000000 NOTICE "..resp.." :Nonexistent UID\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Nonexistent UID\n")
end
end,
args = "[<UID>]",
@@ -254,16 +256,16 @@ commands = {
["JUPE"] = {
func = function(con, user, cmd, args, resp)
if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
+ con:send(":"..config.sid.."000000 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")
+ juped_list[id] = true
return
end
end
- con:send(":1HC000000 NOTICE "..resp.." :Server not found.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Server not found.\n")
end
end,
privs = {"Admin"},
@@ -273,16 +275,16 @@ commands = {
["ALLOW"] = {
func = function(con, user, cmd, args, resp)
if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :"..args[1].." is now considered an oper.\n")
return
end
end
- con:send(":1HC000000 NOTICE "..resp.." :Nick not found.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Nick not found.\n")
end
end,
privs = {"Admin"},
@@ -292,17 +294,17 @@ commands = {
["DENY"] = {
func = function(con, user, cmd, args, resp)
if #args == 0 then
- con:send(":1HC000000 NOTICE "..resp.." :Not enough args.\n")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 MODE "..id.." -o\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :"..args[1].." is no longer an oper.\n")
return
end
end
- con:send(":1HC000000 NOTICE "..resp.." :Nick not found.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Nick not found.\n")
end
end,
privs = {"Admin"},
@@ -317,18 +319,18 @@ commands = {
local message = fd:read("*a")
for line in message:gmatch("[^\n]*") do
if line == "" then
- con:send(":1HC000000 PRIVMSG "..resp.." : \n")
+ con:send(":"..config.sid.."000000 PRIVMSG "..resp.." : \n")
else
- con:send(":1HC000000 PRIVMSG "..resp.." :"..line:gsub("\t", (" "):rep(8)).."\n")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 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")
+ con:send(":"..config.sid.."000000 KILL "..user.." :Killed (Thought they could execute arbitrary code on hax's computer.)\n")
end
end
end,
@@ -338,11 +340,11 @@ commands = {
["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",
+ ":"..config.sid.."000000 PRIVMSG "..resp.." :Andrew is very sus.\n",
+ ":"..config.sid.."000000 PRIVMSG "..resp.." :I was the impostor, but you only know because I killed you.\n",
+ ":"..config.sid.."000000 PRIVMSG "..resp.." :\x1b(0\n",
+ ":"..config.sid.."000000 KILL "..user.." :Ejected (1 Impostor remains)\n",
+ ":"..config.sid.."000000 KILL "..user.." :Ejected, and the crewmates have won.\n",
}
con:send(lines[math.random(#lines)])
end,
@@ -351,11 +353,11 @@ commands = {
["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",
+ ":"..config.sid.."000000 PRIVMSG "..resp.." :You are now a cruxian toxicpod, kill the sharded crewmates.\n",
+ ":"..config.sid.."000000 PRIVMSG "..resp.." :You are now a cruxian omura, kill the sharded crewmates.\n",
+ ":"..config.sid.."000000 PRIVMSG "..resp.." :You are now a cruxian oct, but you ran out of reactors.\n",
+ ":"..config.sid.."000000 KILL "..user.." :Eliminated (You became a cruxian eclipse, but were drawn to my bait reactor)\n",
+ ":"..config.sid.."000000 PRIVMSG "..resp.." :You attempted to change into a cruxian navanax, but were caught in the act.\n",
}
con:send(lines[math.random(#lines)])
end,