Author Topic: record bot  (Read 2192 times)

0 Members and 1 Guest are viewing this topic.

Offline ?StIfFLEr??

  • Triple Ace
  • **
  • Posts: 241
  • Karma: +17/-63
record bot
« on: 29 October, 2008, 18:47:07 »
has any converted this script by jiten
if yes plz can the link be provided
Code: [Select]
--[[

RecordBot 1.6 - LUA 5.0/5.1 by jiten (11/8/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: Chat and ToArrival structure;
- Removed: !rb.set command;
- Merged: tSettings and Record table;
- Changed: Some code bits and variables;
- Updated: To LUA 5.1 (11/8/2006)
    Yahoo:
- Added: Commands sharerecord and userrecord (by yahoo on 7th May,2007)
- Added: Right Click Menu (by yahoo on 7th May,2007)

]]--

tSettings = {

-- Bot Name
sBot = frmHub:GetHubBotName(),

-- Toggle automatically register Bot Name [true = on, false = off]
bRegister = true,

-- RecordBot DB
fRecord = "tRecord.tbl",

-- Ignore table
tIgnore = { ["jiten"] = 1, ["yournick"] = 1, },

-- Top Sharer and Top Share validation delay (minutes)
iDelay = 0,

-- Message settings [ true = on, false = off ]

-- Show report in Main
bMain = true,

-- Show report in PM
bPM = false,

-- Show report on Login
bLogin = true,

-- Commands
sHelp = "rb.help", sShow = "rb.show", sShare = "sharerecord", sSetup = "rb.set", sReset = "rb.reset", sUser = "userrecord"
}

tRecord, tDelay = {}, {}

Main = function()
if (tSettings.sBot ~= frmHub:GetHubBotName() or tSettings.bRegister) then frmHub:RegBot(tSettings.sBot) end
if loadfile(tSettings.fRecord) then dofile(tSettings.fRecord) end
SetTimer(1000); StartTimer()
end

ChatArrival = function(user, data)
-- Define vars
local _,_, to = string.find(data, "^$To:%s(%S+)%s+From:")
local _,_, msg = string.find(data, "%b<>%s(.*)|$")
-- Message sent to Bot or in Main
if (to and to == tSettings.sBot) or not to then
-- Parse command
local _,_, cmd = string.find(msg, "^%p(%S+)")
-- Exists
if cmd and tCommands[string.lower(cmd)] then
cmd, user.SendMessage = string.lower(cmd), user.SendData
-- PM
if to == tSettings.sBot then user.SendMessage = user.SendPM end
-- If user has permission
if tCommands[cmd].tLevels[user.iProfile] and tCommands[cmd].tLevels[user.iProfile] == 1 then
return tCommands[cmd].fFunction(user), 1
else
return user:SendMessage(tSettings.sBot, "*** Error: You are not allowed to use this command!"), 1
end
end
end
end

ToArrival = ChatArrival

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

tCommands = {
[tSettings.sHelp] = {
fFunction = function(user)
-- Header
local sMsg = "\r\n\r\n\t\t\t"..string.rep("=-", 55).."\r\n"..string.rep("\t", 6).."RecordBot "..frmHub:GetHubName().." "..
"\t\t\t\r\n\t\t\t"..string.rep("=-", 55).."".."\r\n"
-- Loop through table
for i,v in pairs(tCommands) do
-- If user has permission
if v.tLevels[user.iProfile] and v.tLevels[user.iProfile] == 1 then
-- Populate
sMsg = sMsg.."\t\t\t!"..i.."\t\t"..v.tDesc.."\r\n"
end
end
-- Send
user:SendMessage(tSettings.sBot, sMsg.."\t\t\t"..string.rep("-",160));
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.sShow] = {
fFunction = function(user)
if next(tRecord) then
local msg = "\r\n\r\n\t"..string.rep ("=", 50).."\r\n\tRecord\t\tValue\t\tDate - Time\n\t"..string.rep ("-", 100).."\r\n"..
"\tShare\t\t"..(DoShareUnits(tRecord.iShare) or 0).." \t\t"..(tRecord.tShare or "n/a")..
"\r\n\tUsers\t\t"..(tRecord.iUsers or 0).." user(s)\t\t"..(tRecord.tUsers or "n/a")..
"\r\n\tTop Sharer\t"..(tRecord.sMaxSharer or "n/a").." ("..(DoShareUnits(tRecord.iMaxSharer) or 0)..
")\t"..(tRecord.tMaxSharer or "n/a").."\r\n\t"..string.rep ("-", 100)
user:SendMessage(tSettings.sBot, msg)
else
user:SendMessage(tSettings.sBot, "*** 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",
},
-- ammendment #1 by Yahoo:
[tSettings.sShare] = {
fFunction = function(user)
if next(tRecord) then
local msg = "Share record is "..(DoShareUnits(tRecord.iShare) or 0).." on  ("..(tRecord.tShare or "n/a")..")\t & Top Sharer is "..(tRecord.sMaxSharer or "n/a").." "..(DoShareUnits(tRecord.iMaxSharer) or 0).." ("..(tRecord.tMaxSharer or "n/a")..")"
SendToAll(tSettings.sBot, msg)
else
SendToAll(tSettings.sBot, "*** Error: No records have been saved.")
end
end,
tLevels = {
[-1] = 1, [0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1,
},
tDesc = "Shows this hub's all time share record\t\t",
},
[tSettings.sReset] = {
fFunction = function(user)
tRecord = {}; SendToAll(tSettings.sBot, "*** Hub records have been reset!");
end,
tLevels = {
[-1] = 0, [0] = 1, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 1,
},
tDesc = "\tResets all records\t\t\t\t",
},
-- ammendment #1 by Yahoo:
[tSettings.sUser] = {
fFunction = function(user)
if next(tRecord) then
local msg = "User record is "..(tRecord.iUsers or 0).." on ("..(tRecord.tUsers or "n/a")..")"
SendToAll(tSettings.sBot, msg)
else
SendToAll(tSettings.sBot, "*** Error: No records have been saved.")
end
end,
tLevels = {
[-1] = 1, [0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1,
},
tDesc = "Shows this hub's all time user record\t\t",
},
};

NewUserConnected = function(user)
if not tSettings.tIgnore[user.sName] then
local iUserCount = frmHub:GetUsersCount()
tRecord.iUsers, tRecord.tUsers = (tRecord.iUsers or 0), (tRecord.tUsers or "n/a")
if (iUserCount > tRecord.iUsers) then
tRecord.iUsers, tRecord.tUsers = iUserCount, os.date()
if tSettings.bPM then
SendPmToNick(user.sName, "*** Thanks, buddie. You've just raised the all-time share record!");
end;
if tSettings.bMain then
SendToAll(tSettings.sBot, "*** "..user.sName.." has just raised the all-time user record to: "..
tRecord.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 = frmHub:GetCurrentShareAmount(), nick.iShareSize, nick.sName
tRecord.iShare = (tRecord.iShare or 0)
if (iTotalShare > tRecord.iShare) then
tRecord.iShare, tRecord.tShare = iTotalShare, os.date()
if tSettings.bPM then SendPmToNick(nick.sName, tSettings.sBot, "*** Thanks, buddie. You have just raised the all-time share record to "..DoShareUnits(iTotalShare).." :)"); end;
if tSettings.bMain then SendToAll(tSettings.sBot, "*** "..nick.sName.." has just raised the all-time share record to: "..DoShareUnits(iTotalShare).." on "..os.date("%x")); end;
end

tRecord.iMaxSharer = (tRecord.iMaxSharer or 0)
if (iShare > tRecord.iMaxSharer) then
tRecord.iMaxSharer, tRecord.sMaxSharer, tRecord.tMaxSharer = iShare, nick.sName, os.date()
if tSettings.bPM then SendPmToNick(nick.sName, "*** Thanks, buddie. You are our highest sharer with: "..DoShareUnits(iShare).."."); end;
if tSettings.bMain then SendToAll(tSettings.sBot, "*** "..nick.sName.." is our all-time biggest sharer with: "..DoShareUnits((iShare)).." since "..os.date("%x").." :)"); end;
end

if tSettings.bLogin then
local sMsg = "\r\n\r\n\t"..string.rep("=", 50).."\r\n\t\t\tStats\r\n\t"..
string.rep("-", 100).."\r\n\r\n\tShare record: "..(DoShareUnits(tonumber(tRecord.iShare)) or 0).." [ "..
(tRecord.tShare or "n/a").." ]\r\n\tUser record: "..(tRecord.iUsers or 0).." users [ "..
(tRecord.tUsers or "n/a").." ]\r\n\tTop Sharer: "..(tRecord.sMaxSharer or "n/a")..
" ("..(DoShareUnits(tRecord.iMaxSharer) or 0)..") [ "..(tRecord.tMaxSharer or "n/a").." ]\r\n"
nick:SendData(tSettings.sBot, sMsg)
end;
end
tDelay[nick] = nil
end
end
end

-- By kepp and NotRambitWombat
DoShareUnits = function(intSize)
if intSize and intSize ~= 0 then
local tUnits, intSize, sUnits = { "Bytes", "KB", "MB", "GB", "TB" }, tonumber(intSize)
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
-- ammendment #2 by Yahoo:
function NewUserConnected(user)
user:SendData("$UserCommand 1 3 Record Bot\\Help$<%[mynick]> +rb.help&#124;|")
user:SendData("$UserCommand 1 3 Record Bot\\Records$<%[mynick]> +rb.show&#124;|")
user:SendData("$UserCommand 1 3 Record Bot\\Sharerecord$<%[mynick]> +sharerecord&#124;|")
user:SendData("$UserCommand 1 3 Record Bot\\userrecord$<%[mynick]> +userrecord&#124;|")
if user.bOperator then
user:SendData("$UserCommand 1 3 Record Bot\\Reset Records$<%[mynick]> +rb.reset&#124;|")
end
end
OpConnected = NewUserConnected

PtokaX forum

record bot
« on: 29 October, 2008, 18:47:07 »

Offline ?StIfFLEr??

  • Triple Ace
  • **
  • Posts: 241
  • Karma: +17/-63
Re: record bot
« Reply #1 on: 02 November, 2008, 05:45:48 »
plz can some reply to this post whether it can b converted or not

Offline ?StIfFLEr??

  • Triple Ace
  • **
  • Posts: 241
  • Karma: +17/-63
Re: record bot
« Reply #2 on: 02 November, 2008, 06:04:59 »
Code: [Select]
--[[

RecordBot 1.6 - LUA 5.0/5.1 by jiten (11/8/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: Chat and ToArrival structure;
- Removed: !rb.set command;
- Merged: tSettings and Record table;
- Changed: Some code bits and variables;
- Updated: To LUA 5.1 (11/8/2006)

]]--

tSettings = {

-- Bot Name
sBot = "?GiGaByTe?",

-- Toggle automatically register Bot Name [true = on, false = off]
bRegister = true,

-- RecordBot DB
fRecord = "tRecord.tbl",

-- Ignore table
tIgnore = { ["jiten"] = 1, ["yournick"] = 1, },

-- Top Sharer and Top Share validation delay (minutes)
iDelay = 0,

-- Message settings [ true = on, false = off ]

-- Show report in Main
bMain = true,

-- Show report in PM
bPM = false,

-- Show report on Login
bLogin = true,

-- Commands
sHelp = "rb.help", sShow = "rb.show", sSetup = "rb.set", sReset = "rb.reset"

}

tRecord, tDelay = {}, {}

OnStartup = function()
if (tSettings.sBot ~= SetMan.GetString(21) or tSettings.bRegister) then Core.RegBot(tSettings.sBot,"","",true) end
if loadfile(tSettings.fRecord) then dofile(tSettings.fRecord) end

end

ChatArrival = function(user,data)
Core.GetUserAllData(user)
-- Define vars
local _,_, to = string.find(data, "^$To:%s(%S+)%s+From:")
local _,_, msg = string.find(data, "%b<>%s(.*)|$")
-- Message sent to Bot or in Main
if (to and to == tSettings.sBot) or not to then
-- Parse command
local _,_, cmd = string.find(msg, "^%p(%S+)")
-- Exists
if cmd and tCommands[string.lower(cmd)] then
cmd, user.SendMessage = string.lower(cmd), user.SendData
-- PM
if to == tSettings.sBot then user.SendMessage = user.SendPM end
-- If user has permission
if tCommands[cmd].tLevels[user.iProfile] and tCommands[cmd].tLevels[user.iProfile] == 1 then
return tCommands[cmd].fFunction(user), 1
else
return user:SendMessage(tSettings.sBot, "*** Error: You are not allowed to use this command!"), 1
end
end
end
end

ToArrival = ChatArrival

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

tCommands = {
[tSettings.sHelp] = {
fFunction = function(user)
-- Header
local sMsg = "\r\n\r\n\t\t\t"..string.rep("=", 80).."\r\n"..string.rep("\t", 6).."RecordBot - LUA 5.1 version by jiten "..
"\t\t\t\r\n\t\t\t"..string.rep("-", 160).."\r\n\t\t\tAvailable Commands:".."\r\n\r\n"
-- Loop through table
for i,v in pairs(tCommands) do
-- If user has permission
if v.tLevels[user.iProfile] and v.tLevels[user.iProfile] == 1 then
-- Populate
sMsg = sMsg.."\t\t\t!"..i.."\t\t"..v.tDesc.."\r\n"
end
end
-- Send
user:SendMessage(tSettings.sBot, sMsg.."\t\t\t"..string.rep("-",160));
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] = {
fFunction = function(user)
if next(tRecord) then
                                local msg ="\r\n\r\n\t"..string.rep ("", 50).."\r\t\t\t\?GiGaByTe ReCoRdS?\t\t\t"..
                                "\r\n\r\n\t"..string.rep ("", 50).."\r\n\tRecord\t\tValue\t\tDate - Time\n\t"..string.rep ("-", 100).."\r\n"..
"\t?ShArE?\t\t"..(DoShareUnits(tRecord.iShare) or 0).." \t\t"..(tRecord.tShare or "n/a")..
"\r\n\t?UsEr?\t\t"..(tRecord.iUsers or 0).." user(s)\t\t"..(tRecord.tUsers or "n/a")..
"\r\n\t?ToP sHaReR?\t"..(tRecord.sMaxSharer or "n/a").." ("..(DoShareUnits(tRecord.iMaxSharer) or 0)..
")\t"..(tRecord.tMaxSharer or "n/a").."\r\n\t"..string.rep ("-", 100)
user:SendMessage(tSettings.sBot, msg)
else
user:SendMessage(tSettings.sBot, "*** 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.sReset] = {
fFunction = function(user)
tRecord = {}; Core.SendToAll("<"..tSettings.sBot.."> *** Hub records have been reset!");
end,
tLevels = {
[-1] = 0, [0] = 1, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 1,
},
tDesc = "\tResets all records\t\t\t\t!"..tSettings.sReset,
},
};

UserConnected = function(user)
Core.GetUserAllData(user)
if not tSettings.tIgnore[user.sNick] then
local iUserCount = Core.GetUsersCount()
tRecord.iUsers, tRecord.tUsers = (tRecord.iUsers or 0), (tRecord.tUsers or "n/a")
if (iUserCount > tRecord.iUsers) then
tRecord.iUsers, tRecord.tUsers = iUserCount, os.date()
if tSettings.bPM then
Core.SendPmToNick(user.sNick, "*** Thanks, buddie. You've just raised the all-time share record!");
end;
if tSettings.bMain then
Core.SendToAll("<"..tSettings.sBot.."> *** "..user.sNick.." has just raised the all-time user record to: "..
tRecord.iUsers.." users at "..os.date().." :)");
end;
end
tDelay[user] = {}
tDelay[user]["iTime"] = tSettings.iDelay*60
end
end

OpConnected = UserConnected

OnTimer = function(tmr)
for nick,v in pairs(tDelay) do
tDelay[nick]["iTime"] = tDelay[nick]["iTime"] - 1
if tDelay[nick]["iTime"] <= 0 then
if GetItemByName(nick.sNick) then
local iTotalShare, iShare, sNick = Core.GetCurrentSharedSize(), nick.iShareSize, nick.sNick
tRecord.iShare = (tRecord.iShare or 0)
if (iTotalShare > tRecord.iShare) then
tRecord.iShare, tRecord.tShare = iTotalShare, os.date()
if tSettings.bPM then Core.SendPmToNick(nick.sNick, tSettings.sBot, "*** Thanks, buddie. You have just raised the all-time share record to "..DoShareUnits(iTotalShare).." :)"); end;
if tSettings.bMain then Core.SendToAll("<"..tSettings.sBot.."> *** "..nick.sNick.." has just raised the all-time share record to: "..DoShareUnits(iTotalShare).." on "..os.date("%x")); end;
end

tRecord.iMaxSharer = (tRecord.iMaxSharer or 0)
if (iShare > tRecord.iMaxSharer) then
tRecord.iMaxSharer, tRecord.sMaxSharer, tRecord.tMaxSharer = iShare, nick.sNick, os.date()
if tSettings.bPM then Core.SendPmToNick(nick.sNick, "*** Thanks, buddie. You are our highest sharer with: "..DoShareUnits(iShare).."."); end;
if tSettings.bMain then Core.SendToAll("<"..tSettings.sBot.."> *** "..nick.sNick.." is our all-time biggest sharer with: "..DoShareUnits((iShare)).." since "..os.date("%x").." :)"); end;
end

if tSettings.bLogin then
local sMsg = "\r\n\r\n\t"..string.rep("?", 75).."\r\n\t\t\tStats\r\n\t"..
string.rep("-", 100).."\r\n\r\n\t?ShArE rEcOrD?: "..(DoShareUnits(tonumber(tRecord.iShare)) or 0).." [ "..
(tRecord.tShare or "n/a").." ]\r\n\t?UsEr rEcOrD?: "..(tRecord.iUsers or 0).." users [ "..
(tRecord.tUsers or "n/a").." ]\r\n\t?ToP sHaReR?: "..(tRecord.sMaxSharer or "n/a")..
" ("..(DoShareUnits(tRecord.iMaxSharer) or 0)..") [ "..(tRecord.tMaxSharer or "n/a").." ]\r\n"
Core.SendToNick(nick.sNick,"<"..tSettings.sBot.."> ".. sMsg)
end;
end
tDelay[nick] = nil
end
end
end

-- By kepp and NotRambitWombat
DoShareUnits = function(intSize)
if intSize and intSize ~= 0 then
local tUnits, intSize, sUnits = { "Bytes", "KB", "MB", "GB", "TB" }, tonumber(intSize)
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
RegConnected = UserConnected
converted it using converter
but the problem is its just showing user records other functions are not working
« Last Edit: 02 November, 2008, 06:17:34 by ?StIfFLEr?? »

Offline speedX

  • Lord
  • ***
  • Posts: 437
  • Karma: +59/-19
Re: record bot
« Reply #3 on: 05 July, 2009, 19:31:47 »
Thanking You,

speedX

PtokaX forum

Re: record bot
« Reply #3 on: 05 July, 2009, 19:31:47 »