summaryrefslogtreecommitdiff
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
parentec8b1682e86535333c34966f6aafee349e609641 (diff)
downloadlua_coupserv-41dc6bfab38cabc2e2aa6ec5c78f878fafa0d108.tar.gz
lua_coupserv-41dc6bfab38cabc2e2aa6ec5c78f878fafa0d108.zip
Lua CoupServ improvements
-rwxr-xr-xCoupServ.lua18
-rw-r--r--commands.lua108
-rw-r--r--network.lua14
-rw-r--r--stdin.lua4
4 files changed, 76 insertions, 68 deletions
diff --git a/CoupServ.lua b/CoupServ.lua
index 20ee42e..71b3408 100755
--- a/CoupServ.lua
+++ b/CoupServ.lua
@@ -48,7 +48,7 @@ function has_permission(user, privs)
privs = privs or {}
for _, v in pairs(privs) do
if v == "Admin" then
- if user.opertype ~= "Admin" then
+ if user.opertype ~= config.opertypes.admin then
return false
end
elseif v == "Owner" then -- not dealing with this yet, so just always return false for now
@@ -79,7 +79,7 @@ while true do
::continue::
local s = socket.tcp4()
- s:connect("irc.andrewyu.org", 7005)
+ s:connect(config.address, config.port)
local con = ssl.wrap(s, {mode = "client", protocol = "tlsv1_3"})
if not con:dohandshake() then
@@ -90,13 +90,13 @@ while true do
local time = tostring(os.time())
- con:send("SERVER hax.irc.andrewyu.org "..config.send_password.." 0 1HC :HaxServ\n")
+ con:send("SERVER lua.hax.irc.andrewyu.org "..config.send_password.." 0 "..config.sid.." :HaxServ\n")
con:send("BURST "..time.."\n")
- con:send("UID 1HC000000 "..time.." "..config.nick.." "..config.hostmask.." "..config.hostmask.." HaxServ 192.168.1.1 "..time.." +k :HaxServ\n")
- con:send(":1HC000000 OPERTYPE Admin\n")
+ con:send("UID "..config.sid.."000000 "..time.." "..config.nick.." "..config.hostmask.." "..config.hostmask.." HaxServ 192.168.1.1 "..time.." +k :HaxServ\n")
+ con:send(":"..config.sid.."000000 OPERTYPE NetAdmin\n")
- userlist["1HC000000"] = {
- server = "1HC",
+ userlist[config.sid.."000000"] = {
+ server = config.sid,
nick_ts = time,
nick = config.nick,
hostname = config.hostmask,
@@ -113,8 +113,8 @@ while true do
}
for channel, _ in pairs(config.channels) do
- con:send("FJOIN "..channel.." "..time.." + :,1HC000000\n")
- con:send("MODE "..channel.." +o 1HC000000\n")
+ con:send("FJOIN "..channel.." "..time.." + :,"..config.sid.."000000\n")
+ con:send("MODE "..channel.." +o "..config.sid.."000000\n")
end
con:send("ENDBURST\n")
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,
diff --git a/network.lua b/network.lua
index 84cb712..bd988eb 100644
--- a/network.lua
+++ b/network.lua
@@ -157,6 +157,12 @@ message_handler = {
end
end,
+ ["SQUIT"] = function(con, sourge, args, original)
+ if juped_list and juped_list[args[1]] then
+ con:send(":"..config.sid.." SERVER "..servlist[args[1]].address.." * 0 "..args[1].." :Juped.\n")
+ end
+ end,
+
["METADATA"] = function(con, source, args, original)
if args[1] == "*" then
if servlist[source] then
@@ -239,10 +245,10 @@ message_handler = {
print(("%q"):format(userlist[source].nick.." executed command: "..cmd))
return commands[cmd].func(con, source, cmd, cmd_args, resp)
else
- con:send(":1HC000000 NOTICE "..resp.." :You are not authorized to execute that command.\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :You are not authorized to execute that command.\n")
end
else
- con:send(":1HC000000 NOTICE "..resp.." :Unknown command: "..cmd.."\n")
+ con:send(":"..config.sid.."000000 NOTICE "..resp.." :Unknown command: "..cmd.."\n")
end
end,
@@ -271,7 +277,7 @@ message_handler = {
end,
["KILL"] = function(con, source, args, original)
- if args[1]:sub(1,3) ~= "1HC" then
+ if args[1]:sub(1,3) ~= config.sid then
print("Kill remote", original)
userlist[source] = nil
for name, chan in pairs(chanlist) do
@@ -296,7 +302,7 @@ message_handler = {
end,
["KICK"] = function(con, soure, args, original)
- if args[2]:sub(1,3) == "1HC" then
+ if args[2]:sub(1,3) == config.sid then
con:send(":"..args[2].." JOIN "..args[1].."\n")
con:send("MODE "..args[1].." +o "..args[2].."\n")
else
diff --git a/stdin.lua b/stdin.lua
index 4b69590..d7f159f 100644
--- a/stdin.lua
+++ b/stdin.lua
@@ -103,7 +103,7 @@ stdin_commands = {
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(":"..config.sid.."000000 MODE "..id.." -o\n")
print(args[1].." is no longer an oper.")
return
end
@@ -127,6 +127,6 @@ stdin_commands = {
end,
["M"] = function(con, msg, args)
- con:send(":1HC000000 PRIVMSG "..cur_channel.." :"..table.concat(args, " ").."\n")
+ con:send(":"..config.sid.."000000 PRIVMSG "..cur_channel.." :"..table.concat(args, " ").."\n")
end,
}