READ THE RULES
0 Members and 1 Guest are viewing this topic.
--[[ RecordBot 1.5 - Lua 5 version by jiten Based on RecordBot vKryFinal written by bonki 2003 Description: Logs and displays a hub's all time share and user record. - Fixed: Huge users bug and some stuff (thx to TïMê†råVêlléR) - Fixed: Stats sending before MOTD - Added: Top Share and Sharer Record (requested by XPMAN) - Added: Reg Bot switch (requested by (uk)jay) - Fixed: Nil Max Sharer (thx Cosmos) - Added: Ignore List (requested by chettedeboeuf) - Fixed: User Record Time (11/26/2005) - Added: Top Sharer and Share validation delay (requested by chettedeboeuf) - Changed: Command Parsing and profile permission structure - Fixed: Top Sharer and Share Delay bug (thx to chettedeboeuf) - Chaged: Some code rewritten - Added: Time/Date to each record message (requested by Troubadour)]]--tSettings = { -- Bot Name, Mail and Description Bot = { sName = "RecordBot", sMail = "bonki@no-spam.net", sDesc = "RecordBot - LUA 5 version by jiten" }, -- RecordBot Database fRecord = "tRecord.tbl", -- true: Register Automatically, false: don't bRegister = true, -- Top Sharer and Top Share validation delay in minutes iDelay = 0, -- Ignore table tIgnore = { ["jiten"] = 1, ["yournick"] = 1, }, -- Commands sHelp = "rb.help", sShow = "rb.show", sSetup = "rb.set", sReset = "rb.reset"}Record = { -- RecordBot DB tDB = {}, -- RecordBot message settings tSetup = { -- Show report in Main main = 1, -- Show report in PM pm = 0, -- Show report on Login login = 1 },}-- Delay table (don't change this)tDelay = {}Main = function() if tSettings.bRegister then frmHub:RegBot(tSettings.Bot.sName, 1, tSettings.Bot.sDesc, tSettings.Bot.sMail) end if loadfile(tSettings.fRecord) then dofile(tSettings.fRecord) end; SetTimer(1000); StartTimer()endChatArrival = function(user, data) local data = string.sub(data,1,-2) local s,e,cmd = string.find(data, "%b<>%s+[%!%+](%S+)" ) if cmd and tCmds[cmd] then cmd = string.lower(cmd); if tCmds[cmd].tLevels[user.iProfile] then return tCmds[cmd].tFunc(user,data), 1 else return user:SendData(tSettings.Bot.sName, "*** Error: You do not have sufficient rights to run that command!"), 1; end endendOnExit = function() SaveToFile(Record,"Record",tSettings.fRecord)endtCmds = { [tSettings.sHelp] = { tFunc = function(user) local sMsg = "\r\n\t\r\n\t\t\t\t\t"..tSettings.Bot.sDesc.."\r\n\r\n\t\t\t\tLogs and displays a hub's all".. "time share and user record.\r\n\t\r\n\tAvailable Commands:".."\r\n\r\n"; for cmd, v in tCmds do if tCmds[cmd].tLevels[user.iProfile] then sMsg = sMsg.."\t!"..cmd.."\t "..v.tDesc.."\r\n"; end end user:SendData(tSettings.Bot.sName,sMsg); end, tLevels = { [-1] = 1, [0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1, }, tDesc = "\tDisplays this help message\t\t\t!"..tSettings.sHelp.."", }, [tSettings.sShow] = { tFunc = function(user) local tTable = Record.tDB if next(tTable) then local border = string.rep ("-", 100) local msg = "\r\n\t"..border.."\r\n\tRecord\t\tValue\t\tDate - Time\n\t"..border.."\r\n".. "\tShare\t\t"..(DoShareUnits(tTable.iShare) or 0).." \t\t"..(tTable.tShare or "*not available*").. "\r\n\tUsers\t\t"..(tTable.iUsers or 0).." user(s)\t\t"..(tTable.tUsers or "*not available*").. "\r\n\tTop Sharer\t"..(tTable.sMaxSharer or "*not available*").." ("..(DoShareUnits(tTable.iMaxSharer) or 0).. ")\t"..(tTable.tMaxSharer or "*not available*").."\r\n\t"..border user:SendData(tSettings.Bot.sName,msg) else user:SendData(tSettings.Bot.sName, "*** Error: No records have been saved.") end end, tLevels = { [-1] = 1, [0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1, }, tDesc = "\tShows this hub's all time share and user record\t!"..tSettings.sShow, }, [tSettings.sSetup] = { tFunc = function(user, args) local s,e,type,flag = string.find(args,"^%S+%s+%S+%s+(%S+)%s+(%S+)") if type and Record.tSetup[string.lower(type)] then local tTable = { ["enable"] = 1, ["disable"] = 0 } if flag and tTable[string.lower(flag)] then Record.tSetup[string.lower(type)] = tTable[string.lower(flag)] user:SendData(tSettings.Bot.sName, "*** Show in "..string.upper(string.sub(type,1,1)).. string.lower(string.sub(type,2,string.len(type))).." Mode has been "..flag.."d!"); end else user:SendData(tSettings.Bot.sName, "*** Syntax Error: Type !"..tSettings.sSetup.." <login/pm/main> <enable/disable>"); end end, tLevels = { [0] = 1, [5] = 1, }, tDesc = "\tSetup RecordBot\t\t\t\t!"..tSettings.sSetup.." <main/login/pm> <enable/disable>", }, [tSettings.sReset] = { tFunc = function(user) Record.tDB = {} SendToAll(tSettings.Bot.sName, "*** Hub records have been reset!"); end, tLevels = { [0] = 1, [5] = 1, }, tDesc = "\tResets all records\t\t\t\t!"..tSettings.sReset, },};NewUserConnected = function(user) if tSettings.tIgnore[user.sName] ~= 1 then local iUserCount, tTable = frmHub:GetUsersCount(), Record.tDB tTable.iUsers = tTable.iUsers or 0; tTable.tUsers = tTable.tUsers or "*not available*" if (iUserCount > tTable.iUsers) then tTable.iUsers = iUserCount; tTable.tUsers = os.date() if (Record.tSetup.pm == 1) then SendPmToNick(user.sName, "*** Thanks, buddie. You've just raised the all-time share record!"); end; if (Record.tSetup.main == 1) then SendToAll(tSettings.Bot.sName, "*** "..user.sName.." has just raised the all-time user record to: ".. tTable.iUsers.." users at "..os.date().." :)"); end; end tDelay[user] = {} tDelay[user]["iTime"] = tSettings.iDelay*60 endendOpConnected = NewUserConnectedOnTimer = function() for nick,v in tDelay do tDelay[nick]["iTime"] = tDelay[nick]["iTime"] - 1 if tDelay[nick]["iTime"] <= 0 then if GetItemByName(nick.sName) then local iTotalShare, iShare, sNick, tTable = frmHub:GetCurrentShareAmount(), nick.iShareSize, nick.sName, Record.tDB tTable.iShare = tTable.iShare or 0 if (iTotalShare > tTable.iShare) then tTable.iShare = iTotalShare; tTable.tShare = os.date() if (Record.tSetup.pm == 1) then SendPmToNick(nick.sName, tSettings.Bot.sName, "*** Thanks, buddie. You have just raised the all-time share record to "..DoShareUnits(iTotalShare).." :)"); end; if (Record.tSetup.main == 1) then SendToAll(tSettings.Bot.sName, "*** "..nick.sName.." has just raised the all-time share record to: "..DoShareUnits(iTotalShare).." on "..os.date("%x")); end; end tTable.iMaxSharer = tTable.iMaxSharer or 0 if (iShare > tTable.iMaxSharer) then tTable.iMaxSharer = iShare; tTable.sMaxSharer = nick.sName; tTable.tMaxSharer = os.date() if (Record.tSetup.pm == 1) then SendPmToNick(nick.sName, "*** Thanks, buddie. You are our highest sharer with: "..DoShareUnits(iShare).."."); end; if (Record.tSetup.main == 1) then SendToAll(tSettings.Bot.sName, "*** "..nick.sName.." is our all-time biggest sharer with: "..DoShareUnits((iShare)).." since "..os.date("%x").." :)"); end; end if (Record.tSetup.login == 1) then local sMsg = "\r\n\r\n\tShare record: "..(DoShareUnits(tonumber(tTable.iShare)) or 0).." at ".. (tTable.tShare or "*not available*").."\r\n\tUser record: "..(tTable.iUsers or 0).." users at ".. (tTable.tUsers or "*not available*").."\r\n\tTop Sharer: "..(tTable.sMaxSharer or "*not available*").. " ("..(DoShareUnits(tTable.iMaxSharer) or 0)..") at "..(tTable.tMaxSharer or "*not available*").."\r\n" nick:SendData(tSettings.Bot.sName,sMsg) end; end tDelay[nick] = nil end endend-- By kepp and NotRambitWombat DoShareUnits = function(intSize) if intSize and intSize ~= 0 then local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }; intSize = tonumber(intSize); local sUnits; for index in ipairs(tUnits) do if(intSize < 1024) then sUnits = tUnits[index]; break; else intSize = intSize / 1024; end end return string.format("%0.1f %s",intSize, sUnits); end endSerialize = function(tTable,sTableName,hFile,sTab) sTab = sTab or ""; hFile:write(sTab..sTableName.." = {\n"); for key,value in tTable do if (type(value) ~= "function") then local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key); if(type(value) == "table") then 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 end hFile:write(sTab.."}");endSaveToFile = function(table,tablename,file) local hFile = io.open(file,"w+") Serialize(table,tablename,hFile); hFile:close() end
Originally posted by TïMê†råVêlléR When reconecting i got some users it seems [20:33:55] TïMê†råVêlléR has just raised the all-time share record to: 636.5 GB[20:33:55] Share record: 636.5 GB[20:33:55] User record: 683441533803 usersgreetzz TT
Originally posted by TïMê†råVêlléR Shame lost all my users works fine now Greetzz TT
Originally posted by uffetjur had to delete config.tbl to get recordbot to show up in mainchat
Might be a bug to... dont sure chatarrival is used in the complete script,getting users refused from hub to trigger the script...
Originally posted by uffetjur i did used the updated script
Originally posted by kash© gr8 work JitenBut only one problem......that RecordBot comes b4 MOTDBecause of that all that goes up..Can it be done after MOTDwaiting reply,
if Record.Share == nil then Record.Share = 0 end
Originally posted by Optimus Code: [Select]if Record.Share == nil then Record.Share = 0 end This an others can be written asRecord.Share = Record.Share or 0- Optimus
Originally posted by chettedeboeuf ---------------------------------------------------------------------------------------------------- Record Value Date - Time ---------------------------------------------------------------------------------------------------- Share 1.5 TB 06/03/05 12:45:39 Users 40 user(s) Top Sharer --MFZ--ChEtTeDeBoEuF™ (168.9 GB) ----------------------------------------------------------------------------------------------------No date-time for top users ?jiten, do you response at private message if ...
Originally posted by (uk)jay Can you add switch to allow reg/unreg bot please :D
Originally posted by Cosmos im just testing this script.. and in a hub where nobody is sharing i get this error:[16:18] Syntax C:\0.3.3.0.b17.08.nt.dbg\scripts\record.lua:303: attempt to concatenate field `maxSharer' (a nil value)
Originally posted by chettedeboeuf Hi ,---------------------------------------------------------------------------------------------------- Record Valeur Date - Heure ---------------------------------------------------------------------------------------------------- Share 2.3 TB 06/04/05 21:24:58 Users 64 user(s) 06/04/05 21:24:58 Top Sharer [rug.nl]pinger (310.0 GB) ----------------------------------------------------------------------------------------------------Est il possible de filtrer certains utilisateurs pour eviter de fausser les records ?It is possible to filter certain users for eviter to distort the records? i.e. : Top Sharer [rug.nl]pinger (310.0 GB)He doesn't appear either on share nor on the users nor on top sharer