I'm making my own anti advertise script just for fun.
It all work except for the thing that I want my script to detect all kinds of signs that might be used in advertise.
As you see in the code below, I have tried several things, but I can't get it to work anyway. So could anyone please help me?
--Advertise Crusher by blackwings
--v0.4
Bot = "#Anti-Advertise"
function Main()
end
antiAdver = {
{"bummer","com"},
{"super","net"},
}
tMSigns = {
{"?"},
{"?"},
{"?"},
{"?"},
{"#"},
{"!"},
{"@"},
{"$"},
{"%"},
{"^"},
{"&"},
{"*"},
{"_"},
{"-"},
{"="},
{"+"},
{"?"},
}
--tMSigns = {
-- "?","?","?","?","#","!","@","$","%","^","&","*","_","-","=","+","?"
--}
function DataArrival(user,data,sData)
for i=1,getn(antiAdver) do
-- for b=1,getn(tMSigns) do
antiAdver[i][1] = gsub(antiAdver[i][1], "<" , "")
local tPart01 = antiAdver[i][1]
local tPart02 = (%p)
-- local tPart02 = tMSigns[b][1]
local tPart03 = antiAdver[i][2]
-- local advDetect = tPart01..tPart03
-- local advDetect = tPart01..tPart02..tPart03
local advDetect = tPart01.."%S"..tPart03
local word2nd = ardkngadrngarkjgdar
if( strfind(data, advDetect,1,1)) then
-- if not user.bOperator then
SendToAll(Bot, "Dont advertise")
-- end
end
if(strsub(data, 1, 4) == "$To:") then
if( strfind(data, advDetect,1,1) ) then
-- if not user.bOperator then
SendToAll(Bot, "Dont advertise")
-- end
end
end
collectgarbage()
-- end
end
end
You are using magic chars without escape. If you use those standalone, they will act as "regular expressions." Use them with % before them. See how:
tMSigns = {
"%?","%?","%?","%?","%#","%!","%@","%$","%%","%^","%&","%*","%_","%-","%=","%+","%?"
}
OK, it's unnecessary to put it before all, but it's recommended to use an escape before any non-alphanumeric character. This is from LUA4 book:
QuoteSome characters, called magic characters, have special meanings when used
in a pattern. The magic characters are
( ) . % + - * ? [ ^ $
The character % works as an escape for those magic characters. So, %. matches
a dot, and %% matches the % itself. You can use the escape % not only for the
magic characters, but for any non alphanumeric character. When in doubt, play
safe and put an escape.
My script works now :D Now I shall just fix a safe advertise function :)
btw bastya_elvtars, % infront of a non-alphanumeric character in my script doesn't work.
--Advertise Crusher by blackwings
--v1.0
Bot = "#Anti-Advertise"
function Main()
end
-- Check the bottom of the script to find different dns that this script can detect
adverKill = 3
tMSigns = {
{"?"},
{"?"},
{"?"},
{"?"},
{"#"},
{"!"},
{"@"},
{"$"},
{"%"},
{"^"},
{"&"},
{"*"},
{"_"},
{"-"},
{"="},
{"+"},
{"."},
{"?"},
}
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()
elseif adverKill == adverKill then
user:SendData(Bot, "You are PERMBANNED because of advertiseing")
user:Ban()
adverCounter = 0
end
end
collectgarbage()
end
function DataArrival(user,data)
for i=1,getn(antiAdver) do
antiAdver[i][1] = gsub(antiAdver[i][1], "<" , "")
tPart01 = antiAdver[i][1]
tPart03 = antiAdver[i][2]
for b=1,getn(tMSigns) do
tMSigns[b][1] = gsub(tMSigns[b][1], "<" , "")
tPart02 = tMSigns[b][1]
local advDetect = tPart01..tPart02..tPart03
if( strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") then
if( strfind(data, advDetect,1,1) ) then
return adverSmashing(user)
end
end
end
end
collectgarbage()
end
antiAdver = {
{"no-ip","com"},
{"no-ip","org"},
{"no-ip","info"},
{"no-ip","biz"},
{"no-ip","co.uk"},
{"mine","nu"},
{"sytes","net"},
{"dynip","com"}, -- not sure if it should be .com or .org etc
{"dyndns","org"},
{"dyndns","info"},
{"dyndns","biz"},
{"gotdns","com"},
{"gotdns","org"},
{"kicks-ass","net"},
{"kicks-ass","org"},
{"d2g","org"}, -- not sure if it should be .com or .org etc
{"serveftp","com"},
{"serveftp","org"},
{"serveftp","net"},
{"servehttp","com"},
{"servehalflife","com"},
{"servequake","com"},
{"servecounterstrike","com"},
{"xs4all","com"}, -- not sure if it should be .com or .org etc
{"myftp","biz"},
{"myftp","org"},
{"servebeer","com"},
{"zapto","org"},
{"tropico","com"}, -- not sure if it should be .com or .org etc
{"lysekil","net"}, -- not sure if it should be .com or .org etc
{"udgnet","com"}, -- not sure if it should be .com or .org etc
{"dnsalias","net"},
{"dnsalias","com"},
{"dnsalias","org"},
{"dynalias","net"},
{"dynalias","com"},
{"dynalias","org"},
{"ath","cx"},
{"homeip","net"},
{"servemp3","com"},
{"hopto","org"},
{"servegame","org"},
{"staticip","com"}, -- not sure if it should be .com or .org etc
{"orgdns","com"}, -- not sure if it should be .com or .org etc
{"myftpsite","com"}, -- not sure if it should be .com or .org etc
{"ipactive","com"}, -- not sure if it should be .com or .org etc
{"idlegames","com"}, -- not sure if it should be .com or .org etc
{"homeunix","com"},
{"homeunix","net"},
{"homeunix","org"},
{"homelinux","com"},
{"homelinux","net"},
{"homelinux","org"},
{"flamenap","com"}, -- not sure if it should be .com or .org etc
{"dns2go","org"}, -- not sure if it should be .com or .org etc
{"clanpimp","com"}, -- not sure if it should be .com or .org etc
{"bounceme","net"},
{"ip","biz"},
{"uni","cc"},
{"is-a-geek","com"},
{"is-a-geek","org"},
{"is-a-geek","net"},
{"isa-geek","com"},
{"isa-geek","org"},
{"isa-geek","net"},
}
Added a safe advertisment function.
I will be happy to get any comments on how to make it better :)
EDIT: lol, I tested to advertise in my testhub with both my script and RoboCop 0.9g, my script was faster on detecting and take action.
--Advertise Crusher by blackwings
--v1.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
-----------
--added: safe advertisment
-----------
Bot = "#Anti-Advertise"
function Main()
end
-- Check the bottom of the script to see what it can detect
-- Do also check the bottom of the script for the safe advertising settings
adverKill = 3
tMSigns = {
{"?"},
{"?"},
{"?"},
{"?"},
{"#"},
{"!"},
{"@"},
{"$"},
{"%"},
{"^"},
{"&"},
{"*"},
{"_"},
{"-"},
{"="},
{"+"},
{"."},
{"?"},
}
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()
elseif adverKill == adverKill then
user:SendData(Bot, "You are PERMBANNED because of advertiseing")
user:Ban()
adverCounter = 0
end
end
collectgarbage()
end
function DataArrival(user,data)
for i=1,getn(antiAdver) do
antiAdver[i][1] = gsub(antiAdver[i][1], "<" , "")
tPart01 = antiAdver[i][2]
tPart03 = antiAdver[i][3]
safeAdv = antiAdver[i][1]
for b=1,getn(tMSigns) do
tMSigns[b][1] = gsub(tMSigns[b][1], "<" , "")
tPart02 = tMSigns[b][1]
local advDetect = tPart01..tPart02..tPart03
if( strfind(data, advDetect,1,1)) then
if( strfind(data, safeAdv,1,1)) then
return nil
end
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") then
if( strfind(data, advDetect,1,1) ) then
if( strfind(data, safeAdv,1,1)) then
return nil
end
return adverSmashing(user)
end
end
end
end
collectgarbage()
end
-- To add a safe advertise adress, add the first part of your adress
-- to the first field infront of the correct DNS.
-- Example: your adress is test.no-ip.org, then replace "xxxxxxx" with "test"
-- in {"xxxxxxx","no-ip","org"},
antiAdver = {
{"test","no-ip","com"},
{"xxxxxxx","no-ip","org"},
{"xxxxxxx","no-ip","info"},
{"xxxxxxx","no-ip","biz"},
{"xxxxxxx","no-ip","co.uk"},
{"xxxxxxx","mine","nu"},
{"xxxxxxx","sytes","net"},
{"xxxxxxx","dynip","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","dyndns","org"},
{"xxxxxxx","dyndns","info"},
{"xxxxxxx","dyndns","biz"},
{"xxxxxxx","gotdns","com"},
{"xxxxxxx","gotdns","org"},
{"xxxxxxx","kicks-ass","net"},
{"xxxxxxx","kicks-ass","org"},
{"xxxxxxx","d2g","org"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","serveftp","com"},
{"xxxxxxx","serveftp","org"},
{"xxxxxxx","serveftp","net"},
{"xxxxxxx","servehttp","com"},
{"xxxxxxx","servehalflife","com"},
{"xxxxxxx","servequake","com"},
{"xxxxxxx","servecounterstrike","com"},
{"xxxxxxx","xs4all","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","myftp","biz"},
{"xxxxxxx","myftp","org"},
{"xxxxxxx","servebeer","com"},
{"xxxxxxx","zapto","org"},
{"xxxxxxx","tropico","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","lysekil","net"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","udgnet","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","dnsalias","net"},
{"xxxxxxx","dnsalias","com"},
{"xxxxxxx","dnsalias","org"},
{"xxxxxxx","dynalias","net"},
{"xxxxxxx","dynalias","com"},
{"xxxxxxx","dynalias","org"},
{"xxxxxxx","ath","cx"},
{"xxxxxxx","homeip","net"},
{"xxxxxxx","servemp3","com"},
{"xxxxxxx","hopto","org"},
{"xxxxxxx","servegame","org"},
{"xxxxxxx","staticip","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","orgdns","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","myftpsite","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","ipactive","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","idlegames","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","homeunix","com"},
{"xxxxxxx","homeunix","net"},
{"xxxxxxx","homeunix","org"},
{"xxxxxxx","homelinux","com"},
{"xxxxxxx","homelinux","net"},
{"xxxxxxx","homelinux","org"},
{"xxxxxxx","flamenap","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","dns2go","org"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","clanpimp","com"}, -- not sure if it should be .com or .org etc
{"xxxxxxx","bounceme","net"},
{"xxxxxxx","ip","biz"},
{"xxxxxxx","uni","cc"},
{"xxxxxxx","is-a-geek","com"},
{"xxxxxxx","is-a-geek","org"},
{"xxxxxxx","is-a-geek","net"},
{"xxxxxxx","isa-geek","com"},
{"xxxxxxx","isa-geek","org"},
{"xxxxxxx","isa-geek","net"},
}
QuoteI will be happy to get any comments on how to make it better :)
EDIT: lol, I tested to advertise in my testhub with both my script and RoboCop 0.9g, my script was faster on detecting and take action.
There we go again, i though we had this conversation allready with a other script of you lol
Do you really think things are that easy hehe
It has nothing todo with speed (check other thread about allowed clients script you made), and second mine is faster cause yours uses loops and mine is hashed. (without loops)
Your way to fast making your conclusiens
LOOOLlllllll :D
QuoteOriginally posted by Optimus
QuoteI will be happy to get any comments on how to make it better :)
EDIT: lol, I tested to advertise in my testhub with both my script and RoboCop 0.9g, my script was faster on detecting and take action.
There we go again, i though we had this conversation allready with a other script of you lol
Do you really think things are that easy hehe
It has nothing todo with speed (check other thread about allowed clients script you made), and second mine is faster cause yours uses loops and mine is hashed. (without loops)
Your way to fast making your conclusiens
LOOOLlllllll :D
ok, sorry for makeing such comment :P
Why is hashed better then loop, if loop works faster??
Just curious, because you said that your faster even if my detects och take action faster.
And if you have time, could you show a code example on the difference between loop and hash?
I'm always intresting to learn, even if I'm not so often program in lua :)
well m8 i have tested your script and i have found the reason why yours seems tobe faster.
Call your script z.lua and yours will take action
Call your script 1.lua and mine will take action
So simple is it.
- Optimus
QuoteOriginally posted by blackwings
btw bastya_elvtars, % infront of a non-alphanumeric character in my script doesn't work.
OK, i see. I thought you are using strfind or something like it. Nice work btw, just 1 question: why do you use the
tMSigns = {
{"?"},
{"?"},
{"?"},
{"?"},
{"#"},
{"!"},
{"@"},
{"$"},
{"%"},
{"^"},
{"&"},
{"*"},
{"_"},
{"-"},
{"="},
{"+"},
{"."},
{"?"},
}
such a way, when
tMSigns = {"a","b","c", --etc.
}
would be enough?
BTW i really like the solution you made for it. Keep up the good work!
-- // edit
btw opti is right: hashing is faster and less resource consumant, your script is only faster because it processes the data before RoboCop, this has nothing to do with speed, this depends on the order of the scripts.
QuoteOriginally posted by bastya_elvtars
OK, i see. I thought you are using strfind or something like it. Nice work btw, just 1 question: why do you use the tMSigns = {
{"?"},
{"?"},
}
such a way, when
tMSigns = {"a","b","c", --etc.
}
would be enough?
well, after the time I started this thread and asked for help, this method was the one I used when I made it work. I didn't really think about that other types of tables might be faster/better. Is the one you showed faster?QuoteOriginally posted by bastya_elvtars
hashing is faster and less resource consumant
Could you show a code example of how hashing works bastya_elvtars? Maybe then I could modify my script to use hashing instead of loops.
-- this is an example
table={
["a"]=1, -- [key]=value
["b"]=1,
["c"]=1,
-- etc.
}
-- now lets see hashing
function WeHaveAStringValue(val)
if table[val] then --if the string is in the table
-- dothingshere
end
end
You are using an array. Array is:
arr={"a","b"}
which is considered by lua as if it were
arr={[1]="a", [2]="b"}
thus in an array you only list the values, but in tables you do hashing using the [keys] and it's a pity keys are always ascending numbers in arrays. What i recommend is to run a loop on the array(s) you use and insert its elements into a table. Thus your script remains well-configurable still fast on the cost of a little more ram usage.
array={"a","b","c","d"} --declare aray elements
table={} --create empty table
for a=1,getn(array) do -- do a loop consisting of repeats
table[array[a]]=1 -- a-th element of array becomes a key in the table with value 1
end
QuoteOriginally posted by bastya_elvtars
array={"a","b","c","d"} --declare aray elements
table={} --create empty table
for a=1,getn(array) do -- do a loop consisting of repeats
table[array[a]]=1 -- a-th element of array becomes a key in the table with value 1
end
I must have misundertood your example, because this doesn't work =>--Advertise Crusher by blackwings
--v2.0
--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
-----------
--added: safe advertisment
--added: pm to ops
--added: improved what the script detects
--added: profiles that the script should take action against
--fixed: a copy mistake
--changed: from typical loops to hashing = faster
-----------
Bot = "#Anti-Advertise"
function Main()
end
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Check the bottom of the script to see what it can detect
-- Do also check the bottom of the script for the safe advertising settings
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- (1)Shall be tempbanned/banned / (0) this profile shouldn't be effected.
SetToWho = {
[0] = 0, -- Masters
[1] = 0, -- Operators
[2] = 1, -- Vips
[3] = 1, -- Regs
[4] = 0, -- Moderator
[5] = 0, -- NetFounder
[-1] = 1, -- Users
}
adverKill = 3
DNS01={"super","mega","nova","hellfire"}
MSigns={".","-","?","+"}
DNS02={"com","net","org","nu"}
tDNS01={}
tMSigns={}
tDNS02={}
adverCounter = 0
function adverSmashing(user)
if SetToWho[user.iProfile]==1 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)
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)
adverCounter = 0
end
end
collectgarbage()
end
function DataArrival(user,data)
for a=1,getn(DNS01) do
tDNS01[DNS01[a]]=1
tPart02 = tDNS01[DNS01[a]]==1
for b=1,getn(MSigns) do
tMSigns[MSigns[b]]=1
tPart01 = tMSigns[MSigns[b]]==1
tPart03 = tMSigns[MSigns[b]]==1
for c=1,getn(DNS02) do
tDNS02[DNS02[c]]=1
tPart04 = tDNS02[DNS02[c]]==1
user:SendData(Bot, "this was typed = "..tPart04)
advDetect = tPart01..tPart02..tPart03..tPart04
if( strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") then
if( strfind(data, advDetect,1,1) ) then
return adverSmashing(user)
end
end
end
end
end
collectgarbage()
end
Quotearray={"a","b","c","d"} --declare aray elements
table={} --create empty table
for a=1,getn(array) do -- do a loop consisting of repeats
table[array[a]]=1 -- a-th element of array becomes a key in the table with value 1
end
i think he ment you should put it in function main()
QuoteOriginally posted by Optimus
Quotearray={"a","b","c","d"} --declare aray elements
table={} --create empty table
for a=1,getn(array) do -- do a loop consisting of repeats
table[array[a]]=1 -- a-th element of array becomes a key in the table with value 1
end
i think he ment you should put it in function main()
No, this was a general lua tutorial. :)
And yes, it should be in Main() - sorry if I forgot to mention - and thx, Opti.
QuoteOriginally posted by bastya_elvtars
QuoteOriginally posted by Optimus
Quotearray={"a","b","c","d"} --declare aray elements
table={} --create empty table
for a=1,getn(array) do -- do a loop consisting of repeats
table[array[a]]=1 -- a-th element of array becomes a key in the table with value 1
end
i think he ment you should put it in function main()
No, this was a general lua tutorial. :)
And yes, it should be in Main() - sorry if I forgot to mention - and thx, Opti.
All of it, or just some of it?
This is the whole method to insert array intems into a table for further usage.
-- // edit
see this (http://board.univ-angers.fr/action.php?action=getlastboard&threadid=3630&boardid=11) thread, i exactly made the way i explained.
Hmm, still doesn't work. I get this error message = Syntax error: table index is nil
stack traceback:
1: function `DataArrival' at line 82 [file `C:\ptokax\scripts\AdvertiseCrusher2_0.lua']
Either something is missing in the script or this is wrong = tPart01 = tMSigns[MSigns[b]]==1
tPart02 = tDNS01[DNS01[a]]==1
tPart03 = tMSigns[MSigns[b]]==1
tPart04 = tDNS02[DNS02[c]]==1
Here is the rest of the code = --Advertise Crusher by blackwings
--v2.0
--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
-----------
--added: safe advertisment
--added: pm to ops
--added: improved what the script detects
--added: profiles that the script should take action against
--fixed: a copy mistake
--changed: from typical loops to hashing = faster
-----------
Bot = "#Anti-Advertise"
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Check the bottom of the script to see what it can detect
-- Do also check the bottom of the script for the safe advertising settings
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- (1)Shall be tempbanned/banned / (0) this profile shouldn't be effected.
SetToWho = {
[0] = 0, -- Masters
[1] = 0, -- Operators
[2] = 1, -- Vips
[3] = 1, -- Regs
[4] = 0, -- Moderator
[5] = 0, -- NetFounder
[-1] = 1, -- Users
}
adverKill = 3
DNS01={"super","mega","nova","hellfire"}
MSigns={".","-","?","+"}
DNS02={"com","net","org","nu"}
tDNS01={}
tMSigns={}
tDNS02={}
adverCounter = 0
function Main()
for a=1,getn(DNS01) do
tDNS01[DNS01[a]]=1
end
for b=1,getn(MSigns) do
tMSigns[MSigns[b]]=1
end
for c=1,getn(DNS02) do
tDNS02[DNS02[c]]=1
end
end
function adverSmashing(user)
if SetToWho[user.iProfile]==1 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)
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)
adverCounter = 0
end
end
collectgarbage()
end
function DataArrival(user,data)
tPart01 = tMSigns[MSigns[b]]==1
tPart02 = tDNS01[DNS01[a]]==1
tPart03 = tMSigns[MSigns[b]]==1
tPart04 = tDNS02[DNS02[c]]==1
advDetect = tPart01..tPart02..tPart03..tPart04
if( strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") then
if( strfind(data, advDetect,1,1) ) then
return adverSmashing(user)
end
end
collectgarbage()
end
I do not understand your way of declaring those things. Please explain. :)
function DataArrival(user,data)
-- || ||
---- \/ ==== what the hell is this for? :P \/ ==== -----
tPart01 = tMSigns[MSigns[b]]==1
tPart02 = tDNS01[DNS01[a]]==1
tPart03 = tMSigns[MSigns[b]]==1
tPart04 = tDNS02[DNS02[c]]==1
---- /\ ==== what the hell is this for? :P /\ ==== -----
---- || ||
advDetect = tPart01..tPart02..tPart03..tPart04
if( strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") then
if( strfind(data, advDetect,1,1) ) then
return adverSmashing(user)
end
end
collectgarbage()
end
QuoteOriginally posted by bastya_elvtars
I do not understand your way of declaring those things. Please explain. :)
well, my script search for "advDetect" =>
if( strfind(data, advDetect,1,1)) then
which is this =>
advDetect = tPart01..tPart02..tPart03..tPart04
tPart01-04 is the different part of DNS the script looks for
tPart01 = dot/sign
tPart02 = the middle part of a DNS
tPart03 = dot/sign
tPart04 = the extensions, you now, .com and .org
Thats why I try to declare each array to tPart01-04.
But where do a, b and c come from?
QuoteOriginally posted by bastya_elvtars
But where do a, b and c come from?
from here =>
function Main()
for a=1,getn(DNS01) do
tDNS01[DNS01[a]]=1
end
for b=1,getn(MSigns) do
tMSigns[MSigns[b]]=1
end
for c=1,getn(DNS02) do
tDNS02[DNS02[c]]=1
end
end
You have to do the loop again in DataArrival as the lifetime of a, b, and c is only inside Main()
QuoteOriginally posted by bastya_elvtars
You have to do the loop again in DataArrival as the lifetime of a, b, and c is only inside Main()
ok, now my script do the thing in main() and I have loops in DataArrival. The script works, but I don't think it's hashing, so something is still missing =
--Advertise Crusher by blackwings
--v2.0
--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
-----------
--added: safe advertisment
--added: pm to ops
--added: improved what the script detects
--added: profiles that the script should take action against
--fixed: a copy mistake
--changed: from typical loops to hashing = faster
-----------
Bot = "#Anti-Advertise"
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Check the bottom of the script to see what it can detect
-- Do also check the bottom of the script for the safe advertising settings
--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- (1)Shall be tempbanned/banned / (0) this profile shouldn't be effected.
SetToWho = {
[0] = 0, -- Masters
[1] = 0, -- Operators
[2] = 1, -- Vips
[3] = 1, -- Regs
[4] = 0, -- Moderator
[5] = 0, -- NetFounder
[-1] = 1, -- Users
}
adverKill = 3
DNS01={"super","mega","nova","hellfire"}
MSigns={".","-","?","+"}
DNS02={"com","net","org","nu"}
tDNS01={}
tMSigns={}
tDNS02={}
adverCounter = 0
function Main()
for a=1,getn(DNS01) do
tDNS01[DNS01[a]]=1
end
for b=1,getn(MSigns) do
tMSigns[MSigns[b]]=1
end
for c=1,getn(DNS02) do
tDNS02[DNS02[c]]=1
end
end
function adverSmashing(user)
if SetToWho[user.iProfile]==1 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)
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)
adverCounter = 0
end
end
collectgarbage()
end
function DataArrival(user,data)
for d=1,getn(MSigns) do
tPart01 = (strlower(MSigns[d]))
tPart03 = (strlower(MSigns[d]))
for e=1,getn(DNS01) do
tPart02 = (strlower(DNS01[e]))
for f=1,getn(DNS02) do
tPart04 = (strlower(DNS02[f]))
advDetect = tPart01..tPart02..tPart03..tPart04
if( strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") then
if( strfind(data, advDetect,1,1) ) then
return adverSmashing(user)
end
end
end
end
end
collectgarbage()
end
1) you are doing loops inside loops
2) you are redeclaring the same value d times.
3) why use those arrays once you declared tables?
4) please comment what that chunk should do
QuoteOriginally posted by bastya_elvtars
1) you are doing loops inside loops
2) you are redeclaring the same value d times.
3) why use those arrays once you declared tables?
4) please comment what that chunk should do
1)if you mean what I'm doing in DataArrival, well, the script doesn't work if they are separeted
2) I only declare "d" one time, or have I missed something.
in main I use = a,b,c
in dataarrival = d,e,f
3) because you said so = You have to do the loop again in DataArrival as the lifetime of a, b, and c is only inside Main()
4) What is this "chunk" your are talking about??
Maybe you should post the code that your questioning + describe whatever you are wondering better.
Commented what I dislike. Sorry for being brief (and thus rude), but hate typing... :P
for d=1,getn(MSigns) do
tPart01 = (strlower(MSigns[d]))
tPart03 = (strlower(MSigns[d])) -- declaring 2 variables w/ same value
-- why no end HERE?
for e=1,getn(DNS01) do
tPart02 = (strlower(DNS01[e]))
-- and here?
for f=1,getn(DNS02) do
tPart04 = (strlower(DNS02[f]))
-- and here?
advDetect = tPart01..tPart02..tPart03..tPart04
if( strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") then -- so this check is done several times until adving is really found
if( strfind(data, advDetect,1,1) ) then
return adverSmashing(user)
end
end
end
end
end
-- IMHO better use
-- dnsarray={{no,ip,com},{myftp,org},{kicks,ass,org}}
-- this is easier to handle
ok, I changed the double declaration of the value for the MSigns array to only one now.
could you explain this a little bit more = if(strsub(data, 1, 4) == "$To:") then -- so this check is done several times until adving is really found
How do you get/handle the values in a array like this = dnsarray={{no,ip,com},{myftp,org},{kicks,ass,org}}
About the comments in the code why there isn't a "end"(with other words, why the "for" isn't seperated) like this = function DataArrival(user,data)
for d=1,getn(MSigns) do
tPartSigns = (strlower(MSigns[d]))
end
for e=1,getn(DNS01) do
tPart01 = (strlower(DNS01[e]))
end
for f=1,getn(DNS02) do
tPart02 = (strlower(DNS02[f]))
end
advDetect = tPartSigns..tPart01..tPartSigns..tPart02
if( strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") then
if( strfind(data, advDetect,1,1) ) then
return adverSmashing(user)
end
end
collectgarbage()
end
Well, it's because it doesn't work, the "array checks" must be inside of each other. Why? I don't know, but thats how it is = function DataArrival(user,data)
for d=1,getn(MSigns) do
tPartSigns = (strlower(MSigns[d]))
for e=1,getn(DNS01) do
tPart01 = (strlower(DNS01[e]))
for f=1,getn(DNS02) do
tPart02 = (strlower(DNS02[f]))
advDetect = tPartSigns..tPart01..tPartSigns..tPart02
if( strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") then
if( strfind(data, advDetect,1,1) ) then
return adverSmashing(user)
end
end
end
end
end
collectgarbage()
end
Now that the wiki is alive, please visit the following site in order to read plop's tutorial:
http://ptokaxwiki.no-ip.com/wikka.php?wakka=LuaOnTables
QuoteOriginally posted by bastya_elvtars
Now that the wiki is alive, please visit the following site in order to read plop's tutorial:
http://ptokaxwiki.no-ip.com/wikka.php?wakka=LuaOnTables
Maybe I'm blind, but I couldn't see any example on how to use this kind of array =
dnsarray={{no,ip,com},{myftp,org},{kicks,ass,org}}
If
dnsarray={{no,ip,com},{myftp,org},{kicks,ass,org}}
then you can recall "ass" by:
dnsarray[3][2]
QuoteOriginally posted by bastya_elvtars
Ifdnsarray={{no,ip,com},{myftp,org},{kicks,ass,org}}
then you can recall "ass" by:dnsarray[3][2]
hmm, ok, but is that really hashing? (both you and Opti said hashing was better and faster).
First when you gave a suggestion about that array, I thought you meant this = DNSarray={{no,ip,com},{myftp,org},{kicks,ass,org}}
MSigns={".","-","?","+"}
tDNSarray={}
tMSigns={}
function Main()
for c=1,getn(DNSarray) do
tDNSarray[DNSarray[c]]=1
end
for d=1,getn(MSigns) do
tMSigns[MSigns[d]]=1
end
end
function DataArrival(user,data)
for h=1,getn(MSigns) do
vPartSigns = (strlower(MSigns[h]))
for i=1,getn(tDNSarray) do
tDNSarray[i][1] = gsub(tDNSarray[i][1], "<" , "")
vPart01 = tDNSarray[i][1]
vPart02 = tDNSarray[i][2]
advDetect = vPartSigns..vPart01..vPartSigns..vPart02
if( strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
if(strsub(data, 1, 4) == "$To:") and (strfind(data, advDetect,1,1)) then
return adverSmashing(user)
end
end
collectgarbage()
end
end
But I guess I was totally wrong there :P
Now I am confused too. :D I will find a solution but i need some rest 1st.
tGood = {
["dcgui.berlios.de"] ="DCGUI"
}
tBad = {
["revconnect.sf.net"] ="get out"
}
tTags = {
[1] = "$MyINFO $ALL [OP]test [URL]http://dcgui.berlios.de[/URL]",
[2] = "$MyINFO $ALL [OP]test [URL]http://revconnect.sf.net[/URL]",
[3] = "$MyINFO $ALL [OP]test [URL]http://site.com.here[/URL]"
}
for a,nMyInfo in tTags do
s,e,url = strfind(nMyInfo, "([^%.%/]+%.[^%.]+%.%S+)")
if url then
print(url)
if tGood[url] then
print(tGood[url])
elseif tBad[url] then
print(tBad[url])
else
print("no advertising")
end
end
end
Here you have a simple demostration how hashing worksss
EDIT: the loop is only there to demostrate how things work. That part can be deleted eventualy
Gr. Optimus
QuoteOriginally posted by Optimus
Here you have a simple demostration how hashing worksss
EDIT: the loop is only there to demostrate how things work. That part can be deleted eventualy
Gr. Optimus
hmm, pretty confusing example. Seem to be example from a lua, so it's not 100% ptokax adapted.
Plus the method you show there isn't dynamic(atleast that is what it looks like for me :P ), which mean it isn't fitted
to be used in a anti-advertise script.