PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: blackwings on 28 February, 2005, 04:12:51

Title: Advertise Crusher 1.0 (LUA 5)
Post by: blackwings on 28 February, 2005, 04:12:51
Converted my anti-advertise bot to LUA 5. Enjoy this until the elite programmers comes with their scripts :)
Please report any bugs that you may find :)
--Advertise Crusher by blackwings
--v1.0 LUA 5
--functions:
-- anti-advertise - detect and tempban
-- safe advertise - so you can type the hubs own adress
-- Counter       - aka adverKill, in default it bans after 3 tempbans
-- Many Signs     - can detect advertisment that use different signs then "."
--      Tempban left   - how many tempbans a user has before permban
-----------
--changed: Converted the script to LUA 5.
-----------
------------------------------------------------------------------------
--++++++++++++++++++++++ START OF CONFIGURATION ++++++++++++++++++++++--
------------------------------------------------------------------------
Bot = "#anti-advetise"

-- How many times a user gets tempbanned before getting a permban
adverKill = 3
-- If the "kill" messages should be shown to everyone in main chat
ShowAllinMain = 1

--Put the first part of you safe advertise adress here
nosafeAdver={
"safe1","safe2","safe3","safe4",
}

DNS01={
"no-ip","mine","sytes","dynip","dyndns","gotdns","kicks-ass","d2g","serveftp",
"servehttp","servehalflife","servequake","servecounterstrike","xs4all","myftp",
"servebeer","zapto","tropico","lysekil","udgnet","dnsalias","dynalias","ath","homeip",
"servemp3","hopto","servegame","staticip","orgdns","myftpsite","ipactive","idlegames",
"homeunix","homelinux","flamenap","dns2go","clanpimp","bounceme","ip","uni","is-a-geek","isa-geek"
}

MSigns={".","_","-","+","?","&","*","=","!","#","|","?","?","?","?","@","$","%","^"}
DNS02={"com","net","org","nu","se","cx","us","it","co.uk","info","biz","cc","de","tv","nl"}
------------------------------------------------------------------------
--+++++++++++++++++++++++ END OF CONFIGURATION +++++++++++++++++++++++--
------------------------------------------------------------------------

adverCounter = 0

function adverSmashing(user)
if not user.bOperator then
adverCounter = adverCounter + 1
tmpBanLeft = adverKill - adverCounter
if adverCounter < adverKill then
user:SendData(Bot, "You are tempbanned because of advertiseing.")
user:SendData(Bot, "Number of tempban before permban = "..tmpBanLeft)
user:TempBan()
SendPmToOps(Bot, "User <"..user.sName.."> was tempbanned for advertising, wrote = "..advDetect)
if ShowAllinMain == 1 then
SendToAll(Bot, "User <"..user.sName.."> was tempbanned for advertising")
end
elseif adverCounter == adverKill then
user:SendData(Bot, "You are PERMBANNED because of advertiseing")
user:Ban()
SendPmToOps(Bot, "User <"..user.sName.."> was PERMBANNED for advertising, wrote = "..advDetect)
if ShowAllinMain == 1 then
SendToAll(Bot, "User <"..user.sName.."> was PERMBANNED for advertising")
end
adverCounter = 0
end
end
end


function ChatArrival(user,data)
for d=1,table.getn(MSigns) do
tSigns = (string.lower(MSigns[d]))
for e=1,table.getn(DNS01) do
tPart01 = (string.lower(DNS01[e]))
for f=1,table.getn(DNS02) do
tPart02 = (string.lower(DNS02[f]))
for g=1,table.getn(nosafeAdver) do
safe01 = (string.lower(nosafeAdver[g]))
--
advDetect = tSigns..tPart01..tSigns..tPart02
safeAdv = safe01..advDetect
--
if(string.find(data, advDetect,1,1))  then
if(string.find(data, safeAdv,1,1))  then
return nil
end
return adverSmashing(user)
end
if(string.sub(data, 1, 4) == "$To:") then
if(string.find(data, advDetect,1,1) ) then
if(string.find(data, safeAdv,1,1))  then
return nil
end
return adverSmashing(user)
end
end
end
end
end
end
end
Title:
Post by: ??????Hawk?????? on 28 February, 2005, 04:53:47
hi m8  


$To:   Has its own arrival    ;)
Title:
Post by: blackwings on 28 February, 2005, 05:00:30
EDIT: Updated the script above with Opti's suggestion
Title:
Post by: Optimus on 28 February, 2005, 12:20:32
ToArrival = ChatArrival maybe that works also. less code
Title:
Post by: bastya_elvtars on 28 February, 2005, 12:27:23
I still don't get why ther are loops inside loops. Gonna look.
Title:
Post by: plop on 28 February, 2005, 17:24:45
complex story comming up.
move all code from chat/to arrivals 2 a standalone function.
when it finds something bad you should return 1.
by sending data 2 this function and checking for the return 1 you can minimize chat/to arrival 2 the bare minimum.
also don't forget 2 strip the data on to arrival a bit so it matches chat arrival.
for more hints, check my/bast's wordreplacer.

plop
Title:
Post by: bastya_elvtars on 28 February, 2005, 17:28:37
have I coded a wordreplacer? you keep surprising me! :D
Title:
Post by: blackwings on 01 March, 2005, 18:06:30
QuoteOriginally posted by plop
complex story comming up.
move all code from chat/to arrivals 2 a standalone function.
when it finds something bad you should return 1.
by sending data 2 this function and checking for the return 1 you can minimize chat/to arrival 2 the bare minimum.
also don't forget 2 strip the data on to arrival a bit so it matches chat arrival.
for more hints, check my/bast's wordreplacer.

plop
ok, I will try, not sure if I will succed :P

(edited the script in my first post with opti's suggestion)