can someone convert this please.
Quote
-- SearchSentry 1.01c
-- by Mutor The Ugly
--
-- Monitors user searches for unwanted queries.
-- Provides option for:
-- - warn [warned 3 times = ban]
-- - timeban [timeban 3 times = ban]
-- - send user website/forum message
-- - loads/saves warns to external files
-- files(s) saved before hub/scripts restart
-- - send report to admin
-- - send report to operators
-- - send report to main chat
--
-- Local Ops now exempt...
--
--User Settings-------------------------------------------------------------------------------------
--Send report to main chat
Snd2All = "0"
--Send pm report to ops
Snd2Ops = "1" -- 1 = on / 0 = off
--Send pm report Admin's Nick
Snd2Admin = "0"
--Admin's Nick or any other single nick
AdminName = "Mutor"
--Name for bot [You can use your main bot, if so no need to register this bot. See 'function main'.
Bot = "[Mosh-Crew]"
-- Message to direct user to hubs website or forum
ForumMsg = "\r\n\r\n\tIf you disagree and would like to be unbanned. Visit our forum at : \r\n\r\n\t\t http://hubforum.no-ip.com \r\n\r\n\t\t\t\tand state your case."
--Minutes to be banned for on first ban offense
Firstx = "20"
--Minutes to be banned on second ban offense
Secondx = "40"
--Minutes to be banned on third ban offense
Thirdx = "60"
--File(s) to save warn data
WarnFile = "Warned.txt"
BanWarnFile = "BanWarned.txt"
--
-- Bad filenames, use caution to avoid kicking/banning for harmless filenames that may include these words.
trigs = {
["stealthdc"] ="Warn",
["r@ygold"] ="Warn",
["animalsex"] ="Warn",
["beastiality"] ="Warn",
["lolita"] ="Warn",
["preteen"] ="Ban",
["incest"] ="Ban",
["rape"] ="Ban",
["underage"] ="Ban",
["childsex"] ="Ban",
["childporn"] ="Ban"
}
--End User Settings----------------------------------------------------------------------------------
Warned = {}
BanWarned = {}
function Main()
-- frmHub:RegBot(Bot) --If using main bot, remark this line, add -- ie.. --frmHub:RegBot(sBot)
frmHub:EnableSearchData(1)
LoadFromFile(WarnFile)
LoadFromFile(BanWarnFile)
end
function DataArrival(user, data)
if ((strlower(strsub(data,1,3))=="$sr")or(strlower(strsub(data,1,7))=="$search")) and not user.bOperator then
BanTime = ""
BanUser = ""
DisconnectUser = ""
xwarned = "3, User Now Banned"
for key, value in trigs do
if( strfind( strlower(data), key) ) then
if value == "Warn" then
DisconnectUser = "1"
if Warned[user.sName]==nil then Warned[user.sName]=1
xwarned = "First Warning"
Offense = "Warned User"
elseif Warned[user.sName]==1 then Warned[user.sName]=2
xwarned = "Second Warning"
Offense = "Warned User"
elseif Warned[user.sName]==2 then Warned[user.sName]=3
xwarned = "Third & Final, Ban Next"
Offense = "Warned User"
elseif Warned[user.sName]==3 then Warned[user.sName]=nil
Warned3x = "1"
Offense = "User Is Banned"
DisconnectUser = ""
end
elseif value == "Ban" then
if BanWarned[user.sName]==nil then BanWarned[user.sName]=1
xwarned = "First Warning"
Offense = "Warned & TimeBanned"
BanWarned3x = "1"
BanTime = Firstx
elseif BanWarned[user.sName]==1 then BanWarned[user.sName]=2
xwarned = "Second Warning"
Offense = "Warned & TimeBanned"
BanWarned3x = "1"
BanTime = Secondx
elseif BanWarned[user.sName]==2 then BanWarned[user.sName]=3
xwarned = "Third & Final, Ban Next"
Offense = "Warned & TimeBanned"
BanWarned3x = "1"
BanTime = Thirdx
elseif BanWarned[user.sName]==3 then BanWarned[user.sName]=nil
Warned3x = "1"
Offense = "User is banned"
end
end
AReport = "\r\n\r\n\t -<> Administrators Report <>-\r\n\t[ ]----------------------------------------------------[ ]"
Report = "\r\n\r\n\t[ Unacceptable Search Detected ]\r\n\r\n\tUsers Name :\t"..user.sName.."\r\n\tSearch From :\t"..user.sIP..".\r\n\tSearch String :\t"..key.."\r\n\tResponse :\t "..Offense.."\r\n\tTimes Warned :\t[ "..xwarned.." ]\r\n\r\n"
WarnMsg = "\r\n\r\n\tYour search conflicts with this hub's policies\r\n\tTimes warned: [ "..xwarned.." ]\r\n\r\n\tUser Name:\t"..user.sName.."\r\n\tSearch From:\t"..user.sIP.."\r\n\tSearch String:\t"..key.."\r\n\r\n\tYou have been kicked!\r\n\r\n"
BanWarnMsg = "\r\n\r\n\tYour search conflicts with this hub's policies\r\n\tTimes warned: [ "..xwarned.." ]\r\n\r\n\tUser Name:\t"..user.sName.."\r\n\tSearch From:\t"..user.sIP.."\r\n\tSearch String:\t"..key.."\r\n\r\n\tYou have been time banned for "..BanTime.." minutes.\r\n\r\n"
BanMsg = "\r\n\r\n\tYour search conflicts with this hub's policies\r\n\r\n\tUser Name:\t"..user.sName.."\r\n\tSearch From:\t"..user.sIP.."\r\n\tSearch String:\t"..key.."\r\n\r\n\tYou have been banned!\r\n\r\n"
if Snd2Admin == "1" then
SendPmToNick(AdminName, Bot,AReport..Report )
end
if Snd2All == "1" then
SendToAll(Bot,Report )
end
if Snd2Ops == "1" then
SendPmToOps(Bot,Report )
end
if DisconnectUser == "1" then
SendPmToNick(user.sName, Bot, WarnMsg)
user:Disconnect()
DisconnectUser = ""
end
if BanWarned3x == "1" then
SendPmToNick(user.sName, Bot, BanWarnMsg)
user:TimeBan(BanTime)
BanWarned3x = ""
end
if Warned3x == "1" then
SendPmToNick(user.sName, Bot, BanMsg..ForumMsg)
user:Ban()
Warned3x = ""
end
if BanUser == "1" then
SendPmToNick(user.sName, Bot, BanMsg..ForumMsg)
user:Ban()
BanUser = ""
end
end
end
end
end
function OnExit()
SaveToFile(BanWarnFile , BanWarned , "BanWarned")
SaveToFile(WarnFile , Warned , "Warned")
end
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t"); -- The Bug was here
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}\r\n"
return sTmp
end
function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end
function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end
With the 50to51.lua script.. i still get an error
thanks, Yvisaur
Quote from: [NL]_Yvisaur on 28 July, 2006, 23:33:55
With the 50to51.lua script.. i still get an error
Yes, because this is Lua4 :-)
Lol, you could try the 425 script and after that the 50to51 script;)
Well done Mutor, i will probably give it a try aswell.
ok it works now :)
ty
look at the credits part for details
-- SearchSentry 1.01c
-- by Mutor The Ugly
--
-- Monitors user searches for unwanted queries.
-- Provides option for:
-- - warn [warned 3 times = ban]
-- - timeban [timeban 3 times = ban]
-- - send user website/forum message
-- - loads/saves warns to external files
-- files(s) saved before hub/scripts restart
-- - can send report to admin
-- - can send report to operators
-- - can send report to main chat
-- - profile exemptions table
--
--
-- Converted to LUA5 by Mutor 9/8/05
--
--- touched by Herodes
--- optimised the script a bit to allow for easier extension (more times than three may be possible with a little work)
--- fixed a small logic bug (BanUser wasn't used)
--- sorry I can't work on this for much longer,.. I am at work :) (Also I haven't tested)
--User Settings-------------------------------------------------------------------------------------
--//--Send report to main chat
Snd2All = "1"
--//--Send pm report to ops
Snd2Ops = "0" --//-- 1 = on / 0 = off
--//--Send pm report Admin's Nick
Snd2Admin = "0"
--//--Admin's Nick or any other single nick
AdminName = "Mutor"
--//--Name for bot [You can use your main bot, if so no need to register this bot. See 'function main'.
Bot = frmHub:GetHubBotName()
--//-- Message to direct user to hubs website or forum
ForumMsg = "\r\n\r\n\tIf you disagree and would like to be unbanned. Visit our forum at : \r\n\r\n"..
"\t\t http://hubforum.no-ip.com \r\n\r\n\t\t\t\tand state your case."
--//--Minutes to be banned for on first ban offense
Firstx = "5"
--//--Minutes to be banned on second ban offense
Secondx = "15"
--//--Minutes to be banned on third ban offense
Thirdx = "30"
--//--File(s) to save warn data
WarnFile = "Warned.txt"
BanWarnFile = "BanWarned.txt"
--//--Set your profiles here.
--//--profile_idx, Exempt from check? [0=no 1=yes], "Profile Name"
SearchProfiles = {
[-1] = { 0, "Unregistered User" },
[0] = { 1, "Master" },
[1] = { 1, "Operator" },
[2] = { 0, "Vip" },
[3] = { 0, "Registered User" },
[4] = { 1, "Moderator" },
[5] = { 1, "NetFounder" },
}
--
-- Bad filenames, use caution to avoid kicking/banning for harmless filenames that may include these words.
trigs = {
["stealthdc"] = "Warn",
["r@ygold"] = "Warn",
["animalsex"] = "Warn",
["beastiality"] = "Warn",
["lolita"] = "Warn",
["preteen"] = "Ban",
["incest"] = "Ban",
["rape"] = "Ban",
["underage"] = "Ban",
["childsex"] = "Ban",
["childporn"] = "Ban"
}
--End User Settings----------------------------------------------------------------------------------
function Main()
if loadfile(WarnFile) ~= nil then
dofile(WarnFile)
else
Warned ={}
Save_File(WarnFile,Warned,"Warned")
end
if loadfile(BanWarnFile) ~= nil then
dofile(BanWarnFile)
else
BanWarned ={}
Save_File(BanWarnFile,BanWarned,"BanWarned")
end
end
function SearchArrival(user, data)
if string.sub(data,1,4) == "$Sea" and SearchProfiles[user.iProfile][1] == 0 then
local BanTime, BanUser, DisconnectUser, xwarned = 0,0,0,"3, User Now Banned"
for key, value in pairs(trigs) do
if ( string.find( string.lower(data), key) ) then
if (value == "Warn") then
DisconnectUser, Offense = "1", "Warned User"
if ( Warned[user.sName]== nil ) then
Warned[user.sName] = 0
end
Warned[user.sName] = Warned[user.sName] + 1
if ( Warned[user.sName] < 4 ) then --- warn the user ...
local tStrings = {
[1] = "First Warning",
[2] = "Second Warning",
[3] = "Third & Final, Ban Next",
}
xwarned = tStrings[Warned[user.sName]]
else --- ban the user
Warned[user.sName] = nil
Warned3x = "1"
Offense = "User Is Banned"
DisconnectUser = 0
end
Save_File( WarnFile, Warned, "Warned" )
elseif (value == "Ban") then
Offense = "Warned & TimeBanned"
if BanWarned[user.sName] == nil then
BanWarned[user.sName] = 0
end
BanWarned[user.sName] = BanWarned[user.sName] + 1
if ( BanWarned[user.sName] < 4 ) then
local tStrings = {
[1] = { "First Warning", Firstx, },
[2] = { "Second Warning", Secondx, },
[3] = { "Third & Final, Ban Next", Thirdx, },
}
BanWarned3x = "1"
xwarned = tStrings[BanWarned[user.sName]][1]
BanTime = tStrings[BanWarned[user.sName]][2]
else
BanWarned[user.sName] = nil
Warned3x = "1"
Offense = "User is banned"
BanUser = "1"
end
Save_File(BanWarnFile,BanWarned,"BanWarned")
end
AReport = "\r\n\r\n\t -<> Administrators Report <>-\r\n"..
"\t[ ]----------------------------------------------------[ ]"
Report = "\r\n\r\n\t[ Unacceptable Search Detected ]\r\n\r\n"..
"\tUsers Name :\t"..user.sName.."\r\n"..
"\tSearch From :\t"..user.sIP..".\r\n"..
"\tSearch String :\t"..key.."\r\n"..
"\tResponse :\t "..Offense.."\r\n"..
"\tTimes Warned :\t[ "..xwarned.." ]\r\n\r\n"
WarnMsg = "\r\n\r\n\tYour search conflicts with this hub's policies\r\n"..
"\tTimes warned: [ "..xwarned.." ]\r\n\r\n"..
"\tUser Name:\t"..user.sName.."\r\n\tSearch From:\t"..user.sIP.."\r\n"..
"\tSearch String:\t"..key.."\r\n\r\n\tYou have been kicked!\r\n\r\n"
BanWarnMsg = "\r\n\r\n\tYour search conflicts with this hub's policies\r\n"..
"\tTimes warned: [ "..xwarned.." ]\r\n\r\n\tUser Name:\t"..user.sName.."\r\n"..
"\tSearch From:\t"..user.sIP.."\r\n\tSearch String:\t"..key.."\r\n\r\n"..
"\tYou have been time banned for "..BanTime.." minutes.\r\n\r\n"
BanMsg = "\r\n\r\n\tYour search conflicts with this hub's policies\r\n\r\n"..
"\tUser Name:\t"..user.sName.."\r\n\tSearch From:\t"..user.sIP.."\r\n"..
"\tSearch String:\t"..key.."\r\n\r\n\tYou have been banned!\r\n\r\n"
if Snd2Admin == "1" then
SendPmToNick(AdminName, Bot,AReport..Report )
end
if Snd2All == "1" then
SendToAll(Bot,Report )
end
if Snd2Ops == "1" then
SendPmToOps(frmHub:GetOpChatName(),Bot..Report )
end
if DisconnectUser == "1" then
SendPmToNick(user.sName, Bot, WarnMsg)
user:Disconnect()
DisconnectUser = 0
end
if BanWarned3x == "1" then
SendPmToNick(user.sName, Bot, BanWarnMsg)
user:TimeBan(BanTime)
BanWarned3x = 0
end
if Warned3x == "1" then
SendPmToNick(user.sName, Bot, BanMsg..ForumMsg)
user:Ban()
Warned3x = 0
end
if BanUser == "1" then
SendPmToNick(user.sName, Bot, BanMsg..ForumMsg)
user:Ban()
BanUser = 0
end
end
end
end
end
function OnExit()
Save_File(WarnFile,Warned,"Warned")
Save_File(BanWarnFile,BanWarned,"BanWarned")
end
Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" );
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
Save_Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
hFile:write( sTab.."\t"..sKey.." = "..sValue);
end
hFile:write( ",\n");
end
hFile:write( sTab.."}");
end
Save_File = function(file,table , tablename )
local hFile = io.open (file , "w")
Save_Serialize(table, tablename, hFile);
hFile:close()
end
Hehem... if string.sub(data,1,4) == "$Sea"
Quote from: Markitos on 29 July, 2006, 09:28:45
Hehem... if string.sub(data,1,4) == "$Sea"
it was like
string.lower(string.sub(data,1,7)) == "$Search"
No other DC protocol command starts with "$Sea" or even "$Se"
is the string.sub really needed in the SearchArrival ? .. no other data besides $Search is in that Arrival afaik
Typhoon?
i thought so to , but didn't remember the $Search Hub part, thank you for refreshing my bad memory
Typhoon?