I needed a small word censor bot to filter main or private chat from bad words or advs., search what people send and if considered wrong to kick or ban the user, give him a reason, and also send the ops about him.
So i have found censor bot, but it is not working.
I am just a begining LUA programmer so like any newbie I've come for help directly to the source.
If anybody can help me to make this work right i'd be greatfull all my days. Thks.
-------------------------------------------------------------------
botname = frmHub:GetHubBotName()
trigs = { ["fuck"]=1,["pussy"]=2,["suck"]=3,["sucks"]=4,["suckz"]=5,["blow"]=6,["fucker"]=7,
["homeip"]=8,["no-ip"]=9,["dyn"]=10,["dns"]=11,["myftp"]=12,["ass"]=13,["d2g"]=14,
["serveftp"]=15,["sytes"]=16,["http"]=17,["udgnet"]=18,["servebeer"]=19,["zapto"]=20,["hopto"]=21,
["dnsalias"]=22,["bounceme"]=23,["mine"]=24,["lysekil"]=25,["ath"]=26,["xs4all"]=27,["dynip"]=28,
["gotdns"]=29,["servemp3"]=30,["tropico"]=31,["sex"]=32,["pizda"]=33,["curva"]=34,["muie"]=35,
["pula"]=36,["idiot"]=37,["tampit"]=38,["floci"]=39,["cur"]=40,["fund"]=41,["sug"]=42,
["anal"]=43,["pedofil"]=44,["zoofil"]=45,["prost"]=46,["proxenet"]=47,["bitch"]=48,["coaie"]=49,
["penis"]=50,["ovule"]=51,["stupid"]=52,["bou"]=53,["vaca"]=54,["magar"]=55,["cretin"]=56
}
function DataArrival(user, data)
if (not user.bOperator) then
if (( strsub(data, 1, 1) == "<" ) or ( strsub(data, 1, 4) == "$To:" )) then
for key,a in trigs do
if( strfind( strlower(data), key) ) then
user:SendPM( botname, user.sName.." a fost dat afara pentru cuvinte triviale sau reclama." )
user:Disconnect()
return 1
end
end
end
else
if (( strsub(data, 1, 1) == "<" ) or ( strsub(data, 1, 4) == "$To:" )) then
for key,a in trigs do
if( strfind( strlower(data), key) ) then
user:SendPM( botname, user.sName.." a folosit cuvinte triviale sau a facut reclama." )
return 1
end
end
end
end
end
The code only needed minor changes. So if i translate the functions you gave it should work. Can you tell me if i can give him temp or permanent ban from my script, and how can i send a message to master in the mean time. I will also look if i cand find that, but i'm also asking.
The final work should look like this:
--------------------------------------------------------------------
botname = frmHub:GetHubBotName()
trigs = { ["fuck"]=1,["pussy"]=2,["suck"]=3,["sucks"]=4,["suckz"]=5,["blow"]=6,["fucker"]=7,
["homeip"]=8,["no-ip"]=9,["dyn"]=10,["dns"]=11,["myftp"]=12,["ass"]=13,["d2g"]=14,
["serveftp"]=15,["sytes"]=16,["http"]=17,["udgnet"]=18,["servebeer"]=19,["zapto"]=20,["hopto"]=21,
["dnsalias"]=22,["bounceme"]=23,["mine"]=24,["lysekil"]=25,["ath"]=26,["xs4all"]=27,["dynip"]=28,
["gotdns"]=29,["servemp3"]=30,["tropico"]=31,["sex"]=32,["pizda"]=33,["curva"]=34,["muie"]=35,
["pula"]=36,["idiot"]=37,["tampit"]=38,["floci"]=39,["cur"]=40,["fund"]=41,["sug"]=42,
["anal"]=43,["pedofil"]=44,["zoofil"]=45,["prost"]=46,["proxenet"]=47,["bitch"]=48,["coaie"]=49,
["penis"]=50,["ovule"]=51,["stupid"]=52,["bou"]=53,["vaca"]=54,["magar"]=55,["cretin"]=56
}
function ChatArrival (User, data)
if (not User.bOperator) then -- simple bad user in main
if (( strsub(data, 1, 1) == "<" ) or ( strsub(data, 1, 4) == "$To:" )) then
for key,a in trigs do
if( strfind( strlower(data), key) ) then
User:SendPM( botname, User.sName.." a fost dat afara pentru cuvinte triviale sau reclama." )
User:Disconnect()
return 1
end
end
end
else ---if it is a bad op in main master should know
if (( strsub(data, 1, 1) == "<" ) or ( strsub(data, 1, 4) == "$To:" )) then
for key,a in trigs do
if( strfind( strlower(data), key) ) then
User:SendPM( botname, user.sName.." a folosit cuvinte triviale sau a facut reclama." )
return 1
end
end
end
end
end
function ToArrival(User, Data)
if (not User.bOperator) then -- simple bad user in private
if (( strsub(data, 1, 1) == "<" ) or ( strsub(data, 1, 4) == "$To:" )) then
for key,a in trigs do
if( strfind( strlower(data), key) ) then
User:SendPM( botname, User.sName.." a fost dat afara pentru cuvinte triviale sau reclama." )
curUser:Disconnect()
return 1
end
end
end
else ---if it is a bad op in private master should know
if (( strsub(data, 1, 1) == "<" ) or ( strsub(data, 1, 4) == "$To:" )) then
for key,a in trigs do
if( strfind( strlower(data), key) ) then
User:SendPM( botname, User.sName.." a folosit cuvinte triviale sau a facut reclama." )
return 1
end
end
end
end
end
----------------------------------------------------------------------
I will test this and get back to you friend Mutor.
I test it. I tried to write a bad word in main and not just that it doesn't do anything but i also have this error: :(
[07:46] Syntax ...C++\Server\PtokaX 0.3.3.21.nt.dbg\scripts\Censor.lua:15: attempt to call global `strsub' (a nil value)
Find strsub and replace with string.sub :-)
But, that's not all, read what mutor wrote and check again
I have made the changes as you Mutor and you Scanning said and things are improving. Thanks. Now it stops all bad words in private and announce the ops and give Ban and disconnect.
But in main chat in function ChatArrival it doesn't give me no error but it does not work either. I know it's probably something stupid :( but i can't seem to see it. Please point me the error please. Thanks.
------------------------------------------------------------------
--bot of hub
botname = frmHub:GetHubBotName()
--bad words
trigs = { ["fuck"]=1,["pussy"]=2,["suck"]=3,["sucks"]=4,["suckz"]=5,["blow"]=6,["fucker"]=7,
["homeip"]=8,["no-ip"]=9,["dyn"]=10,["dns"]=11,["myftp"]=12,["ass"]=13,["d2g"]=14,
["serveftp"]=15,["sytes"]=16,["http"]=17,["udgnet"]=18,["servebeer"]=19,["zapto"]=20,["hopto"]=21,
["dnsalias"]=22,["bounceme"]=23,["mine"]=24,["lysekil"]=25,["ath"]=26,["xs4all"]=27,["dynip"]=28,
["gotdns"]=29,["servemp3"]=30,["tropico"]=31,["sex"]=32,["pizda"]=33,["curva"]=34,["muie"]=35,
["pula"]=36,["idiot"]=37,["tampit"]=38,["floci"]=39,["cur"]=40,["fund"]=41,["sug"]=42,
["anal"]=43,["pedofil"]=44,["zoofil"]=45,["prost"]=46,["proxenet"]=47,["bitch"]=48,["coaie"]=49,
["penis"]=50,["ovul"]=51,["cacat"]=52,["rahat"]=53,["shit"]=54,["pisat"]=55,["cretin"]=56,
[".ro"]=57,[".com"]=58,[".org"]=59,[".biz"]=60,[".cc"]=61,[".cx"]=62,[".nu"]=63,
[".us"]=64,[".info"]=65,[".ru"]=66,[".es"]=67,[".fr"]=68,[".it"]=69,[".uk"]=70
}
--overwatch main chat
function ChatArrival (user, data)
if(string.sub(data, 1, 4) == "$To:") then
data=string.sub(data,1,string.len(data)-1)
local s,e,txt = string.find(data, "%$(%b<>.+)")
if (not User.bOperator) then -- simple bad user in main
for key,a in trigs do
if( string.find( string.lower(txt), key) ) then
SendToAll( botname,user.sName.." a primit BAN pt. cuvinte interzise. Urmeaza ca masterii sa decida daca a fost intentionat sau doar o greseala. O lista completa a acestor cuvinte poate fi citita folosind in fereastra principala comanda: +rules" )
user:SendPM( botname, user.sName..": ai zis: "..txt.." si acest cuvant apare in lista interzisa de adrese internet sau cuvinte triviale. Trebuia sa citesti regulamentul mai intai. (comanda: +rules)" )
SendPmToOps (botname,user.sName.." a fost dat afara pentru cuvinte triviale sau reclama: "..txt)
user:Ban()
user:Disconnect()
return 1
end
end
else ---if it is a bad op in main master should know
for key,a in trigs do
if( string.find( string.lower(txt), key) ) then
user:SendPM( botname, user.sName.." a folosit cuvinte triviale sau a facut reclama: "..txt )
return 1
end
end
end
end
end
--overwatch on private
function ToArrival(user, data)
if(string.sub(data, 1, 4) == "$To:") then
data=string.sub(data,1,string.len(data)-1)
local s,e,txt = string.find(data, "%$(%b<>.+)")
if (not user.bOperator) then -- simple bad user in main
for key,a in trigs do
if( string.find( string.lower(txt), key) ) then
user:SendPM( botname, user.sName..": ai zis: "..txt.." si acest cuvant apare in lista interzisa de adrese internet sau cuvinte triviale. Trebuia sa citesti regulamentul mai intai. (comanda: +rules)" )
SendPmToOps (botname,user.sName.." a fost dat afara pentru cuvinte triviale sau reclama: "..txt)
user:Ban()
user:Disconnect()
return 1
end
end
else ---if it is a bad op in main master should know
for key,a in trigs do
if( string.find( string.lower(txt), key) ) then
SendPmToOps (botname,user.sName.." a folosit din lista interzisa ceva in exprimarea: "..txt)
return 1
end
end
end
end
end
A guy was banned today with this script and he didn't said no bad words. Is there a glicj?h in this script other than the ones mentioned? Thanks :)
Remove
if(string.sub(data, 1, 4) == "$To:") then
and it's end from the ChatArrival
Do the same in ToArrival
I have deleted those lines but now i have other error:
Syntax ...C++\Server\PtokaX 0.3.3.21.nt.dbg\scripts\Censor.lua:19: bad argument #1 to `lower' (string expected, got nil). Why in ToArrival is working perfect and in ChatArrival it doesn't?
----------------------------------------------------------------------
--bot of hub
botname = frmHub:GetHubBotName()
--bad words
trigs = { ["fuck"]=1,["coaie"]=2,["suck"]=3,["sucks"]=4,["suckz"]=5,["blow"]=6,["fucker"]=7,
["homeip"]=8,["no-ip"]=9,["dyn"]=10,["dns"]=11,["myftp"]=12,["ass"]=13,["d2g"]=14,
["serveftp"]=15,["sytes"]=16,["http"]=17,["udgnet"]=18,["servebeer"]=19,["zapto"]=20,["hopto"]=21,
["dnsalias"]=22,["bounceme"]=23,["mine"]=24,["lysekil"]=25,["stoarfa"]=26,["xs4all"]=27,["dynip"]=28,
["gotdns"]=29,["servemp3"]=30,["tropico"]=31,["sex"]=32,["pizda"]=33,["curva"]=34,["muie"]=35,
["pula"]=36,["proxenet"]=37,["bitch"]=38,["floci"]=39,["penis"]=40,["shit"]=41,["sugi"]=42,
["anal"]=43,["pedofil"]=44,["zoofil"]=45,["cacat"]=46,["muisti"]=47,["gaoaza"]=48,
[".cc"]=49,["cx"]=50,[".biz"]=51,[".net"]=52,[".org"]=53,[".ro"]=54
}
--overwatch main chat
function ChatArrival (user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,msg = string.find(data, "%$(%b<>.+)")
if (not user.bOperator) then -- simple bad user in main
for key,a in trigs do
if(string.find( string.lower(msg), key)) then -- error here
SendToAll( botname,user.sName.." a primit BAN pt. cuvinte interzise. Urmeaza ca masterii sa decida daca a fost intentionat sau doar o greseala. O lista completa a acestor cuvinte poate fi citita folosind in fereastra principala comanda: +rules" )
user:SendPM( botname, user.sName..": ai zis: "..msg.." si acest cuvant apare in lista interzisa de adrese internet sau cuvinte triviale. Trebuia sa citesti regulamentul mai intai. (comanda: +rules)" )
SendPmToOps (botname,user.sName.." a fost dat afara pentru cuvinte triviale sau reclama: "..msg)
user:Ban()
user:Disconnect()
return 1
end
end
else ---if it is a bad op in main master should know
for key,a in trigs do
if(string.find( string.lower(msg), key)) then
user:SendPM( botname, user.sName.." a folosit cuvinte triviale sau a facut reclama: "..msg )
return 1
end
end
end
end
--overwatch on private
function ToArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,txt = string.find(data, "%$(%b<>.+)")
if (not user.bOperator) then -- simple bad user in main
for key,a in trigs do
if( string.find( string.lower(txt), key) ) then
user:SendPM( botname, user.sName..": ai zis: "..txt.." si acest cuvant apare in lista interzisa de adrese internet sau cuvinte triviale. Trebuia sa citesti regulamentul mai intai. (comanda: +rules)" )
SendPmToOps (botname,user.sName.." a fost dat afara pentru cuvinte triviale sau reclama: "..txt)
user:Ban()
user:Disconnect()
return 1
end
end
else ---if it is a bad op in main master should know
for key,a in trigs do
if( string.find( string.lower(txt), key) ) then
SendPmToOps (botname,user.sName.." a folosit din lista interzisa ceva in exprimarea: "..txt)
return 1
end
end
end
end
Try changin this
local s,e,msg = string.find(data, "%$(%b<>.+)")
to this
local s,e,msg = string.find(data, "%b<>(.+)")
in ChatArrival
It should work...
Adn the reason it didnt work is beacuse the data in ChatArrival and ToArrival look diffrent.. So you cant use same string.find to find msg
It's working just fine.This is the final version. I worked for this cause i like to work with script snot with big bots.
-------------------------------------------------------------
--bot of hub
botname = frmHub:GetHubBotName()
--bad words
trigs = { ["fuck"]=1,["coaie"]=2,["suck"]=3,["sucks"]=4,["suckz"]=5,["blow"]=6,["fucker"]=7,
["homeip"]=8,["no-ip"]=9,["dyn"]=10,["dns"]=11,["myftp"]=12,["ass"]=13,["d2g"]=14,
["serveftp"]=15,["sytes"]=16,["http"]=17,["udgnet"]=18,["servebeer"]=19,["zapto"]=20,["hopto"]=21,
["dnsalias"]=22,["bounceme"]=23,["mine"]=24,["lysekil"]=25,["stoarfa"]=26,["xs4all"]=27,["dynip"]=28,
["gotdns"]=29,["servemp3"]=30,["tropico"]=31,["sex"]=32,["pizda"]=33,["curva"]=34,["muie"]=35,
["pula"]=36,["proxenet"]=37,["bitch"]=38,["floci"]=39,["penis"]=40,["shit"]=41,["sugi"]=42,
["anal"]=43,["pedofil"]=44,["zoofil"]=45,["cacat"]=46,["muisti"]=47,["gaoaza"]=48
}
--overwatch main chat
function ChatArrival (user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,msg = string.find(data, "%b<>(.+)")
if (not user.bOperator) then -- simple bad user in main
for key,a in trigs do
if(string.find( string.lower(msg), key)) then -- error here
SendToAll( botname,user.sName.." a primit BAN pt. cuvinte interzise. Mesajul sau nu va fi afisat din respect pentru ceilalti VIP. Urmeaza ca masterii sa decida daca a fost intentionat sau doar o greseala. O lista completa a acestor cuvinte poate fi citita folosind in fereastra principala comanda: +rules" )
user:SendPM( botname, user.sName..": ai zis: "..msg.." si acest cuvant apare in lista interzisa de adrese internet sau cuvinte triviale. Trebuia sa citesti regulamentul mai intai. (comanda: +rules)" )
SendPmToOps (botname,user.sName.." a fost dat afara pentru cuvinte triviale sau reclama: "..msg)
user:Ban()
user:Disconnect()
return 1
end
end
else ---if it is a bad op in main master should know
for key,a in trigs do
if(string.find( string.lower(msg), key)) then -- error here
user:SendPM( botname, user.sName.." a folosit cuvinte triviale sau a facut reclama: "..msg )
return 1
end
end
end
end
--overwatch on private
function ToArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,txt = string.find(data, "%$(%b<>.+)")
if (not user.bOperator) then -- simple bad user in main
for key,a in trigs do
if( string.find( string.lower(txt), key) ) then
user:SendPM( botname, user.sName..": ai zis: "..txt.." si acest cuvant apare in lista interzisa de adrese internet sau cuvinte triviale. Trebuia sa citesti regulamentul mai intai. (comanda: +rules)" )
SendPmToOps (botname,user.sName.." a fost dat afara pentru cuvinte triviale sau reclama: "..txt)
user:Ban()
user:Disconnect()
return 1
end
end
else ---if it is a bad op in main master should know
for key,a in trigs do
if( string.find( string.lower(txt), key) ) then
SendPmToOps (botname,user.sName.." a folosit din lista interzisa ceva in exprimarea: "..txt)
return 1
end
end
end
end
I t still remains to solve the problem that if a user use a perfectly good word as "sexophon" and we have "sex" in bad words he will get banned. That's bad.
I hope if i save instead of "sex" ->>> " sex " the problem will be solved. But is this truelly a problem? What do you think guys? How would you deal with that logical problem?
You need to check for a space or punctuation around the bad word....
try
if(string.find( string.lower(msg), "[%s%.%,%-%_]" .. key .. "[%s%.%,%-%_]")) then
instead of
if(string.find( string.lower(msg), key)) then
All good man but where is tha space char? If i write with spaces it doesn't work. Which was the space in LUA5?
For instance i have the word kkt in bad words. In any others situations it finds it. I have found 2 exceptions.
If i write only kkt in chat, nothing less, it escapes control. I understand that after the word is like a null value. But how can i interpret that in LUA?
Also i tried writing muci.no-ip.com and it doesn't detect the bad word "no-ip" because it has the special caracter "-". How do I deal with this exceptions?
if(string.find( string.lower(msg), "[%s%.%,%-%_]?" .. key .. "[%s%.%,%-%_%|]?")) then
should do it,
added pipeline to end, and made the char checks not return nil if not found at start or end of phraise
QuoteOriginally posted by Paco
Also i tried writing muci.no-ip.com and it doesn't detect the bad word "no-ip" because it has the special caracter "-". How do I deal with this exceptions?
When using special chars save them in settings like...
%.
%-
%_
%@
and so on...
so the bad phaise "no-ip" should be "no%-ip"
I think that should do for now. Final version of Romanian Word Censor V.1.0. It really works. I expect critics and bugs.
---------------------------------------------------------------------
Special thanks goes to the true artists of LUA who really have proven to contribue to the expansion of LUA language with their continue support. Thank you guys. I'm ib your debt.
-order of helping appearance-
Mutor
Scanning
madman
Carayzon
---get system boot
botname = frmHub:GetHubBotName()
---bad words list
trigs = { ["fuck"]=1,["coaie"]=2,["suck"]=3,["sucks"]=4,["suckz"]=5,["blow"]=6,["fucker"]=7,
["homeip"]=8,["no%-ip"]=9,["dyn"]=10,["dns"]=11,["myftp"]=12,["asshole"]=13,["d2g"]=14,
["serveftp"]=15,["sytes"]=16,["http"]=17,["udgnet"]=18,["servebeer"]=19,["zapto"]=20,["hopto"]=21,
["dnsalias"]=22,["bounceme"]=23,["masochist"]=24,["lysekil"]=25,["stoarfa"]=26,["xs4all"]=27,["dynip"]=28,
["gotdns"]=29,["servemp3"]=30,["tropico"]=31,["sex"]=32,["pizda"]=33,["curva"]=34,["muie"]=35,
["pula"]=36,["proxenet"]=37,["bitch"]=38,["floci"]=39,["penis"]=40,["shit"]=41,["sugi"]=42,
["anal"]=43,["pedofil"]=44,["zoofil"]=45,["cacat"]=46,["muisti"]=47,["gaoaza"]=48,
["sperma"]=49,["kkt"]=50,["futai"]=51,["futeai"]=52,["erectie"]=53,["ejaculare"]=54,["felatio"]=54,["labii"]=55,["dchub"]=56
}
---overwatch on main chat
function ChatArrival (user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,msg = string.find(data, "%b<>(.+)")
if (not user.bOperator) then -- simple bad user in main
for key,a in trigs do
if(string.find( string.lower(msg), "[%s%.%,%-%_]?" .. key .. "[%s%.%,%-%_%|]?")) then
SendToAll( botname,user.sName.." a primit BAN pt. cuvinte interzise si isi cere scuze. Mesajul sau nu va fi afisat din respect pentru ceilalti VIP. Urmeaza ca masterii sa decida daca a fost intentionat sau doar o greseala. O lista completa a acestor cuvinte poate fi citita folosind in fereastra principala comanda: +rules" )
user:SendPM( botname, user.sName..": ai zis: "..msg.." si acest cuvant apare in lista interzisa de adrese internet sau cuvinte triviale. Trebuia sa citesti regulamentul mai intai. (comanda: +rules)" )
SendPmToOps ( botname,user.sName.." a fost dat afara pentru cuvinte triviale sau reclama: "..msg )
user:Ban()
user:Disconnect()
return 1
end
end
else ---if it is a bad op in main master should know
for key,a in trigs do
if(string.find( string.lower(msg), "[%s%.%,%-%_]?" .. key .. "[%s%.%,%-%_%|]?")) then
user:SendPM( botname, user.sName.." a folosit cuvinte triviale sau a facut reclama: "..msg )
return 1
end
end
end
end
---overwatch on private
function ToArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,msg = string.find(data, "%$(%b<>.+)")
if (not user.bOperator) then -- simple bad user in main
for key,a in trigs do
if(string.find( string.lower(msg), "[%s%.%,%-%_]?" .. key .. "[%s%.%,%-%_%|]?")) then
user:SendPM( botname, user.sName..": ai zis: "..txt.." si acest cuvant apare in lista interzisa de adrese internet sau cuvinte triviale. Trebuia sa citesti regulamentul mai intai. (comanda: +rules)" )
SendPmToOps ( botname,user.sName.." a fost dat afara pentru cuvinte triviale sau reclama: "..msg)
user:Ban()
user:Disconnect()
return 1
end
end
else ---if it is a bad op in main master should know
for key,a in trigs do
if(string.find( string.lower(msg), "[%s%.%,%-%_]?" .. key .. "[%s%.%,%-%_%|]?")) then
SendPmToOps ( botname,user.sName.." a folosit din lista interzisa ceva in exprimarea: "..msg )
return 1
end
end
end
end
U should replace the old script in the thread post with the new script mate =]
Also place scripts between the [code] tag.
{code}Somecode{/code}
{} = []
QuoteOriginally posted by Corayzon
U should replace the old script in the thread post with the new script mate =]
Also place scripts between the [code] tag.
{code}Somecode{/code}
{} = []
Yes corayzon and why not script using tabs? Its more easy to find bugs.
Cheers...
The script did had tabs but i had no ideea how to format it right. Thks for showing me how. I'm only a one week poster. :] Sorry
How should I change the script in order to introduce a list of safe words?