hello, need an anti advertising bot that checks only unregistered users... it kick, or ban them when they try to advertise through pm or in the main chat...
but it will not check ops, vips and registered users...
didnot find it here... thx if u can help me.)
Give this a try:
--====[ Advertising Shield ]====--
-- Only checks Unregistered users
-- Version: 10
-- By: NightLitch
-- Date: 2004-03-23
----------------------------------------------------
-- Set Botname
BotName = "botname"
-- Set action for advertising ( 0=Warn / 1=Disconnect / 2=Kick / 3=Ban)
Action = 0
-- Set OK hubs that are allowed to be entered.
OkHubs = {
"hub1.no-ip.org",
"hub2.no-ip.org",
}
-- Accepted "sites" or triggers infront of the address
Sites = {
"www.",
"http://",
"ftp://",
"irc.",
"cs.",
}
-- Denyed/not allowed adver's sent in chat/pm
Adver = {
"ip",
"myftp",
"dyndns",
"dns2go",
"dynip",
"d2g",
"dynu",
"mine",
"kick-ass",
"sytes",
"homeip",
"mine",
"serveftp",
"servebeer",
"ass",
"gotdns",
"udgnet",
}
-- Extentions belonging to Adver above.
Ext = {
"com",
"net",
"org",
"se",
"nu",
}
-- Change characters.
CharCh = {
["%(dot%)"]=".",
["dot"]=".",
["%(%-%)"]="-",
["#"]="",
["!"]="",
["+"]="",
["%-"]="",
["*"]="",
["/"]="",
[" '"]="",
}
---------------------------------------------------------------
-- DON'T EDIT BELLOW --
tabAdvert = {}
function Main()
frmHub:RegBot(BotName)
end
function DataArrival(curUser, data)
local Msg = ""
if strsub(data, 1, 1) == "<" and not strfind(data,"> !") and curUser.iProfile < 0 then
local _, _,line = strfind(data, "^%b<>%s+(.*)")
Msg = line
for i,v in CharCh do
line=gsub(line, i, v)
end
if CheckAdver(curUser,line,"in Main-Chat, typing",Msg)==1 then
return 1
end
elseif ( strsub(data, 1, 4) == "$To:" ) and curUser.iProfile < 0 then
local _,_,to,from,line = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
Msg = line
for i,v in CharCh do
line=gsub(line, i, v)
end
if CheckAdver(curUser,line,"in PM to "..to..", typing",Msg)==1 then
return 1
end
end
end
function CheckAdver(curUser,line,msg,Msg)
local adver,extension = Verify(curUser.sName, line,Adver), Verify(curUser.sName, line,Ext)
if adver and extension and OkAdver(adver)~=1 then
tabAdvert = nil
tabAdvert = {}
local action = DoDisc(curUser,msg,line)
SendToOps("",curUser.sName.." ( "..curUser.sIP.." ) is "..action.." becouse advertising "..msg..": "..Msg)
return 1
end
end
function DoDisc(curUser,msg,line)
if Action==0 then
curUser:SendPM(BotName,"You are Warned for advertising "..msg..": "..line) return "Warned"
elseif Action==1 then
curUser:SendPM(BotName,"You are Disconnected for advertising "..msg..": "..line)
curUser:Disconnect() return "Disconnected"
elseif Action==2 then
curUser:SendPM(BotName,"You are Kicked for advertising "..msg..": "..line)
curUser:TempBan() return "Kicked"
elseif Action==3 then
curUser:SendPM(BotName,"You are Banned for advertising "..msg..": "..line)
curUser:Ban() return "Banned"
end
end
function OkAdver(adver)
for i,v in OkHubs do
if strfind(adver,v) then
return 1
end
end
end
function Verify(userdata, msg,table)
if not msg then return end
tmp =""
gsub(strlower(msg), "([a-?0-9.:%-])", function(x) tmp = tmp..x end)
if not tabAdvert[userdata] then
tabAdvert[userdata] = { iClock = clock(), l1 = "", l2 = "", l3 = "", l4= "", l5= "",l6= "",l7= "",l8= "",l9 = tmp}
else
tabAdvert[userdata].iClock = clock()
tabAdvert[userdata].l1 = tabAdvert[userdata].l2
tabAdvert[userdata].l2 = tabAdvert[userdata].l3
tabAdvert[userdata].l3 = tabAdvert[userdata].l4
tabAdvert[userdata].l4 = tabAdvert[userdata].l5
tabAdvert[userdata].l5 = tabAdvert[userdata].l6
tabAdvert[userdata].l6 = tabAdvert[userdata].l7
tabAdvert[userdata].l7 = tabAdvert[userdata].l8
tabAdvert[userdata].l8 = tabAdvert[userdata].l9
tabAdvert[userdata].l9 = tmp
end
local Lines = tabAdvert[userdata].l1.."#"..tabAdvert[userdata].l2.."#"..tabAdvert[userdata].l3.."#"..tabAdvert[userdata].l4.."#"..tabAdvert[userdata].l5.."#"..tabAdvert[userdata].l6.."#"..tabAdvert[userdata].l7.."#"..tabAdvert[userdata].l8.."#"..tabAdvert[userdata].l9
for key, value in table do
if (strfind(Lines, strlower(value), 1, 1)) then
return 1
end
end
end
Cheers
thx but i need lua 4 version.)
First post updated with the Lua 4 one.
Cheers
thx verry much.)
hmmm seems not working perfect.) tryed to advertise as admin and vip and was warned both times...
QuoteOriginally posted by FrAcTi0n
hmmm seems not working perfect.) tryed to advertise as admin and vip and was warned both times...
First post updated once again.
I'm so used to Lua 5 that I used its API :D
That's why it didn't work.
Cheers
hehe thx, made the same think...
so its workin now.) kewl and thx again.)