--RegHound 1.0 --Requested by Sin --Script by Mutor The Ugly 7/10/14 -- --Prompts unregistered users to register on repaeating interval --Hounds in Main Chat, as well as PM -- -- --User Settings------------------------------------------------------------------------------------- -- --Name for bot[You can use your main bot, if so no need to register this bot. See 'function main'. sBot = "[RegHound]" --Interval [in minutes] to PM unregistered users Mins = "1" --Message to send to unregistered Users UnRegMsg = "Get Registered you putz!" -- --End User Settings---------------------------------------------------------------------------------- UnRegTab = {} UnReg = "UnReg.dat" function Main() SetTimer(Mins*60000) StartTimer() frmHub:RegBot(sBot) --If using main bot, remark this line, add -- ie.. --frmHub:RegBot(sBot) LoadFromFile(UnReg) end function OnExit() SaveToFile(UnReg , UnRegTab , "UnRegTab") end function NewUserConnected(user, data) if (user.iProfile == -1 and UnRegTab[user.sName] == nil) then UnRegTab[user.sName] = 1 end end function UserDisconnected(user, data) if (user.iProfile == -1 and UnRegTab[user.sName] ~= nil) then UnRegTab[user.sName] = nil end end function OnTimer() local usr,aux for usr, aux in UnRegTab do if (GetItemByName(usr) ~= nil) then sNick = GetItemByName(usr) sNick:SendPM(sBot, UnRegMsg) sNick:SendData(sBot, UnRegMsg) 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"); 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