PtokaX forum

Archive => Archived 5.1 boards => Finished Scripts => Topic started by: Thor on 16 April, 2006, 20:12:51

Title: AntiSpam
Post by: Thor on 16 April, 2006, 20:12:51
Converted to LUA 5.1

--|-----------------------------------------
--|
--| 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
--|
--| Converted LUA 5.1 2oo6.04.16
--|
--|-----------------------------------------

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 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
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 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
end

function OnTimer()
StopTimer()
end

--- Edited
In ToArrival missing pairs added thx Markitos :)
Title: Re: AntiSpam
Post by: Markitos on 16 April, 2006, 20:40:58
for i,v in tBadWords do in ToArrival function  ;D
Title: Re: AntiSpam
Post by: mastdesi on 27 August, 2006, 21:17:11
can u plz make the time from 15 seconds to like forever?????? (i tried changing the time my self but it stay at 15 seconds )

and one more thing i want it to work for regged uesers also.

Title: Re: AntiSpam
Post by: Thor on 27 August, 2006, 21:33:05
I think this is what you looking for: http://forum.ptokax.org/index.php?topic=5961.0  ;)
Title: Re: AntiSpam
Post by: rik007 on 04 November, 2006, 00:16:08
how i get this script  ???