PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: jiten on 10 May, 2005, 15:38:22

Title: Record Bot
Post by: jiten on 10 May, 2005, 15:38:22

--[[

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()
end

ChatArrival = 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
end
end

OnExit = function()
SaveToFile(Record,"Record",tSettings.fRecord)
end

tCmds = {
[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
end
end

OpConnected = NewUserConnected

OnTimer = 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
end
end

-- 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
end

Serialize = 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.."}");
end

SaveToFile = function(table,tablename,file)
local hFile = io.open(file,"w+") Serialize(table,tablename,hFile); hFile:close()
end

Title:
Post by: dkt on 10 May, 2005, 20:08:57
nice script jiten keep it up m8 !!!
Title:
Post by: jiten on 10 May, 2005, 20:14:54
It surely needs some testing :D
Title:
Post by: TiMeTrAVelleR on 10 May, 2005, 20:37:09
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 users


greetzz   TT
Title:
Post by: jiten on 10 May, 2005, 20:59:04
QuoteOriginally 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 users


greetzz   TT
First post updated.
Please delete the old .tbl files before using this one.
Btw, that would be an all-time record :D

Cheers
Title:
Post by: TiMeTrAVelleR on 10 May, 2005, 21:07:38
Shame  lost all my users  ;)

works fine now  :)

Greetzz TT
Title:
Post by: dkt on 10 May, 2005, 21:33:54
lol ------> lost all users
Title:
Post by: jiten on 11 May, 2005, 12:51:14
QuoteOriginally posted by T?M??r?V?ll?R
Shame  lost all my users  ;)

works fine now  :)

Greetzz TT
Cool :D
Title:
Post by: uffetjur on 11 May, 2005, 14:15:17
had to delete config.tbl to get recordbot to show up in mainchat

so not so good to use recordbots cmd's for settings

running ptokax 17.05 and robocop 10.01e


Might be a bug to... dont sure chatarrival is used in the complete script,
getting users refused from hub to trigger the script...


NewUserConnected = function(curUser)

   local aShare,aUsers = frmHub:GetCurrentShareAmount(),frmHub:GetUsersCount()

   if Record.Share == nil then Record.Share = 0 end

etc etc
Title:
Post by: jiten on 11 May, 2005, 17:06:03
QuoteOriginally posted by uffetjur
had to delete config.tbl to get recordbot to show up in mainchat
Indeed, as you could see in a previous post: "First post updated. Please delete the old .tbl files before using this one."

QuoteMight be a bug to... dont sure chatarrival is used in the complete script,
getting users refused from hub to trigger the script...
Hopefully fixed.

First post updated.

Best regards.
Title:
Post by: uffetjur on 11 May, 2005, 17:14:09
i did used the updated script
Title:
Post by: jiten on 11 May, 2005, 17:21:13
QuoteOriginally posted by uffetjur
i did used the updated script
My guess was that you had the updated one but, didn't delete the .tbl files before using it.

Anyway, let's see if it that problem is solved ;)
Title:
Post by: uffetjur on 11 May, 2005, 17:53:02
Zitat:Originally posted by uffetjur
    i did used the updated script


My guess was that you had the updated one but, didn't delete the .tbl files before using it.

Anyway, let's see if it that problem is solved
______________________________________

did a clean install using the updated script,
now testing the latest update!
cheers m8
Title:
Post by: kash? on 20 May, 2005, 18:42:49
gr8 work Jiten

But only one problem......
that RecordBot comes b4 MOTD
Because of that all that goes up..
Can it be done after MOTD

waiting reply,
Title:
Post by: Dessamator on 20 May, 2005, 19:28:57
indeed, its simple to solve, jiten go go go , :),
btw it would be nice if PPK, could implement an API, that does that, :)
Title:
Post by: jiten on 20 May, 2005, 19:47:57
QuoteOriginally posted by kash?
gr8 work Jiten

But only one problem......
that RecordBot comes b4 MOTD
Because of that all that goes up..
Can it be done after MOTD

