channel_join(client_map[args[1]], args[2], true)
end
-if not spamlevel then
- spamlevel = 0
-end
-function setspamlevel(newlevel)
- spamlevel = newlevel
- hook_add("sendtochannel", "supernets_filter", spamlevel >= 10 and function(hook, cl1, cl2, chan, txt)
- if cl1.umode & 2 ~= 0 then -- UMODE_OPER
- return 0
- end
- if not chan.v[cl1.key] and not chan.o[cl1.key] and
- (txt:find("irc.supernets.org", 1, true) or txt:find("IRC.SUPERNETS.ORG", 1, true)) then
- return -1
- end
- end)
- hook_add("sendtoclient", "no_unsolicited_pm", spamlevel >= 20 and function(hook, cl1, cl2, chan, txt)
- if cl1.umode & 2 ~= 0 then -- UMODE_OPER
- return 0
- end
- if cl1.umode & 8 ~= 0 then -- UMODE_REGISTERED
- return 0
- end
- -- allow is cl1 has perms in any of the channels cl2 is in
- for k, v in pairs(cl2.channels) do
- if v.v[cl1.key] or v.o[cl1.key] then
- return 0
- end
- end
- return -1
- end)
- hook_add("sendtochannel", "globally_moderated", spamlevel >= 30 and function(hook, cl1, cl2, chan, txt)
- if cl1.umode & 2 ~= 0 then -- UMODE_OPER
- return 0
- end
- if cl1.umode & 8 ~= 0 then -- UMODE_REGISTERED
- return 0
- end
- if not chan.v[cl1.key] and not chan.o[cl1.key] then
- return 1
- end
- end)
-end
-setspamlevel(spamlevel)
-
-function commands.spam(client, source, command, args)
- if args.n == 0 then
- client_notice(client, "current spam protection level: "..tostring(spamlevel))
- else
- setspamlevel(tonumber(args[1]))
- client_notice(client, "new spam protection level: "..tostring(spamlevel))
- end
-end
-
dofile "lua/irccloud.lua"
dofile "lua/ctcp.lua"
+dofile "lua/spam.lua"
--- /dev/null
+-- spam filtering
+if not spamlevel then
+ spamlevel = 0
+end
+function setspamlevel(newlevel)
+ spamlevel = newlevel
+ hook_add("sendtochannel", "supernets_filter", spamlevel >= 10 and function(hook, cl1, cl2, chan, txt)
+ if cl1.umode & 2 ~= 0 then -- UMODE_OPER
+ return 0
+ end
+ if not chan.v[cl1.key] and not chan.o[cl1.key] and
+ (txt:find("irc.supernets.org", 1, true) or txt:find("IRC.SUPERNETS.ORG", 1, true)) then
+ return -1
+ end
+ end)
+ hook_add("sendtoclient", "no_unsolicited_pm", spamlevel >= 20 and function(hook, cl1, cl2, chan, txt)
+ if cl1.umode & 2 ~= 0 then -- UMODE_OPER
+ return 0
+ end
+ if cl1.umode & 8 ~= 0 then -- UMODE_REGISTERED
+ return 0
+ end
+ -- allow is cl1 has perms in any of the channels cl2 is in
+ for k, v in pairs(cl2.channels) do
+ if v.v[cl1.key] or v.o[cl1.key] then
+ return 0
+ end
+ end
+ return -1
+ end)
+ hook_add("sendtochannel", "globally_moderated", spamlevel >= 30 and function(hook, cl1, cl2, chan, txt)
+ if cl1.umode & 2 ~= 0 then -- UMODE_OPER
+ return 0
+ end
+ if cl1.umode & 8 ~= 0 then -- UMODE_REGISTERED
+ return 0
+ end
+ if not chan.v[cl1.key] and not chan.o[cl1.key] then
+ return 1
+ end
+ end)
+end
+setspamlevel(spamlevel)
+
+function commands.spam(client, source, command, args)
+ if args.n == 0 then
+ client_notice(client, "current spam protection level: "..tostring(spamlevel))
+ else
+ setspamlevel(tonumber(args[1]))
+ client_notice(client, "new spam protection level: "..tostring(spamlevel))
+ end
+end