--MembersOnly 1.0 -- --Based on 100% Blocker by chill & Allow Nicks 1.0 by Mutor -- -- -allows transfers by members only [those with member tag in nick]. -- -option to manual block/unblock a user. -- -loads/saves warns to external files. -- -files(s) saved before hub/scripts restart. -- -disabled display of block command. -- -operators are exempt from check. -- --User Settings------------------------------------------------------------------------------------- bot = "[Sentry]" --Rename to you main Px bot prefix = "[MBR]" --Member tag [if less or more than 5 charachters,adjust line 45 & 46] cmd1 = "+block" --Manual block command cmd2 = "+unblock" --Manual unblock command Blocked = "Blocked.dat" --Filename for blocked user list. --End User Settings---------------------------------------------------------------------------------- -- BlockedNicks = {} BlockTriggs = { ["$Rev"] = 1, ["$Con"] = 2, ["$Sea"] = 3, } function Main() frmHub:EnableFullData(1) LoadFromFile(Blocked) end function OnExit() SaveToFile(Blocked , BlockedNicks , "BlockedNicks") end function NewUserConnected(curUser) if pre ~= prefix then BlockedNicks[strlower(curUser.sName)] = 1 elseif pre == prefix and BlockedNicks[strlower(unick)] == 1 then BlockedNicks[strlower(unick)] = nil end end function DataArrival(curUser,data) if strsub(data, 1, 13) == "$ValidateNick" then pre = strsub(data, 15, 19); unick = strsub(data, 20, -2); end if strsub(data,1,1) == "$" then local str1 = strsub(data,1,4) if BlockTriggs[str1] then if BlockedNicks[strlower(curUser.sName)] then curUser:SendData("*** You are not authorized to search or download.") return 1 end end elseif strsub(data,1,1) == "<" and curUser.bOperator then local _,_,cmd,nick = strfind(data,"^%b<>%s+(%S+)%s+(%S+)|$") if cmd and cmd == cmd2 then if BlockedNicks[strlower(nick)] then BlockedNicks[strlower(nick)] = nil curUser:SendData("*** "..nick.." has been unblocked.") return 1 end else if cmd and cmd == cmd1 then if BlockedNicks[strlower(nick)] == 1 then curUser:SendData("*** "..nick.." is already blocked. Use +unblock to unblock this user.") return 1 else BlockedNicks[strlower(nick)] = 1 curUser:SendData("*** "..nick.." is now blocked.") return 1 end end end end 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