Author Topic: Antispam  (Read 7324 times)

0 Members and 1 Guest are viewing this topic.

Offline Thor

  • Scripter
  • Lord
  • ******
  • Posts: 290
  • Karma: +45/-5
    • Hungarian Direct Connect Site
Antispam
« 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...
Code: [Select]
--|-----------------------------------------
--|
--| 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
« Last Edit: 20 April, 2006, 18:27:40 by Hungarista »

PtokaX forum

Antispam
« on: 16 April, 2006, 18:52:40 »

Offline -SkA-

  • Double Ace
  • *
  • Posts: 133
  • Karma: +24/-2
Re: Antispam
« Reply #1 on: 16 April, 2006, 20:01:09 »
Hello, can you convert it in lua 5.1?
???:::??x??em?-N????:::??? ?wN??

BrianzaLand Blog" style="border:0

Offline Thor

  • Scripter
  • Lord
  • ******
  • Posts: 290
  • Karma: +45/-5
    • Hungarian Direct Connect Site
Re: Antispam
« Reply #2 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... :-\

Offline -SkA-

  • Double Ace
  • *
  • Posts: 133
  • Karma: +24/-2
Re: Antispam
« Reply #3 on: 16 April, 2006, 20:20:07 »
 :(

Hmmm.... why not?
???:::??x??em?-N????:::??? ?wN??

BrianzaLand Blog" style="border:0

Offline Thor

  • Scripter
  • Lord
  • ******
  • Posts: 290
  • Karma: +45/-5
    • Hungarian Direct Connect Site
Re: Antispam
« Reply #4 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 ::)

Offline -SkA-

  • Double Ace
  • *
  • Posts: 133
  • Karma: +24/-2
Re: Antispam
« Reply #5 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 -.-
???:::??x??em?-N????:::??? ?wN??

BrianzaLand Blog" style="border:0

Offline Thor

  • Scripter
  • Lord
  • ******
  • Posts: 290
  • Karma: +45/-5
    • Hungarian Direct Connect Site
Re: Antispam
« Reply #6 on: 17 April, 2006, 14:34:01 »
So, here is it:
Code: [Select]
--|-----------------------------------------
--|
--| 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!
« Last Edit: 02 September, 2006, 00:43:04 by Hungarista »

Offline rachel

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Antispam
« Reply #7 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

Herodes

  • Guest
Re: Antispam
« Reply #8 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)

Offline Thor

  • Scripter
  • Lord
  • ******
  • Posts: 290
  • Karma: +45/-5
    • Hungarian Direct Connect Site
Re: Antispam
« Reply #9 on: 15 October, 2006, 17:58:08 »
Code: [Select]
--|-----------------------------------------
--|
--| 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.

Offline rachel

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Antispam
« Reply #10 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   :)

PtokaX forum

Re: Antispam
« Reply #10 on: 15 October, 2006, 18:46:47 »