PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: Thor on 16 April, 2006, 18:52:40

Title: Antispam
Post by: Thor on 16 April, 2006, 18:52:40
This script see the main and the private chat also after an user connected for - now - 15 sec, and if it find in the message links (http,www, dchub) then - optionally - it kick the user, and send a report to the OP-s. It can effective against spammers and advertisers - in Hungary there are many bot, which connect to all hubs of a hublist, and just send a link to the main after connection, and go away... It has a little "bug": on many simultaneusly connection it doesn't work...

--|-----------------------------------------
--|
--| Antispammer and advertiser script
--|
--| The newly connected unregistered users
--|
--| can't write url-s nor the mainchat,
--|
--| nor the pivate chat for the setted time
--|
--| written by Hungarista 2006.04.14
--|
--| thanks the help of Bastya_elvtars
--|
--| and as always to Szmeby
--|
--|-----------------------------------------

tBadWords={
[1] = "http",
[2] = "www",
[3] = "dchub",
--[4] = "anything", and so on...
}

function NewUserConnected(curUser)
newuser = curUser.sName
SetTimer(15000)
StartTimer()
end

kick = true

ChatArrival = function(curUser,data)
if curUser.iProfile == -1 then
if GetTimer() == 1 then
if curUser.sName == newuser then
for i,v in tBadWords do
_,_,msg = string.find(data,"%b<>%s(.*)")
msg = string.lower(msg)
msg = string.gsub(msg,"[^a-z0-9]", "")
if string.find(msg,v) then
timer = GetTimerInterval()/1000
if not kick then
curUser:SendData(frmHub:GetHubBotName(),"Please... Don't advertise and don't spam ;) Thanks. You can't write links to the mainchat for "..timer.." second after connecting, please wait if it is important.")
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." tried to spamming in the main: ["..(os.date("%H:%M:%S")).."] "..string.sub(data,1,-2).."")
elseif kick then
curUser:SendPM(frmHub:GetHubBotName(),"You are being kicked because: Don't advertise and don't spam!")
curUser:Kick(frmHub:GetHubBotName(),"No-no-no, we don't like spammers and advertisers...")
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." has been kicked because tried to spamming in the main: "..string.sub(data,1,-2).."")
SendToAll(frmHub:GetHubBotName(),""..frmHub:GetHubBotName().." is kicking "..curUser.sName.." because: We really don't like spammers...")
end
return 1
end
end
end
end
elseif curUser.bOperator then
_,_,comd,arg = string.find(data,"%b<>%s(%S+)%s(%S+)|")
if comd == "!skick" then
if arg == "on" then
if kick == true then
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking already Enabled")
else
kick = true
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking now Enabled")
end
elseif arg == "off" then
if kick == false then
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking already Disabled")
else
kick = false
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking now Disabled")
end
end
return 1
end
end
end
ToArrival = function(curUser,data)
if curUser.iProfile == -1 then
if GetTimer() == 1 then
if curUser.sName == newuser then
_,_, tomsg = string.find(data, "^%$To:%s%S+%sFrom:%s%S+%s%$%b<>%s(.*)")
_,_, nickto, nickfrom, msg = string.find(data, "^%$To:%s(%S+)%sFrom:%s(%S+)%s%$%b<>%s(.+)")
msg = string.lower(msg)
msg = string.gsub(msg,"[^a-z0-9]", "")
for i,v in tBadWords do
if string.find(msg,v) then
timer = GetTimerInterval()/1000
curUser:SendPM(nickto,"I didn't get this message... You can't write links to the private chat for "..timer.." second after connecting, please wait if it is important.")
if not kick then
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." tried to spamming in private chat: "..tomsg.."")
elseif kick then
curUser:SendPM(frmHub:GetHubBotName(),"You are being kicked because: Don't advertise and don't spam!")
curUser:Kick(frmHub:GetHubBotName(),"No-no-no, we don't like spammers and advertisers...")
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." has been kicked because tried to spamming in private chat: "..tomsg.."")
SendToAll(frmHub:GetHubBotName(),""..frmHub:GetHubBotName().." is kicking "..curUser.sName.." because: We really don't like spammers...")
end
return 1
end
end
end
end
end
end

function OnTimer()
StopTimer()
end

The value of kick can be modified from the script also with command !skick on or off. If reload the script, the value will be true. If kick disabled, it will just report the messages.

