summaryrefslogtreecommitdiff
path: root/network.lua
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2022-08-05 00:03:52 -0400
committerTest_User <hax@andrewyu.org>2022-08-05 00:03:52 -0400
commitc3c84a3c6aa633d0833f74d6ce1c99397a7fa8e2 (patch)
tree5ef911b7e034c5b5b9aa22b105bad5900ff4742a /network.lua
parente3d61f12fe302e7e72d97d8c718c6a372b334ff6 (diff)
downloadcoupserv-c3c84a3c6aa633d0833f74d6ce1c99397a7fa8e2.tar.gz
coupserv-c3c84a3c6aa633d0833f74d6ce1c99397a7fa8e2.zip
fix missing license to old CoupServ.py
Diffstat (limited to 'network.lua')
-rw-r--r--network.lua64
1 files changed, 62 insertions, 2 deletions
diff --git a/network.lua b/network.lua
index c581759..84cb712 100644
--- a/network.lua
+++ b/network.lua
@@ -122,6 +122,28 @@ local function parse_modes(modes, args, has_args, current)
return true
end
+local function mode_to_string(modes)
+ local res = "+"
+ local args = {}
+ for mode, arg in pairs(modes) do
+ if arg == true then
+ res = res..mode
+ elseif type(arg) == "string" then
+ res = res..mode
+ table.insert(args, arg)
+ elseif type(arg) == "table" then
+ for _, a in pairs(arg) do
+ res = res..mode
+ table.insert(args, a)
+ end
+ end
+ end
+
+ res = res.." "..table.concat(args, " ")
+
+ return res
+end
+
message_handler = {
["PING"] = function(con, source, args, original)
con:send(":"..args[2].." PONG "..args[2].." "..source.."\n")
@@ -190,6 +212,10 @@ message_handler = {
end,
["PRIVMSG"] = function(con, source, args, original)
+ if args[1] == cur_channel then
+ print(("%q"):format("<"..userlist[source].nick.."> "..args[2]))
+ end
+
local cmd_args = {}
for part in args[2]:gmatch("[^ ]*") do
table.insert(cmd_args, part)
@@ -244,7 +270,41 @@ message_handler = {
end
end,
- ["FJOIN"] = function(con, source, args, original)
+ ["KILL"] = function(con, source, args, original)
+ if args[1]:sub(1,3) ~= "1HC" then
+ print("Kill remote", original)
+ userlist[source] = nil
+ for name, chan in pairs(chanlist) do
+ chan["users"][source] = nil
+ if next(chan["users"]) == nil and not chan["modes"]["P"] then
+ chanlist[name] = nil
+ end
+ end
+ else
+ print("Kill local", original)
+ local user = userlist[args[1]]
+ if type(user) == "table" then
+ con:send("UID "..args[1].." "..user.nick_ts.." "..user.nick.." "..user.hostname.." "..user.vhost.." "..user.ident.." "..user.ip.." "..user.user_ts.." "..mode_to_string(user.modes).." :"..user.realname.."\n")
+
+ -- temporary before I handle channels
+ for channel, _ in pairs(config.channels) do
+ con:send(":"..args[1].." JOIN "..channel.."\n")
+ con:send("MODE "..channel.." +o "..args[1].."\n")
+ end
+ end
+ end
+ end,
+
+ ["KICK"] = function(con, soure, args, original)
+ if args[2]:sub(1,3) == "1HC" then
+ con:send(":"..args[2].." JOIN "..args[1].."\n")
+ con:send("MODE "..args[1].." +o "..args[2].."\n")
+ else
+ print("Channels not yet handled: "..("%q"):format(original))
+ end
+ end,
+
+--[[ ["FJOIN"] = function(con, source, args, original)
- end
+ end]]
}