READ THE RULES
0 Members and 1 Guest are viewing this topic.
--[[ PM Block 1.0c LUA 5.1 [Strict] [API 2] By Mutor 07/14/07 Requested by TwîsTèd-dèvîl Blocks / Unblocks user PM's by command. -Provides commands/protection by profile or op nick -Block auto-cleared after block time elapsed [+/- 1 min.] -Can block/unblock all [non-protected] online nicks -Can block / unblock offline nicks -Cannot block / unblock own nick -Provides context menu [right click] -Blocked user list saved to file for hub/script restart +Changes from 1.0 +Added auto clear after interval +Changes from 1.0b ~Converted to API 2 strict PM Block Command Help Command Description ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ +pmbhelp PM Block Command Help +block Block This User's PM's +blockall Block All User's PM's +unblock Unblock This User's PM +unblockall Unblock All User's PM's +pmblist List PM Blocked Users ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ]]PbCfg = {-- Botname pulled from the hub or use "CustomName"Bot = SetMan.GetString(21),-- Should bot have a key?BotIsOp = true,-- Bot descriptionBotDesc = "Private Message Blocker",-- Bot Email addressBotMail = "user@domain.com",-- Admins nick for status/error messagesOpNick = "Mutor",-- Send verbose script messages to OpNick? ["yes","no"]Verbose = "yes",-- File to save config/user tableFile = "Blocked.dat",-- Context Menu TitleMenu = SetMan.GetString(0),-- Context Submenu TitleSubMenu = "PM Block",--Block time [in minutes] after which users will be automatically unblocked.BlockTime = 30,--Set your profiles permissions here.--[profile #] = {Commands enabled? [0=no 1=yes], "Custom Profile Name"}Profiles = { [-1] = {false,"Unregistered User"}, [0] = {true,"Master"}, [1] = {true,"Operator"}, [2] = {false,"Vip"}, [3] = {false,"Registered User"}, [4] = {false,"Moderator"}, [5] = {true,"NetFounder"}, [6] = {true,"Owner"}, },Exclude = {"Nick1","Nick2"},}local Script = "PM Block 1.0c"OnStartup = function() Timer = TmrMan.AddTimer(6000) if loadfile(PbCfg.File) then dofile(PbCfg.File) else PbCfg.Blocked = {} Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end if PbCfg.Bot ~= SetMan.GetString(21) then Core.RegBot(PbCfg.Bot,PbCfg.BotDesc,PbCfg.BotMail,PbCfg.BotIsOp) end local hc = {SetMan.GetOpChat().sNick,Core.GetHubSecAlias()} for i,v in ipairs(hc) do if not CheckExclude(v) then table.insert(PbCfg.Exclude,v) end end OnError(Script.." for ".._VERSION.." by Mutor has been started.")endOnTimer = function() local Now,Change = os.time() for i,v in ipairs(PbCfg.Blocked) do if ((Now - v[2]) / 60) > PbCfg.BlockTime then Change = true if PbCfg.Verbose:lower() == "yes" then OnError(v[1].." has been removed from blocked pm users.") end table.remove(PbCfg.Blocked,i) end end if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") endendOnExit = function() OnError(Script.." for ".._VERSION.." by Mutor has been stopped.")endOnError = function(msg) local user = Core.GetUser(PbCfg.OpNick) if user then Core.SendToUser(user,"<"..PbCfg.Bot.."> "..msg.."|") endendUserConnected = function(user,data) if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] or user.sNick:lower() == PbCfg.OpNick:lower() then local Profile = PbCfg.Profiles[user.iProfile][2] or "Undefined Profile" SendBlockCmds(user) Core.SendToUser(user,"<"..PbCfg.Bot.."> "..Profile.."'s "..Script.." commands enabled. ".. "Right click hub tab or user list for a command menu.|") endendOpConnected,RegConnected = UserConnected,UserConnectedChatArrival = function(user, data) local _,_,to = data:find("^$To: (%S+) From:") if to and CheckBlock(user.sNick) then local msg = "Your PM's are blocked! It is senseless to try to speak." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true elseif to and CheckBlock(to) then if not CheckExclude(to) then local msg = "Sorry "..user.sNick..", "..to.."'s PM's are blocked! ".. to.." may receive a message but cannot respond." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end else if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] or user.sNick:lower() == PbCfg.OpNick:lower() then local _,_,cmd = data:find("%b<> %p(%w+)") if cmd and BlockCmds[cmd] then if to and to:lower() == PbCfg.Bot:lower() then Core.SendPmToUser(user,PbCfg.Bot,BlockCmds[cmd](user,data).."|") else Core.SendToUser(user,"<"..PbCfg.Bot.."> "..BlockCmds[cmd](user,data).."|") end return true end end endendToArrival = ChatArrivalCheckBlock = function(nick) for i,v in ipairs(PbCfg.Blocked) do if v[1]:lower() == nick:lower() then return i end end return nilendCheckExclude = function(nick) if next(PbCfg.Exclude) then for i,v in ipairs(PbCfg.Exclude) do if v:lower() == nick:lower() then return i end end end return nilendBlockCmds = { block = function(user,data) if user then local _,_,nick = data:find("%b<> %p%w+ (%S+)|$") if not nick then return "Error!, Usage: "..SetMan.GetString(29):sub(1,1).. "block <nick>" else if nick == user.sNick then return "You cannot block yourself "..user.sNick..". Dont be a fool!" end local usr = Core.GetUser(nick) if usr and PbCfg.Profiles[usr.iProfile] and PbCfg.Profiles[usr.iProfile][1] == 1 then return "You cannot block "..PbCfg.Profiles[usr.iProfile][2].." "..usr.sNick.. ", "..PbCfg.Profiles[usr.iProfile][2].."'s are protected from block." end if usr and usr.sNick:lower() == PbCfg.OpNick:lower() then return PbCfg.OpNick.." is protected and may not be blocked." end if CheckBlock(nick) then return "The user: "..nick.." has already been blocked." else table.insert(PbCfg.Blocked,{nick,os.time()}) Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") local status = "offline" if usr then status,nick = "online",usr.sNick Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. ".. "You may not speak in private message.") end return "The "..status.." user: "..nick.." is now ".. "blocked and cannot speak in private message." end end else return "Block This User's PM's"," %[line:Nickname]"," %[nick]" end end, blockall = function(user,data) if user then local Now,Count,Change = os.time(),0,false for i,usr in ipairs(Core.GetOnlineUsers()) do if not PbCfg.Profiles[usr.iProfile] or not PbCfg.Profiles[usr.iProfile][1] then if usr.sNick:lower() ~= PbCfg.OpNick:lower() then Count = Count + 1 Change = true local x = CheckBlock(usr.sNick) if x then PbCfg.Blocked[x][2] = Now else table.insert(PbCfg.Blocked,{usr.sNick,Now}) end end end end if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end local status = "No" if Count > 0 then status = Count end return status.." users were added to or updated in the pm block table." else return "Block All User's PM's","","" end end, unblock = function(user,data) if user then local _,_,nick = data:find("%b<> %p%w+ (%S+)|$") if not nick then return "Error!, Usage: "..SetMan.GetString(29):sub(1,1).. "unblock <nick>" else if nick:lower() == user.sNick:lower() then return "You cannot unblock yourself "..user.sNick.. ". What fun would that be?" end local Block = CheckBlock(nick) if not Block then return "The user: "..nick.." has not been blocked." else table.remove(PbCfg.Blocked,Block) Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") local status,usr = "offline",Core.GetUser(nick) if usr then status = "online" Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been ".. "unblocked. You may now speak in private message again.") end return "The "..status.." user: "..nick.." is unblocked ".. "and can now speak in private message again." end end else return "Unblock This User's PM"," %[line:Nickname]"," %[nick]" end end, unblockall = function(user,data) if user then PbCfg.Blocked = {} Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") return "All user PM's are now unblocked" else return "Unblock All User's PM's","","" end end, pmblist = function(user,data) if user then if next(PbCfg.Blocked) then local Count = 0 local reply = "Listing PM Blocked Users...\r\n\r\n\tNumber\t\tUser Nick\r\n".. "\t"..string.rep("Ż",40).."\r\n" for i,v in ipairs(PbCfg.Blocked) do reply = reply.."\t"..string.format("[ %-3s ]",i).."\t\t"..v[1].."\r\n" end return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n" else return "There are no users blocked at this time." end else return "List PM Blocked Users","","" end end, pmbhelp = function(user,data) if user then local reply = "PM Block Command Help\r\n\r\n\tCommand\t\tDescription\r\n".. "\t"..string.rep("Ż",40).."\r\n" for i,v in pairs(BlockCmds) do local desc,args = BlockCmds[i]() reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\r\n" end return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n" else return "PM Block Command Help","","" end end,}SendBlockCmds = function(user) for i,v in pairs(BlockCmds) do local desc,arg1,arg2 = BlockCmds[i]() Core.SendToUser(user,"$UserCommand 1 1 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\".. desc.."$<%[mynick]> +"..i..arg1.."||") Core.SendToUser(user,"$UserCommand 1 2 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\".. desc.."$$To: "..PbCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."||") collectgarbage("collect") endendSave_Serialize = function(tTable, sTableName, hFile, sTab) sTab = sTab or ""; hFile:write(sTab..sTableName.." = {\n" ) for key, value in ipairs(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.."}")endSave_File = function(file,table, tablename ) local hFile = io.open (file , "wb") Save_Serialize(table, tablename, hFile) hFile:flush() hFile:close() collectgarbage("collect")end
Mutor there is a script made by you which Blocks the PM of User.I have been using it.If a User's PM is Blocked by and operator,The user can,t PM any of the Hub Users.Can it be added with a Function where in a User's PM is Blocked to only a user Who has blocked that users PM whereafter user can PM any other User but not the one who has Blocked it.----For Reged Users can a function be added where in they can request to Operators and masters to Block the PM of a User for them.After the request a message should be sent to all operators and Masters.----Unblock the Individual PM block option.And...All the above configuration once made should be saving to a file
--[[ PM Block 1.0d LUA 5.1 [Strict] [API 2] By Mutor 07/14/07 Requested by TwîsTèd-dèvîl Blocks / Unblocks user PM's by command. -Provides commands/protection by profile or op nick -Block auto-cleared after block time elapsed [+/- 1 min.] -Can block/unblock all [non-protected] online nicks -Can block / unblock offline nicks -Cannot block / unblock own nick -Provides context menu [right click] -Blocked user list saved to file for hub/script restart +Changes from 1.0 +Added auto clear after interval +Changes from 1.0b ~Converted to API 2 strict +Changes from 1.0c 06/21/09 +Added commands/function to support blocking pm's from specific nicks PM Block Command Help Command Description ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ +pmbhelp PM Block Command Help +block Block This User's PM's +blockall Block All User's PM's +unblock Unblock This User's PM +unblockall Unblock All User's PM's +pmblist List PM Blocked Users ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ]]PbCfg = {-- Name for bot ["" = Hub Bot]Bot = "",-- Should bot have a key?BotIsOp = true,-- Bot descriptionBotDesc = "Private Message Blocker",-- Bot Email addressBotMail = "user@domain.com",-- Admins nick for status/error messagesOpNick = "Mutor",-- Send verbose script messages to OpNick? ["yes","no"]Verbose = "yes",-- File to save config/user tableFile = "Blocked.dat",-- File to save nickname tableNickFile = "BlockedNicks.dat",-- Command Menu Title ["" = Hub Name]Menu = "",-- Command SubMenu Title ["" = Script Name]SubMenu = "",--Block time [in minutes] after which users will be automatically unblocked.BlockTime = 30,--Set your profiles permissions here.--[profile #] = {Commands enabled? [true/false], "Profile Name"}Profiles = { [-1] = {false,"Unregistered User"}, [0] = {true,"Master"}, [1] = {true,"Operator"}, [2] = {false,"Vip"}, [3] = {false,"Registered User"}, },Exclude = {"Nick1","Nick2"},}OnStartup = function() Path,Script = Core.GetPtokaXPath().."scripts/","PM Block 1.0d" PbCfg.Pfxs = SetMan.GetString(29) PbCfg.Pfx = PbCfg.Pfxs:sub(1,1) Timer = TmrMan.AddTimer(6000) if PbCfg.Bot == "" then PbCfg.Bot = SetMan.GetString(21) end if PbCfg.Menu == "" then PbCfg.Menu = SetMan.GetString(0) end if PbCfg.SubMenu == "" then PbCfg.SubMenu = Script end if not PbCfg.File:find("^"..Path,1,true) then PbCfg.File = Path..PbCfg.File end if not PbCfg.NickFile:find("^"..Path,1,true) then PbCfg.NickFile = Path..PbCfg.NickFile end if loadfile(PbCfg.File) then dofile(PbCfg.File) else PbCfg.Blocked = {} Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end if loadfile(PbCfg.NickFile) then dofile(PbCfg.NickFile) else PbCfg.Nicks = {} Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks") end if PbCfg.Bot ~= SetMan.GetString(21) then Core.RegBot(PbCfg.Bot,PbCfg.BotDesc,PbCfg.BotMail,PbCfg.BotIsOp) end local hc = {SetMan.GetOpChat().sNick,Core.GetHubSecAlias()} for i,v in ipairs(hc) do if not CheckExclude(v) then table.insert(PbCfg.Exclude,v) end end OnError(Script.." for ".._VERSION.." by Mutor has been started.")endOnTimer = function() local Now,Change = os.time() for i,v in ipairs(PbCfg.Blocked) do if ((Now - v[2]) / 60) > PbCfg.BlockTime then Change = true if PbCfg.Verbose:lower() == "yes" then OnError(v[1].." has been removed from blocked pm users.") end table.remove(PbCfg.Blocked,i) end end if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") endendOnExit = function() OnError(Script.." for ".._VERSION.." by Mutor has been stopped.")endOnError = function(msg) local user = Core.GetUser(PbCfg.OpNick) if user then Core.SendToUser(user,"<"..PbCfg.Bot.."> "..msg.."|") endendUserConnected = function(user,data) if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] or user.sNick:lower() == PbCfg.OpNick:lower() then local Profile = PbCfg.Profiles[user.iProfile][2] or "Undefined Profile" SendBlockCmds(user) Core.SendToUser(user,"<"..PbCfg.Bot.."> "..Profile.."'s "..Script.." commands enabled. ".. "Right click hub tab or user list for a command menu.|") endendOpConnected,RegConnected = UserConnected,UserConnectedChatArrival = function(user, data) local _,_,to = data:find("^$To: (%S+) From:") if to then if CheckNick(to,user.sNick) then local msg = to.." has blocked private messages from you." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end if CheckBlock(user.sNick) then local msg = "Your PM's are blocked! It is senseless to try to speak." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end if CheckBlock(to) and not CheckExclude(to) then local msg = "Sorry "..user.sNick..", "..to.."'s PM's are blocked! ".. to.." may receive a message but cannot respond." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end end if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] or user.sNick:lower() == PbCfg.OpNick:lower() then local _,_,cmd = data:find("%b<> ["..PbCfg.Pfxs.."](%w+)") if cmd and BlockCmds[cmd] then if to and to:lower() == PbCfg.Bot:lower() then Core.SendPmToUser(user,PbCfg.Bot,BlockCmds[cmd](user,data).."|") else Core.SendToUser(user,"<"..PbCfg.Bot.."> "..BlockCmds[cmd](user,data).."|") end return true end endendToArrival = ChatArrivalCheckBlock = function(nick) for i,v in ipairs(PbCfg.Blocked) do if v[1]:lower() == nick:lower() then return i end endendCheckNick = function(op,nick) for i,v in ipairs(PbCfg.Nicks) do if v[1]:lower() == op:lower() then if v[2]:lower() == nick:lower() then return i end end endendCheckExclude = function(nick) if next(PbCfg.Exclude) then for i,v in ipairs(PbCfg.Exclude) do if v:lower() == nick:lower() then return i end end end return nilendBlockCmds = { block = function(user,data) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "block <nick>" else if nick == user.sNick then return "You cannot block yourself "..user.sNick..". Dont be a fool!" end local usr = Core.GetUser(nick) if usr and PbCfg.Profiles[usr.iProfile] then return "You cannot block "..PbCfg.Profiles[usr.iProfile][2].." "..usr.sNick.. ", "..PbCfg.Profiles[usr.iProfile][2].."'s are protected from block." end if usr and usr.sNick:lower() == PbCfg.OpNick:lower() then return PbCfg.OpNick.." is protected and may not be blocked." end if CheckBlock(nick) then return "The user: "..nick.." has already been blocked." else table.insert(PbCfg.Blocked,{nick,os.time()}) Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") local status = "offline" if usr then status,nick = "online",usr.sNick Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. ".. "You may not speak in private message.") end return "The "..status.." user: "..nick.." is now ".. "blocked and cannot speak in private message." end end else return "Block This User's PM's"," %[line:Nickname]"," %[nick]" end end, blocknick = function(user,data) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "block <nick>" else if nick == user.sNick then return "You cannot block yourself "..user.sNick..". Dont be a fool!" end local usr = Core.GetUser(nick) if usr and PbCfg.Profiles[usr.iProfile] and PbCfg.Profiles[usr.iProfile][1] == 1 then return "You cannot block "..PbCfg.Profiles[usr.iProfile][2].." "..usr.sNick.. ", "..PbCfg.Profiles[usr.iProfile][2].."'s are protected from block." end if usr and usr.sNick:lower() == PbCfg.OpNick:lower() then return PbCfg.OpNick.." is protected and may not be blocked." end if CheckNick(user.sNick,nick) then return "The user: "..nick.." has already been blocked." else table.insert(PbCfg.Nicks,{user.sNick,nick,os.time()}) Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks") local status = "offline" if usr then status,nick = "online",usr.sNick Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. ".. "You may not speak to "..user.sNick.." in private message.") end return "The "..status.." user: "..nick.." is now ".. "blocked and cannot speak to you in private message." end end else return "Block PM's From This User To You"," %[line:Nickname]"," %[nick]" end end, unblocknick = function(user,data) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "unblock <nick>" else if nick:lower() == user.sNick:lower() then return "You cannot unblock yourself "..user.sNick.. ". What fun would that be?" end local Block = CheckNick(user.sNick,nick) if not Block then return "The user: "..nick.." has not been blocked." else table.remove(PbCfg.Nicks,Block) Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks") local status,usr = "offline",Core.GetUser(nick) if usr then status = "online" Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been unblocked. ".. "You may now speak to "..user.sNick.." in private message again.") end return "The "..status.." user: "..nick.." is unblocked ".. "and can now speak in private message to you once more." end end else return "Unblock PM's From This User To You"," %[line:Nickname]"," %[nick]" end end, blockall = function(user,data) if user then local Now,Count,Change = os.time(),0,false for i,usr in ipairs(Core.GetOnlineUsers()) do if not PbCfg.Profiles[usr.iProfile] or not PbCfg.Profiles[usr.iProfile][1] then if usr.sNick:lower() ~= PbCfg.OpNick:lower() then Count = Count + 1 Change = true local x = CheckBlock(usr.sNick) if x then PbCfg.Blocked[x][2] = Now else table.insert(PbCfg.Blocked,{usr.sNick,Now}) end end end end if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end local status = "No" if Count > 0 then status = Count end return status.." users were added to or updated in the pm block table." else return "Block All User's PM's","","" end end, unblock = function(user,data) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "unblock <nick>" else if nick:lower() == user.sNick:lower() then return "You cannot unblock yourself "..user.sNick.. ". What fun would that be?" end local Block = CheckBlock(nick) if not Block then return "The user: "..nick.." has not been blocked." else table.remove(PbCfg.Blocked,Block) Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") local status,usr = "offline",Core.GetUser(nick) if usr then status = "online" Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been ".. "unblocked. You may now speak in private message again.") end return "The "..status.." user: "..nick.." is unblocked ".. "and can now speak in private message again." end end else return "Unblock This User's PM"," %[line:Nickname]"," %[nick]" end end, unblockall = function(user,data) if user then PbCfg.Blocked = {} Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") return "All user PM's are now unblocked" else return "Unblock All User's PM's","","" end end, pmblist = function(user,data) if user then if next(PbCfg.Blocked) then local Count = 0 local reply = "Listing PM Blocked Users...\r\n\r\n\tNumber\t\tUser Nick\r\n".. "\t"..string.rep("Ż",40).."\r\n" for i,v in ipairs(PbCfg.Blocked) do reply = reply.."\t"..string.format("[ %-3s ]",i).."\t\t"..v[1].."\r\n" end return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n" else return "There are no users blocked at this time." end else return "List PM Blocked Users","","" end end, pmbhelp = function(user,data) if user then local reply = "PM Block Command Help\r\n\r\n\tCommand\t\tDescription\r\n".. "\t"..string.rep("Ż",40).."\r\n" for i,v in pairs(BlockCmds) do local desc,args = BlockCmds[i]() reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\r\n" end return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n" else return "PM Block Command Help","","" end end,}SendBlockCmds = function(user) for i,v in pairs(BlockCmds) do local desc,arg1,arg2 = BlockCmds[i]() Core.SendToUser(user,"$UserCommand 1 1 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\".. desc.."$<%[mynick]> +"..i..arg1.."||") Core.SendToUser(user,"$UserCommand 1 2 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\".. desc.."$$To: "..PbCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."||") collectgarbage("collect") endendSave_Serialize = function(tTable, sTableName, hFile, sTab) sTab = sTab or ""; hFile:write(sTab..sTableName.." = {\n" ) for key, value in ipairs(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.."}")endSave_File = function(file,table, tablename ) local hFile = io.open (file , "wb") Save_Serialize(table, tablename, hFile) hFile:flush() hFile:close() collectgarbage("collect")end
--[[ PM Block 1.0e LUA 5.1 [Strict] [API 2] By Mutor 07/14/07 Requested by TwîsTèd-dèvîl Blocks / Unblocks user PM's by command. -Provides commands/protection by profile or op nick -Block auto-cleared after block time elapsed [+/- 1 min.] -Can block/unblock all [non-protected] online nicks -Can block / unblock offline nicks -Cannot block / unblock own nick -Provides context menu [right click] -Blocked user list saved to file for hub/script restart +Changes from 1.0 +Added auto clear after interval +Changes from 1.0b ~Converted to API 2 strict +Changes from 1.0c 06/21/09 +Added commands/function to support blocking pm's from specific nicks +Changes from 1.0d 12/23/09 +Added option to disable auto-clear [Set BlockTime = 0], requested by P_pan PM Block Command Help Command Description ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ +pmbhelp PM Block Command Help +block Block This User's PM's +blockall Block All User's PM's +unblock Unblock This User's PM +unblockall Unblock All User's PM's +pmblist List PM Blocked Users ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ]]PbCfg = {-- Name for bot ["" = Hub Bot]Bot = "",-- Should bot have a key?BotIsOp = true,-- Bot descriptionBotDesc = "Private Message Blocker",-- Bot Email addressBotMail = "user@domain.com",-- Admins nick for status/error messagesOpNick = "Mutor",-- Send verbose script messages to OpNick? [true/false]Verbose = true,-- File to save config/user tableFile = "Blocked.dat",-- File to save nickname tableNickFile = "BlockedNicks.dat",-- Command Menu Title ["" = Hub Name]Menu = "",-- Command SubMenu Title ["" = Script Name]SubMenu = "",--Block time [in minutes] after which users will be automatically unblocked. [0 = disable]BlockTime = 30,--Set your profiles permissions here.--[profile #] = {Commands enabled? [true/false], Protection enabled? [true/false], "Custom Profile Name"}Profiles = { [-1] = {false,false,"Unregistered User"}, [0] = {true,true,"Master"}, [1] = {true,true,"Operator"}, [2] = {false,false,"Vip"}, [3] = {false,false,"Registered User"}, },Exclude = {"Nick1","Nick2"},}OnStartup = function() Path,Script = Core.GetPtokaXPath().."scripts/","PM Block 1.0e" PbCfg.Pfxs = SetMan.GetString(29) PbCfg.Pfx = PbCfg.Pfxs:sub(1,1) if PbCfg.BlockTime > 0 then Timer = TmrMan.AddTimer(60000) end if PbCfg.Bot == "" then PbCfg.Bot = SetMan.GetString(21) end if PbCfg.Menu == "" then PbCfg.Menu = SetMan.GetString(0) end if PbCfg.SubMenu == "" then PbCfg.SubMenu = Script end if not PbCfg.File:find("^"..Path,1,true) then PbCfg.File = Path..PbCfg.File end if not PbCfg.NickFile:find("^"..Path,1,true) then PbCfg.NickFile = Path..PbCfg.NickFile end if loadfile(PbCfg.File) then dofile(PbCfg.File) else PbCfg.Blocked = {} Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end if loadfile(PbCfg.NickFile) then dofile(PbCfg.NickFile) else PbCfg.Nicks = {} Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks") end if PbCfg.Bot ~= SetMan.GetString(21) then Core.RegBot(PbCfg.Bot,PbCfg.BotDesc,PbCfg.BotMail,PbCfg.BotIsOp) end local hc = {SetMan.GetOpChat().sNick,Core.GetHubSecAlias()} for i,v in ipairs(hc) do if not CheckExclude(v) then table.insert(PbCfg.Exclude,v) end end OnError(Script.." for ".._VERSION.." by Mutor has been started.")endOnTimer = function() local Now,Change = os.time() for i,v in ipairs(PbCfg.Blocked) do if ((Now - v[2]) / 60) > PbCfg.BlockTime then if not Change then Change = true end if PbCfg.Verbose then OnError(v[1].." has been removed from blocked pm users.") end table.remove(PbCfg.Blocked,i) end end if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") endendOnExit = function() OnError(Script.." for ".._VERSION.." by Mutor has been stopped.")endOnError = function(msg) local user = Core.GetUser(PbCfg.OpNick) if user then Core.SendToUser(user,"<"..PbCfg.Bot.."> "..msg.."|") endendUserConnected = function(user,data) if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] then local Profile = PbCfg.Profiles[user.iProfile][3] or "Undefined Profile" SendBlockCmds(user) Core.SendToUser(user,"<"..PbCfg.Bot.."> "..Profile.."'s "..Script.." commands enabled. ".. "Right click hub tab or user list for a command menu.|") endendOpConnected,RegConnected = UserConnected,UserConnectedChatArrival = function(user, data) local _,_,to = data:find("^$To: (%S+) From:") if to then if CheckNick(to,user.sNick) then local msg = to.." has blocked private messages from you." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end if CheckBlock(user.sNick) then local msg = "Your PM's are blocked! It is senseless to try to speak." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end if CheckBlock(to) and not CheckExclude(to) then local msg = "Sorry "..user.sNick..", "..to.."'s PM's are blocked! ".. to.." may receive a message but cannot respond." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end end if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] then local _,_,pfx,cmd = data:find("%b<> (["..PbCfg.Pfxs.."])(%a+)") if pfx and cmd and BlockCmds[cmd] then cmd = cmd:lower() if to and to:lower() == PbCfg.Bot:lower() then Core.SendPmToUser(user,PbCfg.Bot,BlockCmds[cmd](user,data,pfx..cmd).."|") else Core.SendToUser(user,"<"..PbCfg.Bot.."> "..BlockCmds[cmd](user,data,pfx..cmd).."|") end return true end endendToArrival = ChatArrivalCheckBlock = function(nick) for i,v in ipairs(PbCfg.Blocked) do if v[1]:lower() == nick:lower() then return i end endendCheckNick = function(op,nick) for i,v in ipairs(PbCfg.Nicks) do if v[1]:lower() == op:lower() then if v[2]:lower() == nick:lower() then return i end end endendCheckExclude = function(nick) if next(PbCfg.Exclude) then for i,v in ipairs(PbCfg.Exclude) do if v:lower() == nick:lower() then return i end end end return nilendBlockCmds = { block = function(user,data,cmd) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "block <nick>" else if nick == user.sNick then return "You cannot block yourself "..user.sNick..". Dont be a fool!" end local usr = Core.GetUser(nick) if usr then if PbCfg.Profiles[usr.iProfile][2] then return "You cannot block "..PbCfg.Profiles[usr.iProfile][3].." "..usr.sNick.. ", "..PbCfg.Profiles[usr.iProfile][3].."'s are protected from block." end if usr.sNick:lower() == PbCfg.OpNick:lower() then return PbCfg.OpNick.." is protected and may not be blocked." end end if CheckBlock(nick) then return "The user: "..nick.." has already been blocked." else table.insert(PbCfg.Blocked,{nick,os.time()}) Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") local status = "offline" if usr then status,nick = "online",usr.sNick Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. ".. "You may not speak in private message.") end return "The "..status.." user: "..nick.." is now ".. "blocked and cannot speak in private message." end end else return "Block This User's PM's"," %[line:Nickname]"," %[nick]" end end, blocknick = function(user,data,cmd) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "block <nick>" else if nick == user.sNick then return "You cannot block yourself "..user.sNick..". Dont be a fool!" end local usr = Core.GetUser(nick) if usr then if PbCfg.Profiles[usr.iProfile][2] then return "You cannot block "..PbCfg.Profiles[usr.iProfile][3].." "..usr.sNick.. ", "..PbCfg.Profiles[usr.iProfile][3].."'s are protected from block." end if usr.sNick:lower() == PbCfg.OpNick:lower() then return PbCfg.OpNick.." is protected and may not be blocked." end end if CheckNick(user.sNick,nick) then return "The user: "..nick.." has already been blocked." else table.insert(PbCfg.Nicks,{user.sNick,nick,os.time()}) Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks") local status = "offline" if usr then status,nick = "online",usr.sNick Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. ".. "You may not speak to "..user.sNick.." in private message.") end return "The "..status.." user: "..nick.." is now ".. "blocked and cannot speak to you in private message." end end else return "Block PM's From This User To You"," %[line:Nickname]"," %[nick]" end end, unblocknick = function(user,data,cmd) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "unblock <nick>" else if nick:lower() == user.sNick:lower() then return "You cannot unblock yourself "..user.sNick.. ". What fun would that be?" end local Block = CheckNick(user.sNick,nick) if not Block then return "The user: "..nick.." has not been blocked." else table.remove(PbCfg.Nicks,Block) Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks") local status,usr = "offline",Core.GetUser(nick) if usr then status = "online" Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been unblocked. ".. "You may now speak to "..user.sNick.." in private message again.") end return "The "..status.." user: "..nick.." is unblocked ".. "and can now speak in private message to you once more." end end else return "Unblock PM's From This User To You"," %[line:Nickname]"," %[nick]" end end, blockall = function(user,data,cmd) if user then local Now,Count,Change = os.time(),0,false for i,usr in ipairs(Core.GetOnlineUsers()) do if not PbCfg.Profiles[usr.iProfile] or not PbCfg.Profiles[usr.iProfile][1] then if usr.sNick:lower() ~= PbCfg.OpNick:lower() then Count = Count + 1 Change = true local x = CheckBlock(usr.sNick) if x then PbCfg.Blocked[x][2] = Now else table.insert(PbCfg.Blocked,{usr.sNick,Now}) end end end end if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end local status = "No" if Count > 0 then status = Count end return status.." users were added to or updated in the pm block table." else return "Block All User's PM's","","" end end, unblock = function(user,data,cmd) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "unblock <nick>" else if nick:lower() == user.sNick:lower() then return "You cannot unblock yourself "..user.sNick.. ". What fun would that be?" end local Block = CheckBlock(nick) if not Block then return "The user: "..nick.." has not been blocked." else table.remove(PbCfg.Blocked,Block) Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") local status,usr = "offline",Core.GetUser(nick) if usr then status = "online" Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been ".. "unblocked. You may now speak in private message again.") end return "The "..status.." user: "..nick.." is unblocked ".. "and can now speak in private message again." end end else return "Unblock This User's PM"," %[line:Nickname]"," %[nick]" end end, unblockall = function(user,data,cmd) if user then PbCfg.Blocked = {} Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") return "All user PM's are now unblocked" else return "Unblock All User's PM's","","" end end, pmblist = function(user,data,cmd) if user then if next(PbCfg.Blocked) then local Count = 0 local reply = "Listing PM Blocked Users...\r\n\r\n\tNumber\t\tUser Nick\r\n".. "\t"..string.rep("Ż",40).."\r\n" for i,v in ipairs(PbCfg.Blocked) do reply = reply.."\t"..string.format("[ %-3s ]",i).."\t\t"..v[1].."\r\n" end return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n" else return "There are no users blocked at this time." end else return "List PM Blocked Users","","" end end, pmbhelp = function(user,data,cmd) if user then local reply = "PM Block Command Help\r\n\r\n\tCommand\t\tDescription\r\n".. "\t"..string.rep("Ż",40).."\r\n" for i,v in pairs(BlockCmds) do local desc,args = BlockCmds[i]() reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\r\n" end return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n" else return "PM Block Command Help","","" end end,}SendBlockCmds = function(user) for i,v in pairs(BlockCmds) do local desc,arg1,arg2 = BlockCmds[i]() Core.SendToUser(user,"$UserCommand 1 1 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\".. desc.."$<%[mynick]> +"..i..arg1.."||") Core.SendToUser(user,"$UserCommand 1 2 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\".. desc.."$$To: "..PbCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."||") collectgarbage("collect") endendSave_Serialize = function(tTable, sTableName, hFile, sTab) sTab = sTab or ""; hFile:write(sTab..sTableName.." = {\n" ) for key, value in ipairs(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.."}")endSave_File = function(file,table, tablename ) local hFile = io.open (file , "wb") Save_Serialize(table, tablename, hFile) hFile:flush() hFile:close() collectgarbage("collect")end
Profiles = { [-1] = {false,"Unregistered User"}, [0] = {true,"Master"}, [1] = {true,"Operator"}, [2] = {false,"Vip"}, [3] = {false,"Registered User"}, },
--[[ PM Block 1.0f LUA 5.1 [Strict] [API 2] By Mutor 07/14/07 Requested by TwîsTèd-dèvîl Blocks / Unblocks user PM's by command. -Provides commands/protection by profile or op nick -Block auto-cleared after block time elapsed [+/- 1 min.] -Can block/unblock all [non-protected] online nicks -Can block / unblock offline nicks -Cannot block / unblock own nick -Provides context menu [right click] -Blocked user list saved to file for hub/script restart +Changes from 1.0 +Added auto clear after interval +Changes from 1.0b ~Converted to API 2 strict +Changes from 1.0c 06/21/09 +Added commands/function to support blocking pm's from specific nicks +Changes from 1.0d 12/23/09 +Added option to disable auto-clear [Set BlockTime = 0], requested by P_pan +Changes from 1.0e 09/20/10 +Added report user pm to bot in OpChat. Requested by For_Ever_MeXxX +Added option, block main chat for unregistered users for 'x' minutes. Requested by For_Ever_MeXxX +Added option, block private message for unregistered users for 'x' minutes. Requested by For_Ever_MeXxX PM Block Command Help Command Description ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ +pmbhelp PM Block Command Help +block Block This User's PM's +blockall Block All User's PM's +unblock Unblock This User's PM +unblockall Unblock All User's PM's +pmblist List PM Blocked Users ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ]]PbCfg = {-- Name for bot ["" = Hub Bot]Bot = "",-- Should bot have a key?BotIsOp = true,-- Bot descriptionBotDesc = "Private Message Blocker",-- Bot Email addressBotMail = "user@domain.com",-- Admins nick for status/error messagesOpNick = "Mutor",-- Send verbose script messages to OpNick? [true/false]Verbose = true,-- File to save config/user tableFile = "Blocked.dat",-- File to save nickname tableNickFile = "BlockedNicks.dat",-- Command Menu Title ["" = Hub Name]Menu = "",-- Command SubMenu Title ["" = Script Name]SubMenu = "",--PM Block time [in minutes] after which users will be automatically unblocked. [0 = disable]BlockTime = 30,--Main Chat block time [in minutes] after which unregistered users may chat in main. [0 = disable]MainBlockTime = 5,--Pm block time [in minutes] after which unregistered users may speak in pm. [0 = disable]PmBlockTime = 5,-- Block true/false--Set your profiles permissions here.--[profile #] = {Commands enabled? [true/false], Protection enabled? [true/false], "Custom Profile Name"}Profiles = { [-1] = {false,false,"Unregistered User"}, [0] = {true,true,"Master"}, [1] = {true,true,"Operator"}, [2] = {false,false,"Vip"}, [3] = {false,false,"Registered User"}, },Exclude = {"Nick1","Nick2"},}OnStartup = function() Path,Script = Core.GetPtokaXPath().."scripts/","PM Block 1.0f" PbCfg.Pfxs,PbCfg.HubBot,PbCfg.MainBlock,PbCfg.PmBlock = SetMan.GetString(29),SetMan.GetString(21),{},{} PbCfg.Pfx = PbCfg.Pfxs:sub(1,1),SetMan.GetString(21) if PbCfg.BlockTime > 0 or PbCfg.MainBlockTime > 0 then Timer = TmrMan.AddTimer(1000) end if PbCfg.Bot == "" then PbCfg.Bot = SetMan.GetString(21) end if PbCfg.Menu == "" then PbCfg.Menu = SetMan.GetString(0) end if PbCfg.SubMenu == "" then PbCfg.SubMenu = Script end if not PbCfg.File:find("^"..Path,1,true) then PbCfg.File = Path..PbCfg.File end if not PbCfg.NickFile:find("^"..Path,1,true) then PbCfg.NickFile = Path..PbCfg.NickFile end if loadfile(PbCfg.File) then dofile(PbCfg.File) else PbCfg.Blocked = {} Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end if loadfile(PbCfg.NickFile) then dofile(PbCfg.NickFile) else PbCfg.Nicks = {} Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks") end if PbCfg.Bot ~= SetMan.GetString(21) then Core.RegBot(PbCfg.Bot,PbCfg.BotDesc,PbCfg.BotMail,PbCfg.BotIsOp) end local hc = {SetMan.GetOpChat().sNick,Core.GetHubSecAlias()} for i,v in ipairs(hc) do if not CheckExclude(v) then table.insert(PbCfg.Exclude,v) end end if PbCfg.MainBlockTime > 0 and next(Core.GetOnlineUsers(-1)) then local pl = "s" if PbCfg.MainBlockTime == 1 then pl = "" end for _,user in ipairs(Core.GetOnlineUsers(-1)) do PbCfg.MainBlock[user.sNick] = os.time() end Core.SendToProfile(-1,"<"..PbCfg.Bot.."> Main block enabled. You may ".. "not speak in main chat for "..tostring(PbCfg.MainBlockTime).." minute"..pl..".|") end if PbCfg.PmBlockTime > 0 and next(Core.GetOnlineUsers(-1)) then local pl = "s" if PbCfg.MainBlockTime == 1 then pl = "" end for _,user in ipairs(Core.GetOnlineUsers(-1)) do PbCfg.PmBlock[user.sNick] = os.time() end Core.SendToProfile(-1,"<"..PbCfg.Bot.."> PM block enabled. You may ".. "not speak in private message for "..tostring(PbCfg.MainBlockTime).." minute"..pl..".|") end OnError(Script.." for ".._VERSION.." by Mutor has been started.")endOnTimer = function() local Now,Change = os.time() for i,v in ipairs(PbCfg.Blocked) do if ((Now - v[2]) / 60) > PbCfg.BlockTime then if not Change then Change = true end if PbCfg.Verbose then OnError(v[1].." has been removed from blocked pm users.") end table.remove(PbCfg.Blocked,i) end end if PbCfg.MainBlockTime > 0 then for i,v in pairs(PbCfg.MainBlock) do if ((Now - v) / 60) > PbCfg.MainBlockTime then local user = Core.GetUser(i) PbCfg.MainBlock[i] = nil if user then Core.SendToUser(user,"<"..PbCfg.Bot.."> Block time has expired you may now chat in main.|") end end end end if PbCfg.PmBlockTime > 0 then for i,v in pairs(PbCfg.PmBlock) do if ((Now - v) / 60) > PbCfg.PmBlockTime then PbCfg.PmBlock[i] = nil end end end if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") endendOnExit = function() OnError(Script.." for ".._VERSION.." by Mutor has been stopped.")endOnError = function(msg) local user = Core.GetUser(PbCfg.OpNick) if user then Core.SendToUser(user,"<"..PbCfg.Bot.."> "..msg.."|") endendUserConnected = function(user,data) if PbCfg.MainBlockTime > 0 and user.iProfile == -1 then if not PbCfg.MainBlock[user.sNick] then PbCfg.MainBlock[user.sNick] = os.time() end local pl = "s" if PbCfg.MainBlockTime == 1 then pl = "" end Core.SendToUser(user,"<"..PbCfg.Bot.."> "..user.sNick..", You may not speak in ".. "main chat for "..tostring(PbCfg.MainBlockTime).." minute"..pl..".|") end if PbCfg.PmBlockTime > 0 and user.iProfile == -1 then if not PbCfg.PmBlock[user.sNick] then PbCfg.PmBlock[user.sNick] = os.time() end local pl = "s" if PbCfg.PmBlockTime == 1 then pl = "" end Core.SendToUser(user,"<"..PbCfg.Bot.."> "..user.sNick..", You may not speak in ".. "private message for "..tostring(PbCfg.PmBlockTime).." minute"..pl..".|") end if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] then local Profile = PbCfg.Profiles[user.iProfile][3] or "Undefined Profile" SendBlockCmds(user) Core.SendToUser(user,"<"..PbCfg.Bot.."> "..Profile.."'s "..Script.." commands enabled. ".. "Right click hub tab or user list for a command menu.|") endendOpConnected,RegConnected = UserConnected,UserConnectedUserDisconnected = function(user) if PbCfg.MainBlockTime > 0 and user.iProfile == -1 then if PbCfg.MainBlock[user.sNick] then PbCfg.MainBlock[user.sNick] = nil end end if PbCfg.PmBlockTime > 0 and user.iProfile == -1 then if PbCfg.PmBlock[user.sNick] then PbCfg.PmBlock[user.sNick] = nil end endendChatArrival = function(user, data) local _,_,to = data:find("^$To: (%S+) From:") if to then if to and to == PbCfg.HubBot then local _,_,msg = data:find("%b<> ([^|]+)") if msg then local s = "<"..PbCfg.Bot.."> "..GetProf(user.iProfile).." "..user.sNick.. " from IP: "..user.sIP.." sent a message to "..PbCfg.HubBot..": "..msg return Core.SendToOpChat(s),true end end if PbCfg.PmBlock[user.sNick] then local x,n = PbCfg.PmBlock[user.sNick] + PbCfg.PmBlockTime*60,os.time() if x > n then local tl = Convert(x) if tl then return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> You may not ".. "speak in private for another "..tl.."|"),true end end end if CheckNick(to,user.sNick) then local msg = to.." has blocked private messages from you." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end if CheckBlock(user.sNick) then local msg = "Your PM's are blocked! It is senseless to try to speak." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end if CheckBlock(to) and not CheckExclude(to) then local msg = "Sorry "..user.sNick..", "..to.."'s PM's are blocked! ".. to.." may receive a message but cannot respond." return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true end else if PbCfg.MainBlock[user.sNick] then local x,n = PbCfg.MainBlock[user.sNick] + PbCfg.MainBlockTime*60,os.time() if x > n then local tl = Convert(x) if tl then return Core.SendToUser(user,"<"..PbCfg.Bot.."> You may not ".. "speak in main chat for another "..tl.."|"),true end end end end if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] then local _,_,pfx,cmd = data:find("%b<> (["..PbCfg.Pfxs.."])(%a+)") if pfx and cmd and BlockCmds[cmd] then cmd = cmd:lower() if to and to:lower() == PbCfg.Bot:lower() then Core.SendPmToUser(user,PbCfg.Bot,BlockCmds[cmd](user,data,pfx..cmd).."|") else Core.SendToUser(user,"<"..PbCfg.Bot.."> "..BlockCmds[cmd](user,data,pfx..cmd).."|") end return true end endendToArrival = ChatArrivalCheckBlock = function(nick) for i,v in ipairs(PbCfg.Blocked) do if v[1]:lower() == nick:lower() then return i end endendCheckNick = function(op,nick) for i,v in ipairs(PbCfg.Nicks) do if v[1]:lower() == op:lower() then if v[2]:lower() == nick:lower() then return i end end endendCheckExclude = function(nick) if next(PbCfg.Exclude) then for i,v in ipairs(PbCfg.Exclude) do if v:lower() == nick:lower() then return i end end end return nilendBlockCmds = { block = function(user,data,cmd) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "block <nick>" else if nick == user.sNick then return "You cannot block yourself "..user.sNick..". Dont be a fool!" end local usr = Core.GetUser(nick) if usr then if PbCfg.Profiles[usr.iProfile][2] then return "You cannot block "..PbCfg.Profiles[usr.iProfile][3].." "..usr.sNick.. ", "..PbCfg.Profiles[usr.iProfile][3].."'s are protected from block." end if usr.sNick:lower() == PbCfg.OpNick:lower() then return PbCfg.OpNick.." is protected and may not be blocked." end end if CheckBlock(nick) then return "The user: "..nick.." has already been blocked." else table.insert(PbCfg.Blocked,{nick,os.time()}) Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") local status = "offline" if usr then status,nick = "online",usr.sNick Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. ".. "You may not speak in private message.") end return "The "..status.." user: "..nick.." is now ".. "blocked and cannot speak in private message." end end else return "Block This User's PM's"," %[line:Nickname]"," %[nick]" end end, blocknick = function(user,data,cmd) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "block <nick>" else if nick == user.sNick then return "You cannot block yourself "..user.sNick..". Dont be a fool!" end local usr = Core.GetUser(nick) if usr then if PbCfg.Profiles[usr.iProfile][2] then return "You cannot block "..PbCfg.Profiles[usr.iProfile][3].." "..usr.sNick.. ", "..PbCfg.Profiles[usr.iProfile][3].."'s are protected from block." end if usr.sNick:lower() == PbCfg.OpNick:lower() then return PbCfg.OpNick.." is protected and may not be blocked." end end if CheckNick(user.sNick,nick) then return "The user: "..nick.." has already been blocked." else table.insert(PbCfg.Nicks,{user.sNick,nick,os.time()}) Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks") local status = "offline" if usr then status,nick = "online",usr.sNick Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. ".. "You may not speak to "..user.sNick.." in private message.") end return "The "..status.." user: "..nick.." is now ".. "blocked and cannot speak to you in private message." end end else return "Block PM's From This User To You"," %[line:Nickname]"," %[nick]" end end, unblocknick = function(user,data,cmd) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "unblock <nick>" else if nick:lower() == user.sNick:lower() then return "You cannot unblock yourself "..user.sNick.. ". What fun would that be?" end local Block = CheckNick(user.sNick,nick) if not Block then return "The user: "..nick.." has not been blocked." else table.remove(PbCfg.Nicks,Block) Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks") local status,usr = "offline",Core.GetUser(nick) if usr then status = "online" Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been unblocked. ".. "You may now speak to "..user.sNick.." in private message again.") end return "The "..status.." user: "..nick.." is unblocked ".. "and can now speak in private message to you once more." end end else return "Unblock PM's From This User To You"," %[line:Nickname]"," %[nick]" end end, blockall = function(user,data,cmd) if user then local Now,Count,Change = os.time(),0,false for i,usr in ipairs(Core.GetOnlineUsers()) do if not PbCfg.Profiles[usr.iProfile] or not PbCfg.Profiles[usr.iProfile][1] then if usr.sNick:lower() ~= PbCfg.OpNick:lower() then Count = Count + 1 Change = true local x = CheckBlock(usr.sNick) if x then PbCfg.Blocked[x][2] = Now else table.insert(PbCfg.Blocked,{usr.sNick,Now}) end end end end if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end local status = "No" if Count > 0 then status = Count end return status.." users were added to or updated in the pm block table." else return "Block All User's PM's","","" end end, unblock = function(user,data,cmd) if user then local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$") if not nick then return "Error!, Usage: "..PbCfg.Pfx.. "unblock <nick>" else if nick:lower() == user.sNick:lower() then return "You cannot unblock yourself "..user.sNick.. ". What fun would that be?" end local Block = CheckBlock(nick) if not Block then return "The user: "..nick.." has not been blocked." else table.remove(PbCfg.Blocked,Block) Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") local status,usr = "offline",Core.GetUser(nick) if usr then status = "online" Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been ".. "unblocked. You may now speak in private message again.") end return "The "..status.." user: "..nick.." is unblocked ".. "and can now speak in private message again." end end else return "Unblock This User's PM"," %[line:Nickname]"," %[nick]" end end, unblockall = function(user,data,cmd) if user then PbCfg.Blocked = {} Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") return "All user PM's are now unblocked" else return "Unblock All User's PM's","","" end end, pmblist = function(user,data,cmd) if user then if next(PbCfg.Blocked) then local Count = 0 local reply = "Listing PM Blocked Users...\r\n\r\n\tNumber\t\tUser Nick\r\n".. "\t"..string.rep("Ż",40).."\r\n" for i,v in ipairs(PbCfg.Blocked) do reply = reply.."\t"..string.format("[ %-3s ]",i).."\t\t"..v[1].."\r\n" end return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n" else return "There are no users blocked at this time." end else return "List PM Blocked Users","","" end end, pmbhelp = function(user,data,cmd) if user then local reply = "PM Block Command Help\r\n\r\n\tCommand\t\tDescription\r\n".. "\t"..string.rep("Ż",40).."\r\n" for i,v in pairs(BlockCmds) do local desc,args = BlockCmds[i]() reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\r\n" end return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n" else return "PM Block Command Help","","" end end,}SendBlockCmds = function(user) for i,v in pairs(BlockCmds) do local desc,arg1,arg2 = BlockCmds[i]() Core.SendToUser(user,"$UserCommand 1 1 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\".. desc.."$<%[mynick]> +"..i..arg1.."||") Core.SendToUser(user,"$UserCommand 1 2 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\".. desc.."$$To: "..PbCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."||") collectgarbage("collect") endendGetProf = function(i) local Prof = "Unregistered User" if i ~= -1 then Prof = ProfMan.GetProfile(i).sProfileName end return ProfendConvert = function(time) if time then local s,x,n = "",0,os.time() local tab = {{31556926,"year"},{2592000,"month"},{604800,"week"}, {86400,"day"},{3600,"hour"},{60,"minute"},{1,"second"}} if time > 0 then if time < 2145876659 then if n > time then time = n - time elseif n < time then time = time - n end for i,v in ipairs(tab) do if time > v[1] then x = math.floor(time/v[1]) if x > 1 then v[2] = v[2].."s" end if x > 0 then s = s..x.." "..v[2]..", " time = time-x*v[1] end end end collectgarbage("collect") return s:sub(1,-3) else return "Invalid date or time supplied. [must be pre 12/31/2037]" end else return "Invalid date or time supplied. [must be post 01/01/1970]" end else return "Invalid date or time supplied." endendSave_Serialize = function(tTable, sTableName, hFile, sTab) sTab = sTab or ""; hFile:write(sTab..sTableName.." = {\n" ) for key, value in ipairs(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.."}")endSave_File = function(file,table, tablename ) local hFile = io.open (file , "wb") Save_Serialize(table, tablename, hFile) hFile:flush() hFile:close() collectgarbage("collect")end
You did somethink remove from this script i can find nothing in line 485 it is just a space...it is good to post the line to help mutor...