waiting reply,
Yes, it can be done. First post updated with that fix.

Cheers
Title:
Post by: kash? on 20 May, 2005, 20:32:28
thanx Jiten
working gr8
keep up good job
Title:
Post by: jiten on 03 June, 2005, 11:25:18
First post updated with Top Share and Sharer Record addition.

Cheers
Title:
Post by: chettedeboeuf on 03 June, 2005, 11:53:19
I test this script now

Thank you jiten
Title:
Post by: Optimus on 03 June, 2005, 12:22:04
if Record.Share == nil then Record.Share = 0 end This an others can be written as

Record.Share = Record.Share or 0

- Optimus
Title:
Post by: jiten on 03 June, 2005, 12:41:41
QuoteOriginally posted by Optimus
if Record.Share == nil then Record.Share = 0 end This an others can be written as

Record.Share = Record.Share or 0

- Optimus
Thanks for the tip, Optimus ;)
Going to start using that one.

Cheers
Title:
Post by: chettedeboeuf on 03 June, 2005, 13:15:02
----------------------------------------------------------------------------------------------------
   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 ...
Title:
Post by: jiten on 03 June, 2005, 17:39:04
QuoteOriginally 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 ...
First post updated with that request ;)

Cheers
Title:
Post by: Optimus on 03 June, 2005, 20:06:01
yw  8)
Title:
Post by: chettedeboeuf on 04 June, 2005, 04:22:37
Thank You Jiten
Title:
Post by: jiten on 04 June, 2005, 09:23:40
You're welcome :]
Title:
Post by: Tw?sT?d-d?v on 04 June, 2005, 13:01:49
Can you add switch to allow reg/unreg bot please :D
Title:
Post by: jiten on 04 June, 2005, 14:37:17
QuoteOriginally posted by (uk)jay
Can you add switch to allow reg/unreg bot please :D
First post updated with that request.

Cheers m8
Title:
Post by: Tw?sT?d-d?v on 04 June, 2005, 14:47:08
Cheers m8   :))
Title:
Post by: Cosmos on 04 June, 2005, 22:19:26
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)
Title:
Post by: jiten on 04 June, 2005, 22:51:39
QuoteOriginally 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)
Thanks for the report. First post updated.

Cheers
Title:
Post by: chettedeboeuf on 05 June, 2005, 01:17:35
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
Title:
Post by: jiten on 05 June, 2005, 11:26:18
QuoteOriginally 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
Yes, it's possible. I'm going to add that check to the script.

Best regards
Title:
Post by: jiten on 05 June, 2005, 12:11:25
First post updated once again.

Cheers
Title:
Post by: chettedeboeuf on 05 June, 2005, 22:57:11
Wow
Thank you jiten
Title:
Post by: jiten on 06 June, 2005, 09:26:49
You're welcome ;)
Title:
Post by: chettedeboeuf on 07 June, 2005, 17:39:26
Hi !
this script goes marvelously well
Thank you jiten

Salut !
ce script marche merveilleusement bien
Merci jiten
Title:
Post by: jiten on 07 June, 2005, 18:35:47
I'm glad to know that :]

Cheers
Title:
Post by: GrinSlaW on 12 June, 2005, 16:12:58
hello jiten
can i get a version that show the record before MOTD i use ptokax inbuild MOTD

cheers
Title:
Post by: Dessamator on 12 June, 2005, 16:45:55
QuoteOriginally posted by jiten
QuoteOriginally posted by kash?
gr8 work Jiten

But only one problem......
that RecordBot comes b4 MOTD
Because of that all that goes up..
Can it be done after MOTD

waiting reply,
Yes, it can be done. First post updated with that fix.

Cheers
Title:
Post by: jiten on 12 June, 2005, 16:50:04
QuoteOriginally posted by GrinSlaW
hello jiten
can i get a version that show the record before MOTD i use ptokax inbuild MOTD

cheers
Just to confirm, do you mean before or after?
The way it's now, it shows after.