//EDIT
Little typing-mistake has been corrected
Title: Re: Antispam
Post by: -SkA- on 16 April, 2006, 20:01:09
Hello, can you convert it in lua 5.1?
Title: Re: Antispam
Post by: Thor on 16 April, 2006, 20:15:12
I did it (it was just a word and two bracket :D ) See here: http://forum.ptokax.org/index.php?topic=5957.0 But u have big hub if i think well, so maybe it won't work... :-\
Title: Re: Antispam
Post by: -SkA- on 16 April, 2006, 20:20:07
 :(

Hmmm.... why not?
Title: Re: Antispam
Post by: Thor on 16 April, 2006, 20:23:23
Because on many same-time connection on NewUserConnected the value of newuser will not be the curUser.sName... Maybe i have to modify it: store new connected users in a table... But it use more CPU ::)
Title: Re: Antispam
Post by: -SkA- on 16 April, 2006, 20:29:25
Ok, I'll wait for news ;) because with lucifer 6.6.6 I don't know why but anti-adv in mainchat doesn't works -.-
Title: Re: Antispam
Post by: Thor on 17 April, 2006, 14:34:01
So, here is it:

--|-----------------------------------------
--|
--| Antispammer and advertiser script
--|
--| The newly connected unregistered users
--|
--| can't write url-s nor the mainchat,
--|
--| nor the pivate chat for the setted time
--|
--| written by Szmeby and Hungarista 2006.04.17
--|
--|-----------------------------------------

tBadWords={
[1] = "http",
[2] = "www",
[3] = "dchub",
--[4] = "anything", and so on...
}
kick = false

idotartam = 15

botname = frmHub:GetHubBotName()
opchat = frmHub:GetOpChatName()
users = {}

function Main()
SetTimer(1000)
StartTimer()
end

function NewUserConnected(curUser)
if not curUser.bRegistered then
users[curUser.sName]=os.time()
end
end

function OnTimer()
for k,v in pairs(users) do
if os.difftime(os.time(), v) > idotartam then users[k] = nil end
end
end

kick = true

ChatArrival = function(curUser,data)
if curUser.iProfile == -1 then
if users[curUser.sName] then
for i,v in pairs(tBadWords) do
_,_,msg = string.find(data,"%b<>%s(.*)")
msg = string.lower(msg)
msg = string.gsub(msg,"[^a-z0-9]", "")
if string.find(msg,v) then
timer = GetTimerInterval()/1000
if not kick then
curUser:SendData(frmHub:GetHubBotName(),"Please... Don't advertise and don't spam ;) Thanks. You can't write links to the mainchat for "..timer.." second after connecting, please wait if it is important.")
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." tried to spamming in the main: ["..(os.date("%H:%M:%S")).."] "..string.sub(data,1,-2).."")
elseif kick then
curUser:SendPM(frmHub:GetHubBotName(),"You are being kicked because: Don't advertise and don't spam!")
curUser:Kick(frmHub:GetHubBotName(),"No-no-no, we don't like spammers and advertisers...")
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." has been kicked because tried to spamming in the main: "..string.sub(data,1,-2).."")
SendToAll(frmHub:GetHubBotName(),""..frmHub:GetHubBotName().." is kicking "..curUser.sName.." because: We really don't like spammers...")
end
return 1
end
end
end
elseif curUser.bOperator then
_,_,comd,arg = string.find(data,"%b<>%s(%S+)%s(%S+)|")
if comd == "!skick" then
if arg == "on" then
if kick == true then
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking already Enabled")
else
kick = true
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking now Enabled")
end
elseif arg == "off" then
if kick == false then
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking already Disabled")
else
kick = false
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking now Disabled")
end
end
return 1
end
end
end
ToArrival = function(curUser,data)
if curUser.iProfile == -1 then
if users[curUser.sName] then
_,_, tomsg = string.find(data, "^%$To:%s%S+%sFrom:%s%S+%s%$%b<>%s(.*)")
_,_, nickto, nickfrom, msg = string.find(data, "^%$To:%s(%S+)%sFrom:%s(%S+)%s%$%b<>%s(.+)")
msg = string.lower(msg)
msg = string.gsub(msg,"[^a-z0-9]", "")
for i,v in pairs(tBadWords) do
if string.find(msg,v) then
timer = GetTimerInterval()/1000
curUser:SendPM(nickto,"I didn't get this message... You can't write links to the private chat for "..timer.." second after connecting, please wait if it is important.")
if not kick then
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." tried to spamming in private chat: "..tomsg.."")
elseif kick then
curUser:SendPM(frmHub:GetHubBotName(),"You are being kicked because: Don't advertise and don't spam!")
curUser:Kick(frmHub:GetHubBotName(),"No-no-no, we don't like spammers and advertisers...")
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." has been kicked because tried to spamming in private chat: "..tomsg.."")
SendToAll(frmHub:GetOpChatName(),""..frmHub:GetHubBotName().." is kicking "..curUser.sName.." because: We really don't like spammers...")
end
return 1
end
end
end
end
end

It works with LUA 5.0 and with LUA 5.1 also. This is the best way to use, but it use more CPU, -Ska- please try it, and say me how it works, thanks ;) It's not an antiadver script, it see bad link just for 15 sec!
Title: Re: Antispam
Post by: rachel on 15 October, 2006, 17:32:14
sorry to dig this topic up again, but i was wondering if you could put the option in this script can be made to kick profile 3 aswell  ;D
Title: Re: Antispam
Post by: Herodes on 15 October, 2006, 17:54:09
Welcome rachel,..

