]> PatchyGit - patchyircd.git/commitdiff
spam.lua: block yet another network
authorEgor <egor@patchysicp.xyz>
Sat, 17 Aug 2024 21:03:13 +0000 (00:03 +0300)
committerEgor <egor@patchysicp.xyz>
Sat, 17 Aug 2024 21:03:13 +0000 (00:03 +0300)
lua/spam.lua

index 1f6a606..5947cca 100644 (file)
@@ -2,17 +2,32 @@
 if not spamlevel then
        spamlevel = 0
 end
+local function ascii(txt)
+       txt = txt:gsub("[^ -~]", "")
+       return txt
+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
+               txt = ascii(txt)
                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("sendtochannel", "hardchats_filter", spamlevel >= 10 and function(hook, cl1, cl2, chan, txt)
+               if cl1.umode & 2 ~= 0 then -- UMODE_OPER
+                       return 0
+               end
+               txt = ascii(txt)
+               if not chan.v[cl1.key] and not chan.o[cl1.key] and
+                       (txt:find("hardchats.com", 1, true) or txt:find("HARDCHATS", 1, true)) then
+                       return -1
+               end
+       end)
        hook_add("sendtochannel", "l0de_radio_hour_filter", spamlevel >= 10 and function(hook, cl1, cl2, chan, txt)
                if cl1.umode & 2 ~= 0 then -- UMODE_OPER
                        return 0
@@ -20,6 +35,7 @@ function setspamlevel(newlevel)
                if cl1.umode & 8 ~= 0 then -- UMODE_REGISTERED
                        return 0
                end
+               txt = ascii(txt)
                if not chan.v[cl1.key] and not chan.o[cl1.key] and
                        (txt:find("1-877-293-1933", 1, true)) then
                        return -1
@@ -32,6 +48,7 @@ function setspamlevel(newlevel)
                if cl1.umode & 8 ~= 0 then -- UMODE_REGISTERED
                        return 0
                end
+               txt = ascii(txt)
                if txt:find("1-877-293-1933", 1, true) then
                        return -1
                end