Best regards
Title:
Post by: GrinSlaW on 12 June, 2005, 17:47:01
before MOTD  :)


cheers
Title:
Post by: jiten on 12 June, 2005, 19:15:55
QuoteOriginally posted by GrinSlaW
before MOTD  :)


cheers
Well, delete your OnTimer() function, "SetTimer(1000) StartTimer()" in Main() function and replace your NewUserConnected function with this:
NewUserConnected = function(curUser)
if mSet.tIgnore[curUser.sName] ~= 1 then
local aShare,aUsers,maxShare,maxSharer = frmHub:GetCurrentShareAmount(),frmHub:GetUsersCount(),curUser.iShareSize,curUser.sName
Record.Share = Record.Share or 0
if ( aShare > Record.Share) then
Record.Share = aShare Record.tShare = os.date() WriteTable(Record,"Record",mSet.fRecord)
if (mSet.Config.PM == 1) then SendPmToNick(curUser.sName, mSet.bot.name, sNewSharePMResponse); end;
if (mSet.Config.main == 1) then SendToAll(mSet.bot.name, curUser.sName.." has just raised the all-time share record to: "..DoShareUnits((Record.Share))); end;
end
Record.Users = Record.Users or 0
if ( aUsers > Record.Users ) then
Record.Users = aUsers Record.tUsers = os.date() WriteTable(Record,"Record",mSet.fRecord)
if (mSet.Config.PM == 1) then SendPmToNick(curUser.sName, "Thanks, buddie. You've just raised the all-time share record!"); end;
if (mSet.Config.main == 1) then SendToAll(mSet.bot.name, curUser.sName.." has just raised the all-time user record to: "..Record.Users.." users :)"); end;
end
Record.maxShare = Record.maxShare or 0
if ( maxShare > Record.maxShare ) then
Record.maxShare = maxShare Record.maxSharer = curUser.sName WriteTable(Record,"Record",mSet.fRecord)
if (mSet.Config.PM == 1) then SendPmToNick(curUser.sName, "Thanks, buddie. You are our highest sharer with: "..DoShareUnits((Record.maxShare)).."."); end;
if (mSet.Config.main == 1) then SendToAll(mSet.bot.name, curUser.sName.." is our all-time biggest sharer with: "..DoShareUnits((Record.maxShare)).." :)"); end;
end
if (mSet.Config.Login == 1) then
curUser:SendData(mSet.bot.name, "Share record: "..DoShareUnits(tonumber(Record.Share)));
curUser:SendData(mSet.bot.name, "User record: "..Record.Users.." users");
curUser:SendData(mSet.bot.name, "Top Sharer: "..(Record.maxSharer or "Not Available").." ("..DoShareUnits((Record.maxShare))..")");
end;
end
end
Best regards,

jiten
Title:
Post by: GrinSlaW on 12 June, 2005, 21:38:54
oki tnx jiten it works comes before MOTD now and it works :D


cheers
Title:
Post by: kunal on 13 July, 2005, 08:53:36
i want the date and time when the record was made
Title:
Post by: chettedeboeuf on 19 July, 2005, 21:50:29
Is it possible to validate top sharer en top share after a certain delay ?
Some users come with more than 1TB and are kicked by another script (fake share or ...) and I wan't that they appear in the top

For example 10 minutes after an entry

Thank you Jiten
Posted on: 17 July 2005, 19:21:06
Jiten,

Help me please

 :(
Title:
Post by: aL1en on 29 July, 2005, 18:35:00
can you make that profile settings for who can access the 'op commands'?
i think only masters n netfounders should do it.. maybe moderators..

 8)
Title:
Post by: chettedeboeuf on 12 September, 2005, 20:14:38
Hi !

Change this :

msg = msg.."\tUsers\t\t"..Record.Users.." user(s)\t\t"..Record.tShare.."\r\n"

With this :

msg = msg.."\tUsers\t\t"..Record.Users.." user(s)\t\t"..Record.tUsers.."\r\n"