Please post what you are looking for since there are many many antiadvert scripts on the forum.
There may be something that fulfills your needs already.
Try searching for starters. (Inside Finished scripts or Request for scripts sections)
Title: Re: Antispam
Post by: Thor on 15 October, 2006, 17:58:08

--|-----------------------------------------
--|
--| Antispammer and advertiser script
--|
--| The newly connected unregistered users
--|
--| can't write url-s nor the mainchat,
--|
--| nor the pivate chat for the setted time
--|
--| written by Szmeby and Hungarista 2006.04.17
--|
--|-----------------------------------------

tCheckedUsers={
[-1] = 1, -- Unregistered users
[0] = 0, -- Master users
[1] = 0, -- Operator users
[2] = 0, -- VIP users
[3] = 1, -- Registered users
[4] = 0, -- Moderator users
[5] = 0, -- NetFounder users
}

tBadWords={
[1] = "http",
[2] = "www",
[3] = "dchub",
--[4] = "anything", and so on...
}
kick = false

idotartam = 15

botname = frmHub:GetHubBotName()
opchat = frmHub:GetOpChatName()
users = {}

function Main()
SetTimer(1000)
StartTimer()
end

function NewUserConnected(curUser)
if tCheckedUsers[curUser.iProfile] == 1 then
users[curUser.sName]=os.time()
end
end

function OnTimer()
for k,v in pairs(users) do
if os.difftime(os.time(), v) > idotartam then users[k] = nil end
end
end

kick = true

ChatArrival = function(curUser,data)
if users[curUser.sName] then
for i,v in pairs(tBadWords) do
_,_,msg = string.find(data,"%b<>%s(.*)")
msg = string.lower(msg)
msg = string.gsub(msg,"[^a-z0-9]", "")
if string.find(msg,v) then
timer = GetTimerInterval()/1000
if not kick then
curUser:SendData(frmHub:GetHubBotName(),"Please... Don't advertise and don't spam ;) Thanks. You can't write links to the mainchat for "..timer.." second after connecting, please wait if it is important.")
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." tried to spamming in the main: ["..(os.date("%H:%M:%S")).."] "..string.sub(data,1,-2).."")
elseif kick then
curUser:SendPM(frmHub:GetHubBotName(),"You are being kicked because: Don't advertise and don't spam!")
curUser:Kick(frmHub:GetHubBotName(),"No-no-no, we don't like spammers and advertisers...")
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." has been kicked because tried to spamming in the main: "..string.sub(data,1,-2).."")
SendToAll(frmHub:GetHubBotName(),""..frmHub:GetHubBotName().." is kicking "..curUser.sName.." because: We really don't like spammers...")
end
return 1
end
end
end
elseif curUser.bOperator then
_,_,comd,arg = string.find(data,"%b<>%s(%S+)%s(%S+)|")
if comd == "!skick" then
if arg == "on" then
if kick == true then
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking already Enabled")
else
kick = true
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking now Enabled")
end
elseif arg == "off" then
if kick == false then
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking already Disabled")
else
kick = false
curUser:SendData(frmHub:GetHubBotName(),"*** Spam kicking now Disabled")
end
end
return 1
end
end
end
ToArrival = function(curUser,data)
if users[curUser.sName] then
_,_, tomsg = string.find(data, "^%$To:%s%S+%sFrom:%s%S+%s%$%b<>%s(.*)")
_,_, nickto, nickfrom, msg = string.find(data, "^%$To:%s(%S+)%sFrom:%s(%S+)%s%$%b<>%s(.+)")
msg = string.lower(msg)
msg = string.gsub(msg,"[^a-z0-9]", "")
for i,v in pairs(tBadWords) do
if string.find(msg,v) then
timer = GetTimerInterval()/1000
curUser:SendPM(nickto,"I didn't get this message... You can't write links to the private chat for "..timer.." second after connecting, please wait if it is important.")
if not kick then
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." tried to spamming in private chat: "..tomsg.."")
elseif kick then
curUser:SendPM(frmHub:GetHubBotName(),"You are being kicked because: Don't advertise and don't spam!")
curUser:Kick(frmHub:GetHubBotName(),"No-no-no, we don't like spammers and advertisers...")
SendPmToOps(frmHub:GetOpChatName(),""..curUser.sName.." has been kicked because tried to spamming in private chat: "..tomsg.."")
SendToAll(frmHub:GetOpChatName(),""..frmHub:GetHubBotName().." is kicking "..curUser.sName.." because: We really don't like spammers...")
end
return 1
end
end
end
end
end

I don't understand. This script not a forbidden script, it is against spammers, and spammers never registered I think, but you know.
Title: Re: Antispam
Post by: rachel on 15 October, 2006, 18:46:47
Thankyou very much for your time Hungarista, i had to change a little something but is all working ok now   :)