--UnSeen 1.0 -- --by Mutor 9/29/04 -- --Removes/restores user from/to user list --Unlike other scipts that use the $Quit command this one just --unregisters/registers a users nick from the user list as if a bot --No Problems with the 'nick already taken' as the user is not logged out of the hub --Saves to text files on hub script/restart -- --Note: When a user is hidden they cannot receive a PM [they can send one tho] --Hidden users can participate in the main chat -- --User Settings------------------------------------------------------------------------------------- -- Bot = "[Stealth]" -- Rename to your main Px bot Comm1 = "+hide" -- Script Command Comm2 = "+unhide" -- Script Command HiddenFile = "Hidden.dat" -- File to save hidden table to -- --End User Settings---------------------------------------------------------------------------------- HiddenTab = {} function Main() LoadFromFile(HiddenFile) --frmHub:RegBot(Bot) --Uncomment if not using Px botname end function OnExit() SaveToFile(HiddenFile , HiddenTab , "HiddenTab") end function DataArrival(user, data) s,e,cmd, unick = strfind(data, "^%b<>%s+(%S+)%s+(%S+)|$") if (cmd==Comm1) and user.bOperator then if not GetItemByName(unick) then user:SendData(Bot, "The Nick: "..unick.." is not logged in, check your spelling") elseif HiddenTab[unick] == 1 then user:SendData(Bot, "The Nick: "..unick.." is already hidden.") else user:SendData(Bot, "Removing Nick: "..unick.." from the user list.") frmHub:UnregBot(unick) HiddenTab[unick] = 1 end return 1 elseif (cmd==Comm2) and user.bOperator then if HiddenTab[unick] == nil then user:SendData(Bot, "The Nick: "..unick.." is not on the hidden list, check your spelling") else user:SendData(Bot, "The Nick: "..unick.." has been removed from the hidden list.") HiddenTab[unick] = nil frmHub:RegBot(unick) end return 1 end end function UserDisconnected(user, data) if HiddenTab[user.sName] ~= nil then HiddenTab[user.sName] = nil SaveToFile(HiddenFile , HiddenTab , "HiddenTab") end end OpDisconnected = UserDisconnected 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"); 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.."}" 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