And thank you for this bot Jiten
Title: Re: Record Bot
Post by: jiten on 28 February, 2006, 20:03:51
First post updated with the latest Record Bot version.
Title: Re: Record Bot
Post by: Troubadour on 28 February, 2006, 20:53:19
Very nice one jiten.
Could you make it so it displays with the date of record.

example:
<RecordBot> Share record: 22.4 TB set at 26/02/2006
<RecordBot> User record: 216 users 27/02/2006
<RecordBot> Top Sharer: [NL]Koromo (58.2 GB) 22/02/2006
<RecordBot> [NL]Koromo has just raised the all-time share record to: 22.4 TB at 26/02/2006
<RecordBot> [NL]Koromo is our all-time biggest sharer with: 58.2 GB since 22/02/2006 :)
<RecordBot> [OH]NLAngela2 has just raised the all-time user record to: 217 users on 28/02/2006 :)
<RecordBot> [OH]NLAngela2 has just raised the all-time share record to: 22.5 TB on 28/02/2006
<RecordBot> [OH]NLAngela2 is our all-time biggest sharer with: 110.6 GB since 28/02/2006 :)
Title: Indeed...
Post by: jiten on 01 March, 2006, 18:27:25
Quote from: Troubadour on 28 February, 2006, 20:53:19
Very nice one jiten.
Could you make it so it displays with the date of record.

example:
<RecordBot> Share record: 22.4 TB set at 26/02/2006
<RecordBot> User record: 216 users 27/02/2006
<RecordBot> Top Sharer: [NL]Koromo (58.2 GB) 22/02/2006
<RecordBot> [NL]Koromo has just raised the all-time share record to: 22.4 TB at 26/02/2006
<RecordBot> [NL]Koromo is our all-time biggest sharer with: 58.2 GB since 22/02/2006 :)
<RecordBot> [OH]NLAngela2 has just raised the all-time user record to: 217 users on 28/02/2006 :)
<RecordBot> [OH]NLAngela2 has just raised the all-time share record to: 22.5 TB on 28/02/2006
<RecordBot> [OH]NLAngela2 is our all-time biggest sharer with: 110.6 GB since 28/02/2006 :)

... I'll do that.

Best regards
Title: Re: Indeed...
Post by: Troubadour on 01 March, 2006, 19:48:18
Quote
... I'll do that.

Best regards

I do appreciate it allready m8.
Very awesome script.
Title: Re: Record Bot
Post by: jiten on 08 March, 2006, 20:03:09
First post updated with Troubadour's request.

Didn't test it much so, report your progress.

Cheers
Title: Re: Record Bot
Post by: Troubadour on 09 March, 2006, 21:19:06
Quote from: jiten on 08 March, 2006, 20:03:09
First post updated with Troubadour's request.

Didn't test it much so, report your progress.

Cheers

I'm testing it now, will report the progress here soon!
Thanks m8!
Posted on: 09 March 2006, 18:58:11
As far as i can see at the moment, it rocks!
Just as i wanted it to be.
:)
Title: Re: Record Bot
Post by: jiten on 10 March, 2006, 17:32:51
I'm glad you like it and it's bugless ;)

Best regards
Title: Re: Record Bot
Post by: Zeel on 17 September, 2006, 22:39:12
First off, let me say that I appreciate your scripts and that I liked your old RecordBot script so much I upgraded to your new one.  Next, I have been having a problem.  For some reason, the user record is messed up.  Right now, there are currently 73 users on my hub but the user record is only at 69 users?   What do I need to do to fix this?  The script reports no errors when loaded.  Thanks again!   

-Z
Title: Re: Record Bot
Post by: jiten on 18 September, 2006, 18:03:24
Quote from: Zeel on 17 September, 2006, 22:39:12
For some reason, the user record is messed up.  Right now, there are currently 73 users on my hub but the user record is only at 69 users?   What do I need to do to fix this? 

I haven't really changed much in the code for you to have such strange behaviour. However, it could be related to your settings.

Have a look at your ignore table tIgnore. My guess is that you've some entries there and they will surely affect the user record stated by the script.
Title: Re: Record Bot
Post by: Cêñoßy†ê on 18 September, 2006, 18:20:25
Quote from: Zeel on 17 September, 2006, 22:39:12
For some reason, the user record is messed up.  Right now, there are currently 73 users on my hub but the user record is only at 69 users?   What do I need to do to fix this?  The script reports no errors when loaded.  Thanks again!   

-Z

Remember that script wont count your bots.. your client shows bots as connected users allso ;)
Title: Re: Record Bot
Post by: Zeel on 18 September, 2006, 19:08:41
Ok, I think it was just because of the bots.  Thanks for your help everybody!
Title: Re: Record Bot
Post by: speedX on 20 September, 2006, 05:40:25
Hey jiten, when u had jus made this script tht time i had taken this.....but i have seen tht it has gone under many upgrades.....is it okay if i replace the previous script with this new one?? but i want my old .tbl file only......will I have to make a new .tbl file if i replace the script.....???
Posted on: 18 September 2006, 22:40:01
hope i have not confused u.......i mean to say tht i have this script much b4.....but it has now gone under so many upgrades......can i replace the existing record bot wid me wid this one?? (But i want my old .tbl file only) Is it possible??
Title: Re: Record Bot
Post by: jiten on 20 September, 2006, 15:46:53
Quote from: speedX on 18 September, 2006, 21:40:01
Hey jiten, when u had jus made this script tht time i had taken this.....but i have seen tht it has gone under many upgrades.....is it okay if i replace the previous script with this new one?? but i want my old .tbl file only......will I have to make a new .tbl file if i replace the script.....???

What version of Record Bot are you running?
Title: Re: Record Bot
Post by: speedX on 20 September, 2006, 17:28:18
Lua 5.1
here is the script....
Quote
--[[

   RecordBot 1.5a - LUA 5.1 by jiten (3/22/2006)

   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)
   - Changed: Updated to LUA 5.1

]]--

tSettings = {
   -- Bot Name, Mail and Description
   Bot = { sName = "HoPsCoTcHer", 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 = 0,
      -- Show report in PM
      pm = 0,
      -- Show report on Login
      login = 0
   },
}

-- 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()
end

ChatArrival = 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
   end
end

OnExit = function()
   SaveToFile(Record,"Record",tSettings.fRecord)
end

tCmds = {
   [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 pairs(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,
         
  • = 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,
             
  • = 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 = {
             
  • = 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 = {
             
  • = 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
       end
    end

    OpConnected = NewUserConnected

    OnTimer = function()
       for nick,v in pairs(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
       end
    end

    -- 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
    end

    Serialize = function(tTable,sTableName,hFile,sTab)
       sTab = sTab or "";
       hFile:write(sTab..sTableName.." = {\n");
       for key,value in pairs(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.."}");
    end

    SaveToFile = function(table,tablename,file)
       local hFile = io.open(file,"w+") Serialize(table,tablename,hFile); hFile:close()
    end
Title: Re: Record Bot
Post by: jiten on 21 September, 2006, 19:26:38
Can you attach your older .tbl and tell me its version?
Title: Re: Record Bot
Post by: speedX on 21 September, 2006, 20:55:41
i am using Lua 5.1

Here is the .tbl file.
Quote
Record = {
   ["tDB"] = {
      ["iShare"] = 5659333534458,
      ["tShare"] = "09/14/06 22:50:23",
      ["iMaxSharer"] = 508548633146,
      ["iUsers"] = 137,
      ["sMaxSharer"] = "ahandfullofearth",
      ["tMaxSharer"] = "08/28/06 22:21:59",
      ["tUsers"] = "09/12/06 23:11:27",
   },
   ["tSetup"] = {
      ["pm"] = 0,
      ["main"] = 0,
      ["login"] = 0,
   },
}
Title: Re: Record Bot
Post by: jiten on 22 September, 2006, 18:21:11
It shouldn't be a problem then.

You can use your older .tbl with the latest Record Bot version.
Title: Re: Record Bot
Post by: achiever on 07 November, 2006, 09:09:29
sir i used the first posted script of this available now n i m getting following error
Syntax D:\0.3.5.1.lua5.1.1\scripts\test.lua:181: attempt to call a table value
Syntax D:\0.3.5.1.lua5.1.1\scripts\test.lua:228: attempt to call a table value

plzz can u help. :(
Title: Re: Record Bot
Post by: 6Marilyn6Manson6 on 07 November, 2006, 09:29:34
--[[

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)
--
- Converted to Lua 5.1 version by 6Marilyn6Manson6   07/11/2006
]]--

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()
end

ChatArrival = 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
end
end

OnExit = function()
SaveToFile(Record,"Record",tSettings.fRecord)
end

tCmds = {
[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 ipairs(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
end
end

OpConnected = NewUserConnected

OnTimer = function()
for nick,v in ipairs(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
end
end

-- 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
end

Serialize = function(tTable,sTableName,hFile,sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n");
for key,value in ipairs(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.."}");
end

SaveToFile = function(table,tablename,file)
local hFile = io.open(file,"w+") Serialize(table,tablename,hFile); hFile:close()
end
Title: Re: Record Bot
Post by: achiever on 07 November, 2006, 16:28:54
yup  :D
thks a lot, working properly. :)

bye,

achiever
Title: Re: Record Bot
Post by: jiten on 07 November, 2006, 19:02:38
Quote from: achiever on 07 November, 2006, 09:09:29
sir i used the first posted script of this available now n i m getting following error
Syntax D:\0.3.5.1.lua5.1.1\scripts\test.lua:181: attempt to call a table value
Syntax D:\0.3.5.1.lua5.1.1\scripts\test.lua:228: attempt to call a table value

plzz can u help. :(


You're getting these errors because I haven't updated the script to LUA 5.1 yet. I'll do it as soon as possible.

Though, 6M6M6 has already done a quick conversion. Thanks for that.
Title: Re: Record Bot
Post by: 6Marilyn6Manson6 on 08 November, 2006, 08:46:56
Quote from: jiten on 07 November, 2006, 19:02:38
You're getting these errors because I haven't updated the script to LUA 5.1 yet. I'll do it as soon as possible.

Though, 6M6M6 has already done a quick conversion. Thanks for that.

No problem jiten :)
Title: RecordBot 1.6 - LUA 5.0/5.1
Post by: jiten on 08 November, 2006, 14:38:20
As requested, I've updated this script to LUA 5.1. Please check in its Finished Scripts section.

IMPORTANT: I've changed the database structure in the version, so, you must delete your existing .tbl so that the script can work properly.

If needed, I'll post a converter.
Title: Re: Record Bot
Post by: speedX on 08 November, 2006, 14:44:09
Quote from: jiten on 08 November, 2006, 14:38:20
If needed, I'll post a converter.
plzz, coz I cant delete my old one
Title: RecordBot 1.5a - 1.6 DB Converter
Post by: jiten on 09 November, 2006, 09:57:34
Here you go then:

--[[

RecordBot 1.5a to 1.6 DB Converter by jiten (11/8/2006)

Requested by: speedX

CHANGELOG:

1. Place your old tRecord.tbl under your scripts' folder;
2. Run this script and the new file "tRecord(new).tbl" will appear in the same folder;
3. Backup your old DB (just in case) and rename the new one to the default format: tRecord.tbl
4. And that's it!

]]--

-- File to convert
fConvert = "tRecord.tbl"
-- Output file
fConverted = "tRecord(new).tbl"

tConvert = {}

Main = function()
if loadfile(fConvert) then dofile(fConvert) end; tConvert = Record.tDB
local hFile = io.open(fConverted, "w+") Serialize(tConvert, "tRecord", hFile); hFile:close()
end

Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n");
for key, value in pairs(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.."}");
end