PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Help with scripts => Topic started by: Daywalker? on 24 March, 2008, 22:32:19

Title: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Daywalker? on 24 March, 2008, 22:32:19
--[[

09-02-2008

ReleaseBot 1.0 LUA 5.11 [API 2] made by Daywalker?

Using some code snibbets from Sir Mutor cause i like that style and it's easy going imo :)
Tnx to Plop to point me to the right table form :))
And as always CrazyGuy for listen to my mumbling about some code :P

]]


RelCfg = {
------------------------------- Main Settings -----------------------------------
-- Botname pulled from the hub or use "Custom-Name"
Bot = SetMan.GetString(21),
-- Hub Name
Hub = SetMan.GetString(0),
-- Should bot have a key? true / false
BotIsOp = true,
-- Bot description
BotDesc = "ReleaseBot",
-- Bot Email address
BotMail = "release@genre.mp3",
-- File to save Release table
RelFile = "Release.tbl",
-- File to save Request table
ReqFile = "Request.tbl",
-- File to save Other stuff to table
BuFile = "BackBone.tbl",
-- Context Menu Title
Menu = SetMan.GetString(0),
-- Context Submenu Titles
SubMenu1 = "Release",
SubMenu2 = "Request",
-- activate show today release on connect true or false
sendrelease = true,
-- send releases to main or pm  "Main/Pm"
HowToSend = "Pm",
-- Time to clean a table in days
CleanTime = 14,
------------------------------ Don't Try This At Home --------------------------
}

local minute = 60000
local hour = 60*minute
local day = 24*hour

OnStartup = function()
clean = TmrMan.AddTimer(day)
RelCfg.Tz = TimeZone()
RelCfg.Pfx = SetMan.GetString(29):sub(1,1)
RelCfg.Path = string.gsub(Core.GetPtokaXPath().."scripts/ReleaseBot/","/","\\")
RelCfg.RelFile = RelCfg.Path..RelCfg.RelFile
RelCfg.ReqFile = RelCfg.Path..RelCfg.ReqFile
RelCfg.BuFile = RelCfg.Path..RelCfg.BuFile
gc,no = nil,table.getn
if _VERSION ~= "Lua 5.1" then
return OnError("Error! This script is incompatible with ".._VERSION), true
end
if loadfile(RelCfg.RelFile) then
dofile(RelCfg.RelFile)
Core.SendToOps("<"..RelCfg.Bot.."> *** Loading Release File....|")
else
RelCfg.Rel = {}
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
end
if loadfile(RelCfg.ReqFile) then
dofile(RelCfg.ReqFile)
Core.SendToOps("<"..RelCfg.Bot.."> *** Loading Request File........|")
else
RelCfg.Req = {}
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
end
if loadfile(RelCfg.BuFile) then
dofile(RelCfg.BuFile)
Core.SendToOps("<"..RelCfg.Bot.."> *** Loading Genre File...............|")
else
RelCfg.Bu = {}
Save_File(RelCfg.BuFile,RelCfg.Bu,"RelCfg.Bu")
end
if RelCfg.Bot ~= SetMan.GetString(21) or
RelCfg.Bot == SetMan.GetString(21) and SetMan.GetBool(17) == false then
Core.RegBot(RelCfg.Bot, RelCfg.BotDesc, RelCfg.BotMail, RelCfg.BotIsOp)
end
OnError("*** ReleaseBot 1.0RC1 LUA for ".._VERSION.." by Daywalker? has been started...")
end

OnExit = function()
OnError("*** ReleaseBot 1.0RC1 LUA for ".._VERSION.." by Daywalker? has been stopped...")
end

OnError = function(msg)
Core.SendToOps("<"..RelCfg.Bot.."> "..msg.."|")
end

function UserConnected(user, data)
SendRelCmds(user)
SendReqCmds(user)
SendRel(user)
end

OpConnected = UserConnected
RegConnected = UserConnected

ChatArrival = function(user, data)
local s,e,cmd = string.find( data, "%b<> %p(%w+)")
local s,e,to = string.find(data,"^$To: (%S+) From:")
if cmd and RelCmds[cmd] then
local _,_,_,tab = RelCmds[cmd]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
if to and to == RelCfg.Bot then
Core.SendPmToNick(user.sNick,RelCfg.Bot,RelCmds[cmd](user,data).."|")
--Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..message.."|")
else
local message = RelCmds[cmd](user,data)
Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..message.."|")
end
collectgarbage("collect")
return true
end
end
if cmd and ReqCmds[cmd] then
local _,_,_,tab = ReqCmds[cmd]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
if to and to == RelCfg.Bot then
Core.SendPmToNick(user.sNick,RelCfg.Bot,ReqCmds[cmd](user,data).."|")
--Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..message.."|")
else
local message = ReqCmds[cmd](user,data)
Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..message.."|")
end
collectgarbage("collect")
return true
end
end
end
ToArrival = ChatArrival

RelCmds = {
addgen = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
if not genre  then
return "Error!, Use: "..RelCfg.Pfx..
"addgen <genre>"
else
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
return "*** The genre: >> "..v["Genre"].." << is allready added to the ReleaseBot"
end
end
if not RelCfg.Bu then
RelCfg.Bu = {["Genre"] = genre}
else
spam = {["Genre"] = genre}
table.insert(RelCfg.Bu,spam)
end
Core.SendToAll("<"..RelCfg.Bot.."> Genre: "..genre.." is added by "..user.sNick.." to the ReleaseBot|")
Save_File(RelCfg.BuFile,RelCfg.Bu,"RelCfg.Bu")
return "Genre: "..genre.." is added to the ReleaseBot|"
end
else
return "Add A Genre"," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 0,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
delgen = function(user,data)
if user then
local s,e,ID = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not ID then
return "Error!, Use: "..RelCfg.Pfx..
"delgen <ID>"
else
local x
for i,v in pairs(RelCfg.Bu) do
if string.lower(i) == string.lower(ID) then
x = i
break
end
end
if x then
RelCfg.Bu[x] = nil
Save_File(RelCfg.BuFile,RelCfg.Bu,"RelCfg.Bu")
return "ID: "..x.." is deleted from Genre list"
else
return "ID: "..ID.." is not in the Genre list"
end
end
else
return "Delete A Genre"," %[line:ID]"," %[line:ID]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 0,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
addrel = function(user,data)
if user then
local s,e,genre,release = string.find( data, "%b<> %p%w+%s(.*)%s(.*)|$")
if not release  then
return "Error!, Use: "..RelCfg.Pfx..
"addrel <genre> <release>"
else
for i,v in pairs(RelCfg.Rel) do
if v["Release"] == release then
return "*** The release: >> "..v["Release"].." << is allready added to the ReleaseBot"
end
end
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
ReleaseUpdate = {
["Genre"] = genre,
["Release"] = release,
["Name"] = user.sNick,
["Date"] = os.date(),
["Time"] = os.time(),
}
table.insert(RelCfg.Rel,ReleaseUpdate)
Core.SendToAll("<"..RelCfg.Bot.."> Release: "..release.." is added by "..user.sNick..
" to the ReleaseBot under genre: "..v["Genre"].."|")
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
return "Release: "..release.." is added to releasebot|"
else
msg = "*** The genre: >> "..genre.." << is not available yet.."
end
end
return msg
end
else
return "Add A Release"," %[line:Genre] %[line:Release]"," %[line:Genre] %[line:Release]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
delrel = function(user,data)
if user then
local s,e,ID = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not ID then
return "Error!, Use: "..RelCfg.Pfx..
"delrel <ID>"
else
local x
for i,v in pairs(RelCfg.Rel) do
if string.lower(i) == string.lower(ID) then
x = i
break
end
end
if x then
RelCfg.Rel[x] = nil
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
return "ID: "..x.." is deleted from the ReleaseBot"
else
return "ID: "..ID.." is not in the ReleaseBot"
end
end
else
return "Delete A Release"," %[line:ID]"," %[line:ID]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
gen = function(user,data)
if user then
if next(RelCfg.Bu) then
local Count = 0
local reply = "Listing Genres ...\r\n\r\n\tID. "..
"\t\tGenre\r\n\t"..string.rep("?",25).."\r\n"
for i,v in pairsByKeys(RelCfg.Bu) do
reply = reply.."\tID: "..i..
"\t\t"..v["Genre"].."\r\n"
end
return reply.."\n\t"..string.rep("?",25).."\r\n\r\n"
else
return "There are no genres atm."
end
else
return "Show Genres ","","",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
rls = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
if not genre or genre == "" then
if next(RelCfg.Rel) then
local reply = "Listing All Releases ...\r\n\r\n\tID. "..
"\tGenre\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
reply = reply.."\tID: "..i.."\t"..v["Genre"].."\t"..v["Release"]..
" // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
else
return "There are no releases atm."
end
else
local reply = "Listing Releases by Genre...\r\n\r\n\tID. "..
"\t\tGenre\t\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Genre"] == genre then
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Release"]..
" // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
end
else
return "Show releases (genre) "," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
today = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
local od,pos,datesplit = string.find(os.date(), "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if not genre or genre == "" then
if next(RelCfg.Rel) then
local reply = "Listing All Releases of today ...\r\n\r\n\tID. "..
"\tGenre\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Date"] then
tb,pos,splittabledate = string.find(v["Date"], "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if splittabledate == datesplit then
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Release"]..
" // Added by "..v["Name"].." at "..v["Date"].."\r\n"
else
x=1
end
end
end
if x then
--nice empty space to fool the bot^^
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
else
return "There are no releases for today atm."
end
else
local reply = "Listing Today's Releases by Genre...\r\n\r\n\tID. "..
"\tGenre\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Genre"] == genre then
if v["Date"] then
tb,pos,splittabledate = string.find(v["Date"], "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if splittabledate == datesplit then
reply = reply.."\tID: "..i.."\t"..v["Genre"].."\t"..v["Release"]..
" // Added by "..v["Name"].." at "..v["Date"].."\r\n"
else
x=1
end
end
end
end
if x then
--nice empty space to fool the bot^^
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
end
else
return "Show releases of today (genre) "," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
rlshelp = function(user,data)
if user then
local x
local reply = "\r\n\r\n\tRelease Command Help\r\n\r\n\tCommand\t\tDescription\r\n"..
"\t"..string.rep("?",40).."\r\n"
for i,v in pairsByKeys(RelCmds) do
local desc,args,_,tab = RelCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
reply = reply.."\t!"..string.format("%-15s",i).."\t"..desc.."\r\n"
end
end
if x then
return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
else
return "Sorry "..user.sNick.." These commands are disabled for your profile."
end
else
return "Show Release Help","","",
-- Adjust To Your Profiles
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
about = function(user,data)
local reply = "\n\n\tAbout this script..\n"..
"\t"..string.rep("?",40).."\r\n"
if user then
x=1
if x then
reply = reply.."\t09-02-2008\n"..
"\n\tReleaseBot 1.0 RC1 LUA 5.11 [API 2] made by Daywalker?\n"..
"\n\tUsing some code snibbets from Sir Mutor cause i like that style and it's easy going imo :)\n"..
"\tTnx to Plop to point me to the right table form :))\n"..
"\tAnd as always CrazyGuy for listen to my mumbling about some code :P\n"..
"\n\tThis Script Release Candidate was Finished at 03/22/08 14:14:31 +1 UTC\n"..
"\n\tExact Date and Time for now is: "..os.date().." "..RelCfg.Tz.."\n"
end
return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
else
return "Show about this script","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
}

ReqCmds = {
addreq = function(user,data)
if user then
local s,e,genre,request = string.find( data, "%b<> %p%w+%s(.*)%s(.*)|$")
if not request  then
return "Error!, Use: "..RelCfg.Pfx..
"addreq <genre> <request>"
else
for i,v in pairs(RelCfg.Req) do
if v["Request"] == request then
return "*** The request: >> "..v["Request"].." << is allready added to the RequestBot"
end
end
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
RequestUpdate = {
["Genre"] = genre,
["Request"] = request,
["Name"] = user.sNick,
["Date"] = os.date(),
["Time"] = os.time(),
}
table.insert(RelCfg.Rel,RequestUpdate)
Core.SendToAll("<"..RelCfg.Bot.."> Request: "..request.." is added by "..user.sNick..
" to the RequestBot under genre: "..v["Genre"].."|")
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
return "Done!!"
else
msg = "*** The genre: >> "..genre.." << is not available yet.."
end
end
return msg
end
else
return "Add A Request"," %[line:Genre] %[line:Request]"," %[line:Genre] %[line:Request]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
delreq = function(user,data)
if user then
local s,e,ID = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not ID then
return "Error!, Use: "..RelCfg.Pfx..
"delrel <ID>"
else
local x
for i,v in pairs(RelCfg.Req) do
if string.lower(i) == string.lower(ID) then
x = i
break
end
end
if x then
RelCfg.Req[x] = nil
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
return "ID: "..x.." is deleted from the RequestBot"
else
return "ID: "..ID.." is not in the RequestBot"
end
end
else
return "Delete A Request"," %[line:ID]"," %[line:ID]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
req = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
if not genre or genre == "" then
if next(RelCfg.Req) then
local reply = "Listing All Requests ...\r\n\r\n\tID. "..
"\t\tGenre\t\tRequest\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Req) do
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Request"]..
" // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
else
return "There are no requests atm."
end
else
local reply = "Listing Requests by Genre...\r\n\r\n\tID. "..
"\t\tGenre\t\tRequest\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Req) do
if v["Genre"] == genre then
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Request"]..
" // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
end
else
return "Show requests (genre) "," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
reqhelp = function(user,data)
if user then
local x
local reply = "\r\n\r\n\tRequest Command Help\r\n\r\n\tCommand\t\tDescription\r\n"..
"\t"..string.rep("?",40).."\r\n"
for i,v in pairsByKeys(ReqCmds) do
local desc,args,_,tab = ReqCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
reply = reply.."\t!"..string.format("%-15s",i).."\t"..desc.."\r\n"
end
end
if x then
return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
else
return "Sorry "..user.sNick.." These commands are disabled for your profile."
end
else
return "Show Request Help","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
about = function(user,data)
local reply = "\n\n\tAbout this script..\n"..
"\t"..string.rep("?",40).."\r\n"
if user then
x=1
if x then
reply = reply.."\t09-02-2008\n"..
"\n\tReleaseBot 1.0 RC1 LUA 5.11 [API 2] made by Daywalker?\n"..
"\n\tUsing some code snibbets from Sir Mutor cause i like that style and it's easy going imo :)\n"..
"\tTnx to Plop to point me to the right table form :))\n"..
"\tAnd as always CrazyGuy for listen to my mumbling about some code :P\n"..
"\n\tThis Script Release Candidate was Finished at 03/22/08 14:14:31 UTC + 1\n"..
"\tExact Date and Time for now is: "..os.date().."\n"
end
return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
else
return "Show about this script","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
}

SendRelCmds = function(user)
local x
for i,v in pairsByKeys(RelCmds) do
local desc,arg1,arg2,tab = RelCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
Core.SendToNick(user.sNick,"$UserCommand 1 1 "..RelCfg.Menu.."\\"..RelCfg.SubMenu1.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
Core.SendToNick(user.sNick,"$UserCommand 1 2 "..RelCfg.Menu.."\\"..RelCfg.SubMenu1.."\\"..
desc.."$$To: "..RelCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
end
end
if x then
local Prof
if user.iProfile ~= -1 then
Prof = ProfMan.GetProfile(user.iProfile).sProfileName
else
Prof = "Unregistered User"
end
end
collectgarbage("collect")
end

SendReqCmds = function(user)
local x
for i,v in pairsByKeys(ReqCmds) do
local desc,arg1,arg2,tab = ReqCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
Core.SendToNick(user.sNick,"$UserCommand 1 1 "..RelCfg.Menu.."\\"..RelCfg.SubMenu2.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
Core.SendToNick(user.sNick,"$UserCommand 1 2 "..RelCfg.Menu.."\\"..RelCfg.SubMenu2.."\\"..
desc.."$$To: "..RelCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
end
end
if x then
local Prof
if user.iProfile ~= -1 then
Prof = ProfMan.GetProfile(user.iProfile).sProfileName
else
Prof = "Unregistered User"
end
end
collectgarbage("collect")
end

SendRel = function(user)
if RelCfg.sendrelease == true then
if user then
local od,pos,datesplit = string.find(os.date(), "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
local reply = "Listing All Today Releases ...\r\n\r\n\tID. "..
"\tGenre\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Date"] then
tb,pos,splittabledate = string.find(v["Date"], "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if splittabledate == datesplit then
reply = reply.."\tID: "..i.."\t"..v["Genre"].."\t"..v["Release"]..
" // Added by "..v["Name"].." at "..v["Date"].."\r\n"
else
x=1
end
end
end
if x then
--nice empty space to fool the bot^^
end
if RelCfg.HowToSend == "Main" then
Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..reply.."\n\t"..string.rep("?",100).."\r\n\r\n")
else
Core.SendPmToNick(user.sNick,RelCfg.Bot,reply.."\n\t"..string.rep("?",100).."\r\n\r\n")
end
end
else

end
end

OnTimer = function(clean)
if clean then
local cur,chg = os.time()
Core.SendToAll("<"..RelCfg.Bot.."> Release cleaner started at "..os.date())
for i,v in pairs(RelCfg.Rel) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (RelCfg.CleanTime-what)
if what > RelCfg.CleanTime then
--message
Core.SendToAll("<"..RelCfg.Bot.."> Release: "..v["Release"].." is deleted from the releasebot")
table.remove(i)
RelCfg.Rel[i] = nil
chg = true
end
end
Core.SendToAll("<"..RelCfg.Bot.."> Request cleaner started at "..os.date())
local cur2,chg2 = os.time()
for i,v in pairs(RelCfg.Req) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (RelCfg.CleanTime-what)
if what > RelCfg.CleanTime then
--message
Core.SendToAll("<"..RelCfg.Bot.."> Request: "..v["Request"].." is deleted from the requestbot")
table.remove(i)
RelCfg.Req[i] = nil
chg2 = true
end
end
if chg then
Save_File(RelCfg.RelFile,RelCfg.Rel,"BlCfg.Rel")
else
Core.SendToAll("<"..RelCfg.Bot.."> There are no Releases to delete yet, maybe next time..")
end
if chg2 then
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
else
Core.SendToAll("<"..RelCfg.Bot.."> There are no Requests to delete yet, maybe next time..")
end
end
end

CountPairs = function(Table)
local x = 0
if Table then
for i,v in pairs(Table) do
x = x + 1
end
end
return x
end

TimeZone = function()
local h,m = math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
return string.format("%+d UTC",(h + (60 * m)))
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Save_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
hFile:write( sTab.."}")
end

Save_File = function(file,table, tablename )
local hFile = io.open (file , "wb")
Save_Serialize(table, tablename, hFile)
hFile:flush()
hFile:close()
collectgarbage("collect")
end

pairsByKeys = function(t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0      -- iterator variable
local iter = function ()   -- iterator function
i = i + 1
if a[i] == nil then
return nil
else
return a[i], t[a[i]]
end
end
return iter
end


i hope you enjoy :)

// edit * changed a minor thingy in cleaner text "Nicks" into "Requests" ^^
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: baba.runner on 24 March, 2008, 23:24:44
Hi Daywalker

You certainly made a good job.
But i want to point to a problem users will have with your script. I'm not a scripter, but I made already my experience with one setting as it is also made in your script. Again you certainly made a good job.

In your first lines:
RelCfg = {
------------------------------- Main Settings -----------------------------------
-- Botname pulled from the hub or use "Custom-Name"
Bot = SetMan.GetString(21),
-- Hub Name
Hub = SetMan.GetString(0),
-- Should bot have a key? true / false


you use SetMan. and users will get an error.  something like "attempt to index global 'SetMan' (a nil value)"
And it is something PPK point me to too.
follow this link for his remark to my question -> http://board.ptokax.ath.cx/index.php?topic=7662.msg72616#msg72616

I do not want to offend you. It is just that I see that more and more scripts come out with that error. And I personally find it nasty to have to restart the script once I launched the hub.

Kind Regards.
baba.runner
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Daywalker? on 24 March, 2008, 23:40:31
if i'm correct this error shows up on one occasion..

1] when the hub is not started yet and you want to start the script allready..

ex. [23:33] Syntax relreq2.lua:17: attempt to index global 'SetMan' (a nil value)

so start it after you started the hub then the problem will be solved :)

// edit while i was typing Mutor explained it and i could not done it better if you look above :P
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: BrotherBear on 25 March, 2008, 17:50:34
Hi!

Got to try this script :)

I get this error when I am starting the Script:

[17:42] Syntax Rel-Req-Bot.lua:697: attempt to index local 'hFile' (a nil value)

I am Running Ptokax 0.4.0.0b

Regards,

BrotherBear
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: BrotherBear on 25 March, 2008, 18:08:41
Hi Dear BrotherBear :)

You have to Create a Folder named ReleaseBot under Scripts folder.

Then Restart the Script.

Regards,

BrotherBear

P.S Thanks Snooze ;)  D.S
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Daywalker? on 05 April, 2008, 23:08:12
Updated Script To RC2

--[[

09-02-2008

ReleaseBot 1.0 LUA 5.11 [API 2] made by Daywalker

Using some code snibbets from Sir Mutor cause i like that style and it's easy going imo :)
Tnx to Plop to point me to the right table form :))
And as always CrazyGuy for listen to my mumbling about some code :P

- RC2:
* Added the !findrel command (finds all the Releases including the word you searched for)
* Added the !prunerel and !prunereq commands to maually prune the tabled by day
* Fixed the TableCleaner cause it didn't work properly
* Fixed the start script error when hub is not running
* Fixed or Added (that's how you look against it^^) the hFile error when Folder isn't there yet...
script will search for Folder first and will create it first now.
* Added version number for script

]]


RelCfg = {
------------------------------- Main Settings -----------------------------------
-- Botname if "" then it will be pulled from the hub or use "Custom-Name"
Bot = "",
-- Hub Name if "" then it will be set to hubname
Hub = "",
-- Should bot have a key? true / false
BotIsOp = true,
-- Bot description
BotDesc = "ReleaseBot",
-- Bot Email address
BotMail = "release@genre.mp3",
-- Script version
Version = "1.0RC2",
-- folder for DB
Folder = "ReleaseBot",
-- File to save Release table
RelFile = "Release.tbl",
-- File to save Request table
ReqFile = "Request.tbl",
-- File to save Other stuff to table
BuFile = "BackBone.tbl",
-- Context Menu Title if "" then it will be set to hubname
Menu = "",
-- Context Submenu Titles
SubMenu1 = "Release",
SubMenu2 = "Request",
-- activate show today release on connect true or false
sendrelease = true,
-- send releases to main or pm  "Main/Pm"
HowToSend = "Pm",
-- Time to clean a table in days
CleanTime = 8,
-- Time to do the cleaning repeatly [ 24*(60*60000)  =  1 day]
DoClean = 24*(60*60000),
------------------------------ Don't Try This At Home --------------------------
}



OnStartup = function()
if RelCfg.Bot == "" then RelCfg.Bot = SetMan.GetString(21) end
if RelCfg.Menu == "" then RelCfg.Menu = SetMan.GetString(0) end
if RelCfg.Hub == "" then RelCfg.Hub = SetMan.GetString(0) end
clean = TmrMan.AddTimer(RelCfg.DoClean)
RelCfg.Tz = TimeZone()
RelCfg.Pfx = SetMan.GetString(29):sub(1,1)
RelCfg.Path = string.gsub(Core.GetPtokaXPath().."scripts/"..RelCfg.Folder.."/","/","\\")
RelCfg.RelFile = RelCfg.Path..RelCfg.RelFile
RelCfg.ReqFile = RelCfg.Path..RelCfg.ReqFile
RelCfg.BuFile = RelCfg.Path..RelCfg.BuFile
gc,no = nil,table.getn
if _VERSION ~= "Lua 5.1" then
return OnError("Error! This script is incompatible with ".._VERSION), true
end
if loadfile(RelCfg.RelFile) then
dofile(RelCfg.RelFile)
Core.SendToOps("<"..RelCfg.Bot.."> *** Loading Release File....|")
else
os.execute("mkdir "..RelCfg.Folder)
Core.SendToOps("<"..RelCfg.Bot.."> *** Scanning script folder.."..RelCfg.Folder.." not found, Creating "..RelCfg.Folder.." now....|")
RelCfg.Rel = {}
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
Core.SendToOps("<"..RelCfg.Bot.."> *** The folder "..RelCfg.Folder.." is created..inserting files now..|")
Core.SendToOps("<"..RelCfg.Bot.."> *** "..RelCfg.RelFile.." file inserted..|")
end
if loadfile(RelCfg.ReqFile) then
dofile(RelCfg.ReqFile)
Core.SendToOps("<"..RelCfg.Bot.."> *** Loading Request File........|")
else
RelCfg.Req = {}
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
Core.SendToOps("<"..RelCfg.Bot.."> *** "..RelCfg.ReqFile.." file inserted..|")
end
if loadfile(RelCfg.BuFile) then
dofile(RelCfg.BuFile)
Core.SendToOps("<"..RelCfg.Bot.."> *** Loading Genre File...............|")
else
RelCfg.Bu = {}
Save_File(RelCfg.BuFile,RelCfg.Bu,"RelCfg.Bu")
Core.SendToOps("<"..RelCfg.Bot.."> *** "..RelCfg.BuFile.." file inserted..|")
end
if RelCfg.Bot ~= SetMan.GetString(21) or
RelCfg.Bot == SetMan.GetString(21) and SetMan.GetBool(17) == false then
Core.RegBot(RelCfg.Bot, RelCfg.BotDesc, RelCfg.BotMail, RelCfg.BotIsOp)
end
OnError("*** ReleaseBot "..RelCfg.Version.." for ".._VERSION.." by Daywalker? has been started...")
end

OnExit = function()
OnError("*** ReleaseBot "..RelCfg.Version.." for ".._VERSION.." by Daywalker? has been stopped...")
end

OnError = function(msg)
Core.SendToOps("<"..RelCfg.Bot.."> "..msg.."|")
end

function UserConnected(user, data)
SendRelCmds(user)
SendReqCmds(user)
SendRel(user)
end

OpConnected = UserConnected
RegConnected = UserConnected

ChatArrival = function(user, data)
local s,e,cmd = string.find( data, "%b<> %p(%w+)")
local s,e,to = string.find(data,"^$To: (%S+) From:")
if cmd and RelCmds[cmd] then
local _,_,_,tab = RelCmds[cmd]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
if to and to == RelCfg.Bot then
Core.SendPmToNick(user.sNick,RelCfg.Bot,RelCmds[cmd](user,data).."|")
else
local message = RelCmds[cmd](user,data)
Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..message.."|")
end
collectgarbage("collect")
return true
end
end
if cmd and ReqCmds[cmd] then
local _,_,_,tab = ReqCmds[cmd]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
if to and to == RelCfg.Bot then
Core.SendPmToNick(user.sNick,RelCfg.Bot,ReqCmds[cmd](user,data).."|")
else
local message = ReqCmds[cmd](user,data)
Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..message.."|")
end
collectgarbage("collect")
return true
end
end
end
ToArrival = ChatArrival

RelCmds = {
addgen = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
if not genre  then
return "Error!, Use: "..RelCfg.Pfx..
"addgen <genre>"
else
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
return "*** The genre: >> "..v["Genre"].." << is allready added to the ReleaseBot"
end
end
if not RelCfg.Bu then
RelCfg.Bu = {["Genre"] = genre}
else
spam = {["Genre"] = genre}
table.insert(RelCfg.Bu,spam)
end
Core.SendToAll("<"..RelCfg.Bot.."> Genre: "..genre.." is added by "..user.sNick.." to the ReleaseBot|")
Save_File(RelCfg.BuFile,RelCfg.Bu,"RelCfg.Bu")
return "Genre: "..genre.." is added to the ReleaseBot|"
end
else
return "Add A Genre"," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 0,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
delgen = function(user,data)
if user then
local s,e,ID = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not ID then
return "Error!, Use: "..RelCfg.Pfx..
"delgen <ID>"
else
local x
for i,v in pairs(RelCfg.Bu) do
if string.lower(i) == string.lower(ID) then
x = i
break
end
end
if x then
RelCfg.Bu[x] = nil
Save_File(RelCfg.BuFile,RelCfg.Bu,"RelCfg.Bu")
return "ID: "..x.." is deleted from Genre list"
else
return "ID: "..ID.." is not in the Genre list"
end
end
else
return "Delete A Genre"," %[line:ID]"," %[line:ID]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 0,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
addrel = function(user,data)
if user then
local s,e,genre,release = string.find( data, "%b<> %p%w+%s(.*)%s(.*)|$")
if not release  then
return "Error!, Use: "..RelCfg.Pfx..
"addrel <genre> <release>"
else
for i,v in pairs(RelCfg.Rel) do
if v["Release"] == release then
return "*** The release: >> "..v["Release"].." << is allready added to the ReleaseBot"
end
end
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
ReleaseUpdate = {["Genre"] = genre,["Release"] = release,["Name"] = user.sNick,["Date"] = os.date(),["Time"] = os.time(),}
table.insert(RelCfg.Rel,ReleaseUpdate)
Core.SendToAll("<"..RelCfg.Bot.."> Release: "..release.." is added by "..user.sNick.." to the ReleaseBot under genre: "..v["Genre"].."|")
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
return "Release: "..release.." is added to releasebot|"
else
msg = "*** The genre: >> "..genre.." << is not available yet.."
end
end
return msg
end
else
return "Add A Release"," %[line:Genre] %[line:Release]"," %[line:Genre] %[line:Release]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
delrel = function(user,data)
if user then
local s,e,ID = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not ID then
return "Error!, Use: "..RelCfg.Pfx..
"delrel <ID>"
else
local x
for i,v in pairs(RelCfg.Rel) do
if string.lower(i) == string.lower(ID) then
x = i
break
end
end
if x then
RelCfg.Rel[x] = nil
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
return "ID: "..x.." is deleted from the ReleaseBot"
else
return "ID: "..ID.." is not in the ReleaseBot"
end
end
else
return "Delete A Release"," %[line:ID]"," %[line:ID]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
prunerel = function(user,data)
if user then
local s,e,prune = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not prune  then
return "Error!, Use: "..RelCfg.Pfx..
"prunerel <days>"
else
local cur,chg = os.time()
local msg = "\n\t"..string.rep("=",130)..
"\n\t\t\t\t\t- Listing Deleted Releases Older Then "..prune.." Days-"..
"\n\t"..string.rep("-",260).."\n"
for i,v in pairs(RelCfg.Rel) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (tonumber(prune)-what)
if what > tonumber(prune) then
--message
msg = msg.."\tRelease: "..v["Release"].." is deleted from the releasebot\n"
table.remove(RelCfg.Rel[i])
RelCfg.Rel[i] = nil
chg = true
end
end
if chg then
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
Core.SendToAll("<"..RelCfg.Bot.."> "..user.sNick.." Deleted All Releases Older then "..prune.." Days")
return msg.."\n\t"..string.rep("?",130).."\r\n\r\n"
end
return "There Are No Releases To Delete Yet!!\n"
end
else
return "Clean release table"," %[line:Days to prune]"," %[line:Days to prune]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
prunereq = function(user,data)
if user then
local s,e,prune = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not prune  then
return "Error!, Use: "..RelCfg.Pfx..
"prunereq <days>"
else
local cur,chg = os.time()
local msg = "\n\t"..string.rep("=",130)..
"\n\t\t\t\t\t- Listing Deleted Requests Older Then "..prune.." Days-"..
"\n\t"..string.rep("-",260).."\n"
for i,v in pairs(RelCfg.Req) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (tonumber(prune)-what)
if what > tonumber(prune) then
--message
msg = msg.."\tRequest: "..v["Request"].." is deleted from the releasebot\n"
table.remove(RelCfg.Req[i])
RelCfg.Req[i] = nil
chg = true
end
end
if chg then
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
Core.SendToAll("<"..RelCfg.Bot.."> "..user.sNick.." Deleted All Requests Older then "..prune.." Days")
return msg.."\n\t"..string.rep("?",130).."\r\n\r\n"
end
return "*** There Are No Requests To Delete Yet!!\n"
end
else
return "Clean request table"," %[line:Days to prune]"," %[line:Days to prune]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
gen = function(user,data)
if user then
if next(RelCfg.Bu) then
local Count = 0
local reply = "\n\t\t"..string.rep("=",30)..
"\n\t\t\t- Listing Genres -"..
"\n\t\t"..string.rep("-",60).."\n"..
"\n\t\tID.\t\tGenre\n\t\t"..string.rep("?",30).."\r\n"
for i,v in pairsByKeys(RelCfg.Bu) do
reply = reply.."\t\tID: "..i..
"\t\t"..v["Genre"].."\r\n"
end
return reply.."\n\t\t"..string.rep("?",30).."\r\n\r\n"
else
return "There are no genres atm."
end
else
return "Show Genres ","","",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
rls = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
if not genre or genre == "" then
if next(RelCfg.Rel) then
local reply = "\n\t"..string.rep("=",100)..
"\n\t\t\t\t\t- Listing All Releases -"..
"\n\t"..string.rep("-",200).."\n"..
"\n\tID\t\tGenre\t\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
reply = reply.."\tID: "..i.."\t"..v["Genre"].."\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
else
return "There are no releases atm."
end
else
local reply = "Listing Releases by Genre...\r\n\r\n\tID. "..
"\t\tGenre\t\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Genre"] == genre then
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
end
else
return "Show releases (genre) "," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
today = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
local od,pos,datesplit = string.find(os.date(), "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if not genre or genre == "" then
if next(RelCfg.Rel) then
local reply = "\n\t"..string.rep("=",100)..
"\n\t\t\t\t\t- Listing All Releases of today -"..
"\n\t"..string.rep("-",200).."\n"..
"\n\tID\t\tGenre\t\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Date"] then
tb,pos,splittabledate = string.find(v["Date"], "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if splittabledate == datesplit then
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
else
x=1
end
end
end
if x then
--nice empty space to fool the bot^^
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
else
return "There are no releases for today atm."
end
else
local reply = "Listing Today's Releases by Genre...\r\n\r\n\tID. "..
"\tGenre\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Genre"] == genre then
if v["Date"] then
tb,pos,splittabledate = string.find(v["Date"], "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if splittabledate == datesplit then
reply = reply.."\tID: "..i.."\t"..v["Genre"].."\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
else
x=1
end
end
end
end
if x then
--nice empty space to fool the bot^^
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
end
else
return "Show releases of today (genre) "," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
findrel = function(user,data)
if user then
local s,e,rel = string.find( data, "%b<> %p%w+%s(.*)|$")
if not rel then
return "Error!, Use: "..RelCfg.Pfx..
"findrel <releasename or a word init>"
else
local msg = "\n\t\t"..string.rep("=",80)..
"\n\t\t\t\t\t- Search Results for the word ["..rel.."] -"..
"\n\t\t"..string.rep("-",160).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
--if string.lower(v["Release"]) == string.lower(rel) then
if string.find(string.lower(v["Release"]),rel) then
msg = msg.."\r\n\r\n\t\tInfo on the Release: "..v["Release"].." :\n"..
"\r\n\t\t"..string.rep("?",80)..
"\r\n\t\t- Known ID\t\t: "..i..
"\r\n\t\t- Full Releasename\t: "..v["Release"]..
"\r\n\t\t- Genre\t\t: "..v["Genre"]..
"\r\n\t\t- Added by\t: "..v["Name"]..
"\r\n\t\t- Time of Add\t: "..v["Date"]..
"\r\n\r\n\t\t"..string.rep("?",80).."\r\n"
else
x=1
end
end
if x then
return msg.."\n\t\t"..string.rep("-",160).."\r\n\r\n"
else
return "The Release: <"..rel.."> is not found."
end
end
else
return "Find A Release"," %[line:Release]"," %[line:Release]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
DownloadFile()
end,
rlshelp = function(user,data)
if user then
local x
local reply = "\n\t\t"..string.rep("=",40)..
  "\n\t\t\t- Release Command Help-"..
  "\n\t\t"..string.rep("-",80)..
  "\n\t\tCommand\t\tDescription\r\n"..
  "\t\t"..string.rep("?",40).."\r\n"
for i,v in pairsByKeys(RelCmds) do
local desc,args,_,tab = RelCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
reply = reply.."\t\t!"..string.format("%-15s",i).."\t"..desc.."\r\n"
end
end
if x then
return reply.."\n\t\t"..string.rep("?",40).."\r\n\r\n"
else
return "Sorry "..user.sNick.." These commands are disabled for your profile."
end
else
return "Show Release Help","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
relabout = function(user,data)
local reply = "\n\t\t"..string.rep("=",60)..
  "\n\n\t\t\t\t\t-About this script-"..
  "\n\t\t"..string.rep("-",120).."\n"
if user then
x=1
local FileSize1 = CheckFile(RelCfg.BuFile)
local FileSize2 = CheckFile(RelCfg.RelFile)
local FileSize3 = CheckFile(RelCfg.ReqFile)
if x then
reply = reply.."\t\t09-02-2008\n"..
"\n\t\tReleaseBot "..RelCfg.Version.." ".._VERSION.." [API 2] made by Daywalker?\n"..
"\n\t\tUsing some code snibbets from Sir Mutor cause i like that style and it's easy going imo :)\n"..
"\t\tTnx to Plop to point me to the right table form :))\n"..
"\t\tAnd as always CrazyGuy for listen to my mumbling about some code :P\n"..
"\n\t\tThis Script Release Candidate was Finished at 04/05/08 16:44:24 +1 UTC"..
"\n\t\tExact Date and Time for now is: "..os.date().." "..RelCfg.Tz..
"\n\t\tScript uses "..Mem().." atm."..
"\n\n\t\tCurrent File Sizes are for:"..
"\n\t\t"..string.rep("~",25)..
"\n\t\t- Genre file\t: "..FileSize1..
"\n\t\t- Release file\t: "..FileSize2..
"\n\t\t- Request file\t: "..FileSize3..
"\n\t\t"..string.rep("~",25).."\n"
end
return reply.."\n\t\t"..string.rep("?",60).."\r\n\r\n"
else
return "Show about this script","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
}

ReqCmds = {
addreq = function(user,data)
if user then
local s,e,genre,request = string.find( data, "%b<> %p%w+%s(.*)%s(.*)|$")
if not request  then
return "Error!, Use: "..RelCfg.Pfx..
"addreq <genre> <request>"
else
for i,v in pairs(RelCfg.Req) do
if v["Request"] == request then
return "*** The request: >> "..v["Request"].." << is allready added to the RequestBot"
end
end
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
RequestUpdate = {["Genre"] = genre,["Request"] = request,["Name"] = user.sNick,["Date"] = os.date(),["Time"] = os.time(),}
table.insert(RelCfg.Rel,RequestUpdate)
Core.SendToAll("<"..RelCfg.Bot.."> Request: "..request.." is added by "..user.sNick.." to the RequestBot under genre: "..v["Genre"].."|")
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
return "Done!!"
else
msg = "*** The genre: >> "..genre.." << is not available yet.."
end
end
return msg
end
else
return "Add A Request"," %[line:Genre] %[line:Request]"," %[line:Genre] %[line:Request]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
delreq = function(user,data)
if user then
local s,e,ID = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not ID then
return "Error!, Use: "..RelCfg.Pfx..
"delrel <ID>"
else
local x
for i,v in pairs(RelCfg.Req) do
if string.lower(i) == string.lower(ID) then
x = i
break
end
end
if x then
RelCfg.Req[x] = nil
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
return "ID: "..x.." is deleted from the RequestBot"
else
return "ID: "..ID.." is not in the RequestBot"
end
end
else
return "Delete A Request"," %[line:ID]"," %[line:ID]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
req = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
if not genre or genre == "" then
if next(RelCfg.Req) then
local reply = "Listing All Requests ...\r\n\r\n\tID. "..
"\t\tGenre\t\tRequest\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Req) do
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Request"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
else
return "There are no requests atm."
end
else
local reply = "Listing Requests by Genre...\r\n\r\n\tID. "..
"\t\tGenre\t\tRequest\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Req) do
if v["Genre"] == genre then
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Request"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
end
else
return "Show requests (genre) "," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
reqhelp = function(user,data)
if user then
local x
local reply = "\r\n\r\n\tRequest Command Help\r\n\r\n\tCommand\t\tDescription\r\n"..
"\t"..string.rep("?",40).."\r\n"
for i,v in pairsByKeys(ReqCmds) do
local desc,args,_,tab = ReqCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
reply = reply.."\t!"..string.format("%-15s",i).."\t"..desc.."\r\n"
end
end
if x then
return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
else
return "Sorry "..user.sNick.." These commands are disabled for your profile."
end
else
return "Show Request Help","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
reqabout = function(user,data)
local reply = "\n\n\tAbout this script..\n"..
"\t"..string.rep("?",40).."\r\n"
if user then
x=1
local FileSize1 = CheckFile(RelCfg.BuFile)
local FileSize2 = CheckFile(RelCfg.RelFile)
local FileSize3 = CheckFile(RelCfg.ReqFile)
if x then
reply = reply.."\t09-02-2008\n"..
"\n\tReleaseBot "..RelCfg.Version.." ".._VERSION.." [API 2] made by Daywalker?\n"..
"\n\tUsing some code snibbets from Sir Mutor cause i like that style and it's easy going imo :)\n"..
"\tTnx to Plop to point me to the right table form :))\n"..
"\tAnd as always CrazyGuy for listen to my mumbling about some code :P\n"..
"\n\tThis Script Release Candidate was Finished at 04/05/08 16:44:24 +1 UTC"..
"\n\tExact Date and Time for now is: "..os.date().." "..RelCfg.Tz..
"\n\tScript uses "..Mem().." atm."..
"\n\n\tCurrent File Sizes are for:"..
"\n\t"..string.rep("~",20)..
"\n\tGenre file\t\t: "..FileSize1..
"\n\tRelease file\t: "..FileSize2..
"\n\tRequest file\t: "..FileSize3..
"\n\t"..string.rep("~",20).."\n"
end
return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
else
return "Show about this script","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
}

SendRelCmds = function(user)
local x
for i,v in pairsByKeys(RelCmds) do
local desc,arg1,arg2,tab = RelCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
Core.SendToNick(user.sNick,"$UserCommand 1 1 "..RelCfg.Menu.."\\"..RelCfg.SubMenu1.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
Core.SendToNick(user.sNick,"$UserCommand 1 2 "..RelCfg.Menu.."\\"..RelCfg.SubMenu1.."\\"..
desc.."$$To: "..RelCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
end
end
if x then
local Prof
if user.iProfile ~= -1 then
Prof = ProfMan.GetProfile(user.iProfile).sProfileName
else
Prof = "Unregistered User"
end
end
collectgarbage("collect")
end

SendReqCmds = function(user)
local x
for i,v in pairsByKeys(ReqCmds) do
local desc,arg1,arg2,tab = ReqCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
Core.SendToNick(user.sNick,"$UserCommand 1 1 "..RelCfg.Menu.."\\"..RelCfg.SubMenu2.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
Core.SendToNick(user.sNick,"$UserCommand 1 2 "..RelCfg.Menu.."\\"..RelCfg.SubMenu2.."\\"..
desc.."$$To: "..RelCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
end
end
if x then
local Prof
if user.iProfile ~= -1 then
Prof = ProfMan.GetProfile(user.iProfile).sProfileName
else
Prof = "Unregistered User"
end
end
collectgarbage("collect")
end

SendRel = function(user)
if RelCfg.sendrelease then
if user then
local od,pos,datesplit = string.find(os.date(), "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
local reply = "Listing All Today Releases ...\r\n\r\n\tID. "..
"\tGenre\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Date"] then
tb,pos,splittabledate = string.find(v["Date"], "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if splittabledate == datesplit then
reply = reply.."\tID: "..i.."\t"..v["Genre"].."\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
else
x=1
end
end
end
if x then
--nice empty space to fool the bot^^
end
if RelCfg.HowToSend == "Main" then
Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..reply.."\n\t"..string.rep("?",100)..
"\n\n\tWelcome "..user.sNick.." to "..SetMan.GetString(0).."\n\n"..
"\tLet me introduce you to at least one of our services in this hub...\n"..
"\tthe 0 day releases... a hot item for some users and yes we have it!!\n"..
"\tTo download this releases you need to type !regme <password> in main\n"..
"\tto ask for a Vip acount, cause minimal profile to download is Vip profile\n"..
"\n\tType !rlshelp in main or use the RC Commands on the hub tab to get help with the releasebot\n"..
"\tEnjoy your stay in this hub and don't forget to type\n"..
"\t!regme <password> when you're not regged as a vip or ask\n"..
"\t(.??-DJC-?.)T.C.M or (.??-DJC-?.)M.O.T.S? for a Vip acount... Enjoy:))\n\n"..
"\n\t"..string.rep("?",100).."\r\n\r\n")
else
Core.SendPmToNick(user.sNick,RelCfg.Bot,reply.."\n\t"..string.rep("?",100)..
"\n\n\tWelcome "..user.sNick.." to "..SetMan.GetString(0).."\n\n"..
"\tLet me introduce you to at least one of our services in this hub...\n"..
"\tthe 0 day releases... a hot item for some users and yes we have it!!\n"..
"\tTo download this releases you need to type !regme <password> in main\n"..
"\tto ask for a Vip acount, cause minimal profile to download is Vip profile\n"..
"\n\tType !rlshelp in main or use the RC Commands on the hub tab to get help with the releasebot\n"..
"\tEnjoy your stay in this hub and don't forget to type\n"..
"\t!regme <password> when you're not regged as a vip or ask\n"..
"\t(.??-DJC-?.)T.C.M or (.??-DJC-?.)M.O.T.S? for a Vip acount... Enjoy:))\n\n"..
"\n\t"..string.rep("?",100).."\r\n\r\n")
end
end
else

end
end

OnTimer = function(clean)
if clean then
Core.SendToAll("<"..RelCfg.Bot.."> Release cleaner started at "..os.date())
local cur,chg = os.time()
local msg = "\n\t"..string.rep("=",130)..
"\n\t\t\t\t\t- Listing Deleted Releases Older Then "..RelCfg.CleanTime.." Days-"..
"\n\t"..string.rep("-",260).."\n"
for i,v in pairs(RelCfg.Rel) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (RelCfg.CleanTime-what)
if what > RelCfg.CleanTime then
--message
msg = msg.."\tRelease: "..v["Release"].." is deleted from the releasebot\n"
table.remove(RelCfg.Rel[i])
RelCfg.Rel[i] = nil
chg = true
end
end
local reqmsg = "\n\t"..string.rep("=",130)..
"\n\t\t\t\t\t- Listing Deleted Requests Older Then "..RelCfg.CleanTime.." Days-"..
"\n\t"..string.rep("-",260).."\n"
local cur2,chg2 = os.time()
for i,v in pairs(RelCfg.Req) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (RelCfg.CleanTime-what)
if what > RelCfg.CleanTime then
--message
reqmsg = reqmsg.."\tRequest: "..v["Request"].." is deleted from the releasebot\n"
table.remove(RelCfg.Req[i])
RelCfg.Req[i] = nil
chg2 = true
end
end
if chg then
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
Core.SendToAll("<"..RelCfg.Bot.."> "..msg.."\n\t"..string.rep("?",130).."\r\n\r\n")
else
Core.SendToAll("<"..RelCfg.Bot.."> There are no Releases to delete yet, maybe next time..")
end
if chg2 then
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
Core.SendToAll("<"..RelCfg.Bot.."> "..reqmsg.."\n\t"..string.rep("?",130).."\r\n\r\n")
else
Core.SendToAll("<"..RelCfg.Bot.."> There are no Requests to delete yet, maybe next time..")
end
end
end

CountPairs = function(Table)
local x = 0
if Table then
for i,v in pairs(Table) do
x = x + 1
end
end
return x
end

TimeZone = function()
local h,m = math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
return string.format("%+d UTC",(h + (60 * m)))
end

Mem = function()
collectgarbage("collect")
return string.format("%-.2f Kb.",collectgarbage("count"))
end

CheckFile = function(File)
local f,e = io.open(File,"r")
if f then
local current = f:seek()
local size = f:seek("end")
f:seek("set", current) f:close()
if size then return FmtSz(size) end
else
if e then OnError(e:sub(1,2)) return e:sub(1,2) end
end
end

FmtSz = function(int)
local i,u,x= int or 0,{"","K","M","G","T","P"},1
while i > 1024 do i,x = i/1024,x+1 end return string.format("%.2f %sB.",i,u[x])
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Save_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
hFile:write( sTab.."}")
end

Save_File = function(file,table, tablename )
local hFile = io.open (file , "wb")
Save_Serialize(table, tablename, hFile)
hFile:flush()
hFile:close()
collectgarbage("collect")
end

pairsByKeys = function(t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0      -- iterator variable
local iter = function ()   -- iterator function
i = i + 1
if a[i] == nil then
return nil
else
return a[i], t[a[i]]
end
end
return iter
end


enjoy :)
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: butch on 06 April, 2008, 08:28:37
hello all

i have a problem with this great script

nothing seems to work by the firtst time and when a type something in main it apears

aim running PtokaX DC Hub 0.4.1.0RC2

tested with clients strong RSXb3 apex but all the same problem and i now 60% or more of dc users are using this kind of clients

i hoop it can be fixed

respectfully
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Daywalker? on 06 April, 2008, 12:36:48
[20080406 - 12:31:25] <PxTest> *** Scanning script folder..ReleaseBot not found, Creating ReleaseBot now....
[20080406 - 12:31:25] <PxTest> *** The folder ReleaseBot is created..inserting files now..
[20080406 - 12:31:25] <PxTest> *** C:\DJCTHAHUB\devhub\scripts\ReleaseBot\Release.tbl file inserted..
[20080406 - 12:31:25] <PxTest> *** C:\DJCTHAHUB\devhub\scripts\ReleaseBot\Request.tbl file inserted..
[20080406 - 12:31:25] <PxTest> *** C:\DJCTHAHUB\devhub\scripts\ReleaseBot\BackBone.tbl file inserted..
[20080406 - 12:31:25] <PxTest> *** ReleaseBot 1.0RC2 for Lua 5.1 by Daywalker? has been started...
[20080406 - 12:31:34] *** Disconnected
[20080406 - 12:31:34] *** Connecting to 10.0.0.10:2008...
[20080406 - 12:31:34] *** Connected
[20080406 - 12:31:35] *** Stored password sent...
[20080406 - 12:31:35] <PxTest> Daywalker Creates Errors On PtokaX DC Hub 0.4.1.0RC2 (UpTime: 1 days, 17 hours, 20 minutes / Users: 0)
[20080406 - 12:31:36] <PxTest>

                          booo
[20080406 - 12:31:51] <PxTest>
========================================
- Release Command Help-
--------------------------------------------------------------------------------
Command Description
????????????????????????????????????????
!addgen          Add A Genre
!addrel          Add A Release
!delgen          Delete A Genre
!delrel          Delete A Release
!findrel        Find A Release
!gen            Show Genres
!prunerel        Clean release table
!prunereq        Clean request table
!relabout        Show about this script
!rls            Show releases (genre)
!rlshelp        Show Release Help
!today          Show releases of today (genre)

????????????????????????????????????????


[20080406 - 12:32:09] <PxTest> Genre: Techno is added to the ReleaseBot
[20080406 - 12:32:09] <PxTest> Genre: Techno is added by Daywalker to the ReleaseBot
[20080406 - 12:33:49] <PxTest> Release: ThisNameCanBeAReleaseNameAndSceneReleaseNamesAreAlwaysWithoutSpaces is added to releasebot
[20080406 - 12:33:49] <PxTest> Release: ThisNameCanBeAReleaseNameAndSceneReleaseNamesAreAlwaysWithoutSpaces is added by Daywalker to the ReleaseBot under genre: Techno


dunno where it goes wrong but i don't have any problems,
if you get errors or such pls show them so i can take a look at it.
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: butch on 06 April, 2008, 13:10:21
hello

px dont send anny error

when a add windows to realese gerne or annything it wont work intill a type somthing in main

[13:05:43] <?H?b-??r?t??> Genre: Windows<??ghtW??h> 1 is added by ??ghtW??h to the ReleaseBot

here i type 1 in main but the gerne isnt really add to the datebass

i stopped all other script so only your script is running but wont work

respectfully
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: butch on 06 April, 2008, 13:23:19
when i type the command in main it works

[13:20:20] <?H?b-??r?t??> Genre: windows is added to the ReleaseBot
[13:20:20] <?H?b-??r?t??> Genre: windows is added by ??ghtW??h to the ReleaseBot

so it most be the rightclick  ???

respectfully
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Daywalker? on 06 April, 2008, 13:36:56
wich client are you using atm?
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: butch on 06 April, 2008, 13:41:48
checked with rsxb3  apex strong  :)

respectfully
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Daywalker? on 06 April, 2008, 14:20:41
i tested it with all latest versions of the client you pointed it

started with latest StrongDc then latest Rsx and finaly latest Apex

All test done with RC commands

[20080406 - 13:50:08] <PxTest> Genre: RcCommand is added by ThaTest to the ReleaseBot
[20080406 - 13:58:46] <PxTest> Genre: RcCommandsRsx is added by ThaTest to the ReleaseBot
[20080406 - 13:59:27] <PxTest> Genre: RSX is added by ThaTest to the ReleaseBot
[20080406 - 14:13:48] <PxTest> Genre: RcCommandsApex is added by ThaTest to the ReleaseBot
[20080406 - 14:14:10] <PxTest> Genre: Apex is added by ThaTest to the ReleaseBot


Maybe they solved it in the latest versions.
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: butch on 06 April, 2008, 15:00:20
aim bulding a new hub now becouse a tested with the same client dont understand whats not good then  ???

and aim not allone with the same probs in my test hub

tnxxxx for your quick replays ppl

i let you now if its works or not tnxxxx

respectfully
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: butch on 06 April, 2008, 17:44:26
hey all

it isnt working also not in new hub tested with 4 ppl

so i have down a other release Release_Bot_1.3 [New API]  ???

and it works great on the new and old hub so dont now whats not good with this script i hoop you fix this problem for other px users

tnxxx for your time and good luck with your script

respectfully
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Daywalker? on 06 April, 2008, 19:47:44
well i dunno either...

i'm using it with over hundred ppl and works great here ^^
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: butch on 07 April, 2008, 16:55:10
script works fine with dc++705 so it are the clients mutor is right but allot dcers have this bath client but great job Daywalker

your script is good can annywhane plz tell me all the good client with this code plz &#124;|

respectfully
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: larsen on 18 December, 2008, 11:09:11
[11:07] Syntax C:\Server\Larsens\scripts\test.lua:885: attempt to index local 'hFile' (a nil value)

[11:08:37] <MainBot> *** Scanning script folder..ReleaseBot not found, Creating ReleaseBot now....
[11:08:37] <MainBot> C:\Server\LarsensPlace\scripts\test.lua:885: attempt to index local 'hFile' (a nil value)

[11:10:30] <MainBot> C:\Server\Larsens\scripts\test.lua:230: bad argument #1 to 'pairs' (table expected, got nil)
[11:10:38] <MainBot> C:\Server\Larsens\scripts\test.lua:169: bad argument #1 to 'pairs' (table expected, got nil)

some can help me ???
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: larsen on 22 December, 2008, 09:13:22
heej some can make it to PtokaX DC Hub 0.4.1.1 ??

thanks all friends
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Annie on 27 July, 2009, 01:56:11
Hiya, Ive been trying this script today I have got it all working etc.  I have a problem though  when I go to add a release I type in the pop up box;
genre - Movies   release  - Harry Potter  and i get this     ** The genre: >> Movies Harry << is not available yet..

But

If I do this   add a release  genre -  Movies   release Harry.Potter   I get this    Release: Harry.Potter is added by Annie to the ReleaseBot under genre: Movies

If I want to add a space in the release's name  it wont let me.   Is there a quick fix for this?

Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: The Undertaker on 20 February, 2010, 18:40:03
im using ptokax 0.4.1.1 under linux. release adding is fine, but if i try to view releases i got error:
/home/undertaker/PtokaX/scripts/Release_Bot.lua:393: attempt to concatenate field 'Release' (a nil value)

any ideas?
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: The Undertaker on 24 February, 2010, 04:22:51
found solution myself. it was typo in var which caused release view dont work, also requests was not working due this. to fix it all find this line:
table.insert(RelCfg.Rel,RequestUpdate)
and replace it with
table.insert(RelCfg.Req,RequestUpdate)

error i described above was happends if someone was adding request and due this typo in code request was going added to releases file.

also will be nice if someone can make it send releases to PM. because i cant get it to work
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: sphinx_spb on 17 October, 2013, 06:15:48
Some modifications and fixes to the script

--[[

09-02-2008

ReleaseBot 1.0 LUA 5.11 [API 2] made by Daywalker

Using some code snibbets from Sir Mutor cause i like that style and it's easy going imo :)
Tnx to Plop to point me to the right table form :))
And as always CrazyGuy for listen to my mumbling about some code :P

- RC2:
* Added the !findrel command (finds all the Releases including the word you searched for)
* Added the !prunerel and !prunereq commands to maually prune the tabled by day
* Fixed the TableCleaner cause it didn't work properly
* Fixed the start script error when hub is not running
* Fixed or Added (that's how you look against it^^) the hFile error when Folder isn't there yet...
script will search for Folder first and will create it first now.
* Added version number for script

]]


RelCfg = {
------------------------------- Main Settings -----------------------------------
-- Botname if "" then it will be pulled from the hub or use "Custom-Name"
Bot = "ReleaseBot",
-- Hub Name if "" then it will be set to hubname
Hub = "",
-- Should bot have a key? true / false
BotIsOp = true,
-- Bot description
BotDesc = "ReleaseBot",
-- Bot Email address
BotMail = "release@genre.mp3",
-- Script version
Version = "1.0RC2",
-- folder for DB
Folder = "ReleaseBot",
-- File to save Release table
RelFile = "Release.tbl",
-- File to save Request table
ReqFile = "Request.tbl",
-- File to save Other stuff to table
BuFile = "BackBone.tbl",
-- File to save Requests' filled table
ReqDoneFile = "RequestDone.tbl",
-- Context Menu Title if "" then it will be set to hubname
Menu = "",
-- Context Submenu Titles
SubMenu1 = "Release",
SubMenu2 = "Request",
-- activate show today release on connect true or false
sendrelease = true,
-- send releases to main or pm  "Main/Pm"
HowToSend = "Pm",
-- Time to clean a table in days
CleanTime = 8,
-- Time to do the cleaning repeatly [ 24*(60*60000)  =  1 day]
DoClean = 24*(60*60000),
------------------------------ Don't Try This At Home --------------------------
}



OnStartup = function()
if RelCfg.Bot == "" then RelCfg.Bot = SetMan.GetString(21) end
if RelCfg.Menu == "" then RelCfg.Menu = SetMan.GetString(0) end
if RelCfg.Hub == "" then RelCfg.Hub = SetMan.GetString(0) end
clean = TmrMan.AddTimer(RelCfg.DoClean)
RelCfg.Tz = TimeZone()
RelCfg.Pfx = SetMan.GetString(29):sub(1,1)
RelCfg.Path = string.gsub(Core.GetPtokaXPath().."scripts/"..RelCfg.Folder.."/","/","\\")
RelCfg.RelFile = RelCfg.Path..RelCfg.RelFile
RelCfg.ReqFile = RelCfg.Path..RelCfg.ReqFile
RelCfg.BuFile = RelCfg.Path..RelCfg.BuFile
RelCfg.ReqDoneFile = RelCfg.Path..RelCfg.ReqDoneFile
gc,no = nil,table.getn
if _VERSION ~= "Lua 5.1" and _VERSION ~= "Lua 5.2" then
return OnError("Error! This script is incompatible with ".._VERSION), true
end
if loadfile(RelCfg.RelFile) then
dofile(RelCfg.RelFile)
OnError("<"..RelCfg.Bot.."> *** Loading Release File....|")
else
os.execute("mkdir "..RelCfg.Folder)
OnError("<"..RelCfg.Bot.."> *** Scanning script folder.."..RelCfg.Folder.." not found, Creating "..RelCfg.Folder.." now....|")
RelCfg.Rel = {}
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
OnError("<"..RelCfg.Bot.."> *** The folder "..RelCfg.Folder.." is created..inserting files now..|")
OnError("<"..RelCfg.Bot.."> *** "..RelCfg.RelFile.." file inserted..|")
end
if loadfile(RelCfg.ReqFile) then
dofile(RelCfg.ReqFile)
OnError("<"..RelCfg.Bot.."> *** Loading Request File........|")
else
RelCfg.Req = {}
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
OnError("<"..RelCfg.Bot.."> *** "..RelCfg.ReqFile.." file inserted..|")
end
if loadfile(RelCfg.BuFile) then
dofile(RelCfg.BuFile)
OnError("<"..RelCfg.Bot.."> *** Loading Genre File...............|")
else
RelCfg.Bu = {}
Save_File(RelCfg.BuFile,RelCfg.Bu,"RelCfg.Bu")
OnError("<"..RelCfg.Bot.."> *** "..RelCfg.BuFile.." file inserted..|")
end

if loadfile(RelCfg.ReqDoneFile) then
dofile(RelCfg.ReqDoneFile)
OnError("<"..RelCfg.Bot.."> *** Loading RequestDone File........|")
else
RelCfg.ReqDone = {}
Save_File(RelCfg.ReqDoneFile,RelCfg.ReqDone,"RelCfg.ReqDone")
OnError("<"..RelCfg.Bot.."> *** "..RelCfg.ReqDoneFile.." file inserted..|")
end
if RelCfg.Bot ~= SetMan.GetString(21) or
RelCfg.Bot == SetMan.GetString(21) and SetMan.GetBool(17) == false then
Core.RegBot(RelCfg.Bot, RelCfg.BotDesc, RelCfg.BotMail, RelCfg.BotIsOp)
end
OnError("*** ReleaseBot "..RelCfg.Version.." for ".._VERSION.." by Daywalker has been started...")
end

OnExit = function()
OnError("*** ReleaseBot "..RelCfg.Version.." for ".._VERSION.." by Daywalker has been stopped...")
end

OnError = function(msg)
for i=0,1 do
Core.SendToProfile(i, "<"..RelCfg.Bot.."> "..msg.."|")
end
end

function UserConnected(user, data)
SendRelCmds(user)
SendReqCmds(user)
SendRel(user)
end

OpConnected = UserConnected
RegConnected = UserConnected

ChatArrival = function(user, data)
local s,e,cmd = string.find( data, "%b<> %p(%w+)")
local s,e,to = string.find(data,"^$To: (%S+) From:")
if cmd and RelCmds[cmd] then
local _,_,_,tab = RelCmds[cmd]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
if to and to == RelCfg.Bot then
Core.SendPmToNick(user.sNick,RelCfg.Bot,RelCmds[cmd](user,data).."|")
else
local message = RelCmds[cmd](user,data)
Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..message.."|")
end
collectgarbage("collect")
return true
end
end
if cmd and ReqCmds[cmd] then
local _,_,_,tab = ReqCmds[cmd]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
if to and to == RelCfg.Bot then
Core.SendPmToNick(user.sNick,RelCfg.Bot,ReqCmds[cmd](user,data).."|")
else
local message = ReqCmds[cmd](user,data)
Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..message.."|")
end
collectgarbage("collect")
return true
end
end
end
ToArrival = ChatArrival

RelCmds = {
addgen = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
if not genre  then
return "Error!, Use: "..RelCfg.Pfx..
"addgen <genre>"
else
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
return "*** The genre: >> "..v["Genre"].." << is allready added to the ReleaseBot"
end
end
if not RelCfg.Bu then
RelCfg.Bu = {["Genre"] = genre}
else
spam = {["Genre"] = genre}
table.insert(RelCfg.Bu,spam)
end
Core.SendToAll("<"..RelCfg.Bot.."> Genre: "..genre.." is added by "..user.sNick.." to the ReleaseBot|")
Save_File(RelCfg.BuFile,RelCfg.Bu,"RelCfg.Bu")
return "Genre: "..genre.." is added to the ReleaseBot|"
end
else
return "Add A Genre"," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
delgen = function(user,data)
if user then
local s,e,ID = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not ID then
return "Error!, Use: "..RelCfg.Pfx..
"delgen <ID>"
else
local x
for i,v in pairs(RelCfg.Bu) do
if string.lower(i) == string.lower(ID) then
x = i
break
end
end
if x then
RelCfg.Bu[x] = nil
Save_File(RelCfg.BuFile,RelCfg.Bu,"RelCfg.Bu")
return "ID: "..x.." is deleted from Genre list"
else
return "ID: "..ID.." is not in the Genre list"
end
end
else
return "Delete A Genre"," %[line:ID]"," %[line:ID]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
addrel = function(user,data)
if user then
local s,e,genre,release = string.find( data, "%b<> %p%w+%s(%S+)%s(.+)|$")
if not release  then
return "Error!, Use: "..RelCfg.Pfx..
"addrel <genre> <release>"
else
for i,v in pairs(RelCfg.Rel) do
if v["Release"] == release then
return "*** The release: >> "..v["Release"].." << is allready added to the ReleaseBot"
end
end
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
ReleaseUpdate = {["Genre"] = genre,["Release"] = release,["Name"] = user.sNick,["Date"] = os.date(),["Time"] = os.time(),}
table.insert(RelCfg.Rel,ReleaseUpdate)
Core.SendToAll("<"..RelCfg.Bot.."> Release: "..release.." is added by "..user.sNick.." to the ReleaseBot under genre: "..v["Genre"].."|")
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
return "Release: "..release.." is added to releasebot|"
else
msg = "*** The genre: >> "..genre.." << is not available yet.."
end
end
return msg
end
else
return "Add A Release"," %[line:Genre] %[line:Release]"," %[line:Genre] %[line:Release]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
delrel = function(user,data)
if user then
local s,e,ID = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not ID then
return "Error!, Use: "..RelCfg.Pfx..
"delrel <ID>"
else
local x
for i,v in pairs(RelCfg.Rel) do
if string.lower(i) == string.lower(ID) then
x = i
break
end
end
if x then
RelCfg.Rel[x] = nil
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
return "ID: "..x.." is deleted from the ReleaseBot"
else
return "ID: "..ID.." is not in the ReleaseBot"
end
end
else
return "Delete A Release"," %[line:ID]"," %[line:ID]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
prunerel = function(user,data)
if user then
local s,e,prune = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not prune  then
return "Error!, Use: "..RelCfg.Pfx..
"prunerel <days>"
else
local cur,chg = os.time()
local msg = "\n\t"..string.rep("=",130)..
"\n\t\t\t\t\t- Listing Deleted Releases Older Then "..prune.." Days-"..
"\n\t"..string.rep("-",260).."\n"
for i,v in pairs(RelCfg.Rel) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (tonumber(prune)-what)
if what > tonumber(prune) then
--message
msg = msg.."\tRelease: "..v["Release"].." is deleted from the releasebot\n"
table.remove(RelCfg.Rel[i])
RelCfg.Rel[i] = nil
chg = true
end
end
if chg then
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
Core.SendToAll("<"..RelCfg.Bot.."> "..user.sNick.." Deleted All Releases Older then "..prune.." Days")
return msg.."\n\t"..string.rep("?",130).."\r\n\r\n"
end
return "There Are No Releases To Delete Yet!!\n"
end
else
return "Clean release table"," %[line:Days to prune]"," %[line:Days to prune]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
prunereq = function(user,data)
if user then
local s,e,prune = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not prune  then
return "Error!, Use: "..RelCfg.Pfx..
"prunereq <days>"
else
local cur,chg = os.time()
local msg = "\n\t"..string.rep("=",130)..
"\n\t\t\t\t\t- Listing Deleted Requests Older Then "..prune.." Days-"..
"\n\t"..string.rep("-",260).."\n"
for i,v in pairs(RelCfg.Req) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (tonumber(prune)-what)
if what > tonumber(prune) then
--message
msg = msg.."\tRequest: "..v["Request"].." is deleted from the releasebot\n"
table.remove(RelCfg.Req[i])
RelCfg.Req[i] = nil
chg = true
end
end
if chg then
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
Core.SendToAll("<"..RelCfg.Bot.."> "..user.sNick.." Deleted All Requests Older then "..prune.." Days")
return msg.."\n\t"..string.rep("?",130).."\r\n\r\n"
end
return "*** There Are No Requests To Delete Yet!!\n"
end
else
return "Clean request table"," %[line:Days to prune]"," %[line:Days to prune]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
gen = function(user,data)
if user then
if next(RelCfg.Bu) then
local Count = 0
local reply = "\n\t\t"..string.rep("=",30)..
"\n\t\t\t- Listing Genres -"..
"\n\t\t"..string.rep("-",60).."\n"..
"\n\t\tID.\t\tGenre\n\t\t"..string.rep("?",30).."\r\n"
for i,v in pairsByKeys(RelCfg.Bu) do
reply = reply.."\t\tID: "..i..
"\t\t"..v["Genre"].."\r\n"
end
return reply.."\n\t\t"..string.rep("?",30).."\r\n\r\n"
else
return "There are no genres atm."
end
else
return "Show Genres ","","",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
rls = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
if not genre or genre == "" then
if next(RelCfg.Rel) then
local reply = "\n\t"..string.rep("=",100)..
"\n\t\t\t\t\t- Listing All Releases -"..
"\n\t"..string.rep("-",200).."\n"..
"\n\tID\t\tGenre\t\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
reply = reply.."\tID: "..i.."\t"..v["Genre"].."\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
else
return "There are no releases atm."
end
else
local reply = "Listing Releases by Genre...\r\n\r\n\tID. "..
"\t\tGenre\t\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Genre"] == genre then
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
end
else
return "Show releases (genre) "," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
today = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
local od,pos,datesplit = string.find(os.date(), "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if not genre or genre == "" then
if next(RelCfg.Rel) then
local reply = "\n\t"..string.rep("=",100)..
"\n\t\t\t\t\t- Listing All Releases of today -"..
"\n\t"..string.rep("-",200).."\n"..
"\n\tID\t\tGenre\t\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Date"] then
tb,pos,splittabledate = string.find(v["Date"], "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if splittabledate == datesplit then
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
else
x=1
end
end
end
if x then
--nice empty space to fool the bot^^
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
else
return "There are no releases for today atm."
end
else
local reply = "Listing Today's Releases by Genre...\r\n\r\n\tID. "..
"\tGenre\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Genre"] == genre then
if v["Date"] then
tb,pos,splittabledate = string.find(v["Date"], "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if splittabledate == datesplit then
reply = reply.."\tID: "..i.."\t"..v["Genre"].."\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
else
x=1
end
end
end
end
if x then
--nice empty space to fool the bot^^
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
end
else
return "Show releases of today (genre) "," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
findrel = function(user,data)
if user then
local s,e,rel = string.find( data, "%b<> %p%w+%s(.*)|$")
if not rel then
return "Error!, Use: "..RelCfg.Pfx..
"findrel <releasename or a word init>"
else
local msg = "\n\t\t"..string.rep("=",80)..
"\n\t\t\t\t\t- Search Results for the word ["..rel.."] -"..
"\n\t\t"..string.rep("-",160).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
--if string.lower(v["Release"]) == string.lower(rel) then
if string.find(string.lower(v["Release"]),rel) then
msg = msg.."\r\n\r\n\t\tInfo on the Release: "..v["Release"].." :\n"..
"\r\n\t\t"..string.rep("?",80)..
"\r\n\t\t- Known ID\t\t: "..i..
"\r\n\t\t- Full Releasename\t: "..v["Release"]..
"\r\n\t\t- Genre\t\t: "..v["Genre"]..
"\r\n\t\t- Added by\t: "..v["Name"]..
"\r\n\t\t- Time of Add\t: "..v["Date"]..
"\r\n\r\n\t\t"..string.rep("?",80).."\r\n"
else
x=1
end
end
if x then
return msg.."\n\t\t"..string.rep("-",160).."\r\n\r\n"
else
return "The Release: <"..rel.."> is not found."
end
end
else
return "Find A Release"," %[line:Release]"," %[line:Release]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
DownloadFile()
end,
rlshelp = function(user,data)
if user then
local x
local reply = "\n\t\t"..string.rep("=",40)..
  "\n\t\t\t- Release Command Help-"..
  "\n\t\t"..string.rep("-",80)..
  "\n\t\tCommand\t\tDescription\r\n"..
  "\t\t"..string.rep("?",40).."\r\n"
for i,v in pairsByKeys(RelCmds) do
local desc,args,_,tab = RelCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
reply = reply.."\t\t!"..string.format("%-15s",i).."\t"..desc.."\r\n"
end
end
if x then
return reply.."\n\t\t"..string.rep("?",40).."\r\n\r\n"
else
return "Sorry "..user.sNick.." These commands are disabled for your profile."
end
else
return "Show Release Help","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
relabout = function(user,data)
local reply = "\n\t\t"..string.rep("=",60)..
  "\n\n\t\t\t\t\t-About this script-"..
  "\n\t\t"..string.rep("-",120).."\n"
if user then
x=1
local FileSize1 = CheckFile(RelCfg.BuFile)
local FileSize2 = CheckFile(RelCfg.RelFile)
local FileSize3 = CheckFile(RelCfg.ReqFile)
if x then
reply = reply.."\t\t09-02-2008\n"..
"\n\t\tReleaseBot "..RelCfg.Version.." ".._VERSION.." [API 2] made by Daywalker\n"..
"\n\t\tUsing some code snibbets from Sir Mutor cause i like that style and it's easy going imo :)\n"..
"\t\tTnx to Plop to point me to the right table form :))\n"..
"\t\tAnd as always CrazyGuy for listen to my mumbling about some code :P\n"..
"\n\t\tThis Script Release Candidate was Finished at 04/05/08 16:44:24 +1 UTC"..
"\n\t\tExact Date and Time for now is: "..os.date().." "..RelCfg.Tz..
"\n\t\tScript uses "..Mem().." atm."..
"\n\n\t\tCurrent File Sizes are for:"..
"\n\t\t"..string.rep("~",25)..
"\n\t\t- Genre file\t: "..FileSize1..
"\n\t\t- Release file\t: "..FileSize2..
"\n\t\t- Request file\t: "..FileSize3..
"\n\t\t"..string.rep("~",25).."\n"
end
return reply.."\n\t\t"..string.rep("?",60).."\r\n\r\n"
else
return "Show about this script","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
}

ReqCmds = {
addreq = function(user,data)
if user then
local s,e,genre,request = string.find( data, "%b<> %p%w+%s(%S+)%s(.+)|$")
if not request  then
return "Error!, Use: "..RelCfg.Pfx..
"addreq <genre> <request>"
else
for i,v in pairs(RelCfg.Req) do
if v["Request"] == request then
return "*** The request: >> "..v["Request"].." << is allready added to the RequestBot"
end
end
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
RequestUpdate = {["Genre"] = genre,["Request"] = request,["Name"] = user.sNick,["Date"] = os.date(),["Time"] = os.time(),}
table.insert(RelCfg.Req,RequestUpdate) -- was error
Core.SendToAll("<"..RelCfg.Bot.."> Request: "..request.." is added by "..user.sNick.." to the RequestBot under genre: "..v["Genre"].."|")
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
return "Done!!"
else
msg = "*** The genre: >> "..genre.." << is not available yet.."
end
end
return msg
end
else
return "Add A Request"," %[line:Genre] %[line:Request]"," %[line:Genre] %[line:Request]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 0,[5] = 0,[6] = 0,}
end
end,
delreq = function(user,data)
if user then
local s,e,ID = string.find( data, "%b<> %p%w+%s(%d+)|$")
if not ID then
return "Error!, Use: "..RelCfg.Pfx..
"delrel <ID>"
else
local x
for i,v in pairs(RelCfg.Req) do
if string.lower(i) == string.lower(ID) then
x = i
break
end
end
if x then
RelCfg.Req[x] = nil
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
return "ID: "..x.." is deleted from the RequestBot"
else
return "ID: "..ID.." is not in the RequestBot"
end
end
else
return "Delete A Request"," %[line:ID]"," %[line:ID]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
end
end,
req = function(user,data)
if user then
local s,e,genre = string.find( data, "%b<> %p%w+%s(.*)|$")
if not genre or genre == "" then
if next(RelCfg.Req) then
local reply = "Listing All Requests ...\r\n\r\n\tID. "..
"\t\tGenre\t\tRequest\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Req) do
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Request"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
else
return "There are no requests atm."
end
else
local reply = "Listing Requests by Genre...\r\n\r\n\tID. "..
"\t\tGenre\t\tRequest\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Req) do
if v["Genre"] == genre then
reply = reply.."\tID: "..i.."\t\t"..v["Genre"].."\t\t"..v["Request"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
end
end
return reply.."\n\t"..string.rep("?",100).."\r\n\r\n"
end
else
return "Show requests (genre) "," %[line:Genre]"," %[line:Genre]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
reqhelp = function(user,data)
if user then
local x
local reply = "\r\n\r\n\tRequest Command Help\r\n\r\n\tCommand\t\tDescription\r\n"..
"\t"..string.rep("?",40).."\r\n"
for i,v in pairsByKeys(ReqCmds) do
local desc,args,_,tab = ReqCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
reply = reply.."\t!"..string.format("%-15s",i).."\t"..desc.."\r\n"
end
end
if x then
return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
else
return "Sorry "..user.sNick.." These commands are disabled for your profile."
end
else
return "Show Request Help","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
fillreq = function(user,data)
    if user then
local s,e,genre,ID,release = string.find( data, "%b<> %p%w+%s(%S+)%s(%S+)%s(.+)|$")
if not release or not ID then return "Error!, Use: "..RelCfg.Pfx.."fillreq <genre> <ID> <release>" end
local x,y,z = false,false,false
for i,v in pairs(RelCfg.Req) do
if v["Request"] == ID then
x = v["Request"] y= v["Name"] z = i
break
end
end
if not x then return "The request "..ID.." not found, or already been filled" end
for i,v in pairs(RelCfg.Bu) do
if v["Genre"] == genre then
for i,v in pairs(RelCfg.Rel) do
if v["Release"] == release then
return "*** The release: >> "..v["Release"].." << is allready added to the ReleaseBot"
end
end
ReleaseUpdate = {["Genre"] = genre,["Release"] = release,["Name"] = user.sNick,["Date"] = os.date(),["Time"] = os.time(),}
table.insert(RelCfg.Rel,ReleaseUpdate)
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
RequestDoneUpdate = { ["RequestID"] = x, ["Release"] = release, ["Filled by"] = user.sNick, ["Date"] = os.date(), ["Time"] = os.time(), }
table.insert(RelCfg.ReqDone,RequestDoneUpdate)
if y then Core.SendPmToNick(y, RelCfg.Bot,"*** Your request \""..ID.."\" has been filled by "..user.sNick) end
RelCfg.Req[z] = nil
Core.SendToAll("<"..RelCfg.Bot.."> "..user.sNick.." filled up Request: "..ID.."|")
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req"); Save_File(RelCfg.ReqDoneFile,RelCfg.ReqDone,"RelCfg.ReqDone");
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
return "The request \""..ID.."\" has been filled by "..user.sNick
else
return "*** The genre: >> "..genre.." << is not available yet.."
end
end
else
return "Fill request"," %[line:Genre] %[line:ID] %[line:Release]"," %[line:Genre] %[line:ID] %[line:Release]",
-- profiles aan of uit
{[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 0,[4] = 0,[5] = 0,[6] = 0,}
    end
end,
reqabout = function(user,data)
local reply = "\n\n\tAbout this script..\n"..
"\t"..string.rep("?",40).."\r\n"
if user then
x=1
local FileSize1 = CheckFile(RelCfg.BuFile)
local FileSize2 = CheckFile(RelCfg.RelFile)
local FileSize3 = CheckFile(RelCfg.ReqFile)
if x then
reply = reply.."\t09-02-2008\n"..
"\n\tReleaseBot "..RelCfg.Version.." ".._VERSION.." [API 2] made by Daywalker\n"..
"\n\tUsing some code snibbets from Sir Mutor cause i like that style and it's easy going imo :)\n"..
"\tTnx to Plop to point me to the right table form :))\n"..
"\tAnd as always CrazyGuy for listen to my mumbling about some code :P\n"..
"\n\tThis Script Release Candidate was Finished at 04/05/08 16:44:24 +1 UTC"..
"\n\tExact Date and Time for now is: "..os.date().." "..RelCfg.Tz..
"\n\tScript uses "..Mem().." atm."..
"\n\n\tCurrent File Sizes are for:"..
"\n\t"..string.rep("~",20)..
"\n\tGenre file\t\t: "..FileSize1..
"\n\tRelease file\t: "..FileSize2..
"\n\tRequest file\t: "..FileSize3..
"\n\t"..string.rep("~",20).."\n"
end
return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
else
return "Show about this script","","",
-- profiles aan of uit
{[-1] = 1,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}
end
end,
}

SendRelCmds = function(user)
local x
for i,v in pairsByKeys(RelCmds) do
local desc,arg1,arg2,tab = RelCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
Core.SendToNick(user.sNick,"$UserCommand 1 1 "..RelCfg.Menu.."\\"..RelCfg.SubMenu1.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
Core.SendToNick(user.sNick,"$UserCommand 1 2 "..RelCfg.Menu.."\\"..RelCfg.SubMenu1.."\\"..
desc.."$$To: "..RelCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
end
end
if x then
local Prof
if user.iProfile ~= -1 then
Prof = ProfMan.GetProfile(user.iProfile).sProfileName
else
Prof = "Unregistered User"
end
end
collectgarbage("collect")
end

SendReqCmds = function(user)
local x
for i,v in pairsByKeys(ReqCmds) do
local desc,arg1,arg2,tab = ReqCmds[i]()
if tab[user.iProfile] and tab[user.iProfile] == 1 then
x = 1
Core.SendToNick(user.sNick,"$UserCommand 1 1 "..RelCfg.Menu.."\\"..RelCfg.SubMenu2.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
Core.SendToNick(user.sNick,"$UserCommand 1 2 "..RelCfg.Menu.."\\"..RelCfg.SubMenu2.."\\"..
desc.."$$To: "..RelCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
end
end
if x then
local Prof
if user.iProfile ~= -1 then
Prof = ProfMan.GetProfile(user.iProfile).sProfileName
else
Prof = "Unregistered User"
end
end
collectgarbage("collect")
end

SendRel = function(user)
if RelCfg.sendrelease then
if user then
local od,pos,datesplit = string.find(os.date(), "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
local reply = "Listing All Today Releases ...\r\n\r\n\tID. "..
"\tGenre\tRelease\r\n\t"..string.rep("?",100).."\r\n"
for i,v in pairsByKeys(RelCfg.Rel) do
if v["Date"] then
tb,pos,splittabledate = string.find(v["Date"], "%d+%/(%d+)%/%d+%s%d+%:%d+%:%d+")
if splittabledate == datesplit then
reply = reply.."\tID: "..i.."\t"..v["Genre"].."\t"..v["Release"].." // Added by "..v["Name"].." at "..v["Date"].."\r\n"
else
x=1
end
end
end
if x then
--nice empty space to fool the bot^^
end
local msg="\n\t"..string.rep("?",100)..
"\n\n\tWelcome "..user.sNick.." to "..SetMan.GetString(0).."\n\n"..
"\tLet me introduce you to at least one of our services in this hub...\n"..
"\tthe 0 day releases... a hot item for some users and yes we have it!!\n"..
"\tTo download this releases you need to type !regme <password> in main\n"..
"\tto ask for a Vip acount, cause minimal profile to download is Vip profile\n"..
"\n\tType !rlshelp in main or use the RC Commands on the hub tab to get help with the releasebot\n"..
"\tEnjoy your stay in this hub and don't forget to type\n"..
"\t!regme <password> when you're not regged as a vip or ask\n"..
"\t(.??-DJC-?.)T.C.M or (.??-DJC-?.)M.O.T.S? for a Vip acount... Enjoy:))\n\n"..
"\n\t"..string.rep("?",100).."\r\n\r\n"
if RelCfg.HowToSend == "Main" then
Core.SendToNick(user.sNick,"<"..RelCfg.Bot.."> "..reply..msg)
else
Core.SendPmToNick(user.sNick,RelCfg.Bot,reply..msg)
end
end
else

end
end

OnTimer = function(clean)
if clean then
Core.SendToAll("<"..RelCfg.Bot.."> Release cleaner started at "..os.date())
local cur,chg = os.time()
local msg = "\n\t"..string.rep("=",130)..
"\n\t\t\t\t\t- Listing Deleted Releases Older Then "..RelCfg.CleanTime.." Days-"..
"\n\t"..string.rep("-",260).."\n"
for i,v in pairs(RelCfg.Rel) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (RelCfg.CleanTime-what)
if what > RelCfg.CleanTime then
--message
msg = msg.."\tRelease: "..v["Release"].." is deleted from the releasebot\n"
table.remove(RelCfg.Rel[i])
RelCfg.Rel[i] = nil
chg = true
end
end
local reqmsg = "\n\t"..string.rep("=",130)..
"\n\t\t\t\t\t- Listing Deleted Requests Older Then "..RelCfg.CleanTime.." Days-"..
"\n\t"..string.rep("-",260).."\n"
local cur2,chg2 = os.time()
for i,v in pairs(RelCfg.Req) do
local td = os.difftime(os.time(),v["Time"])
local what = (td/86400)
local TtoGo = (RelCfg.CleanTime-what)
if what > RelCfg.CleanTime then
--message
reqmsg = reqmsg.."\tRequest: "..v["Request"].." is deleted from the releasebot\n"
table.remove(RelCfg.Req[i])
RelCfg.Req[i] = nil
chg2 = true
end
end
if chg then
Save_File(RelCfg.RelFile,RelCfg.Rel,"RelCfg.Rel")
Core.SendToAll("<"..RelCfg.Bot.."> "..msg.."\n\t"..string.rep("?",130).."\r\n\r\n")
else
Core.SendToAll("<"..RelCfg.Bot.."> There are no Releases to delete yet, maybe next time..")
end
if chg2 then
Save_File(RelCfg.ReqFile,RelCfg.Req,"RelCfg.Req")
Core.SendToAll("<"..RelCfg.Bot.."> "..reqmsg.."\n\t"..string.rep("?",130).."\r\n\r\n")
else
Core.SendToAll("<"..RelCfg.Bot.."> There are no Requests to delete yet, maybe next time..")
end
end
end

CountPairs = function(Table)
local x = 0
if Table then
for i,v in pairs(Table) do
x = x + 1
end
end
return x
end

TimeZone = function()
local h,m = math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
return string.format("%+d UTC",(h + (60 * m)))
end

Mem = function()
collectgarbage("collect")
return string.format("%-.2f Kb.",collectgarbage("count"))
end

CheckFile = function(File)
local f,e = io.open(File,"r")
if f then
local current = f:seek()
local size = f:seek("end")
f:seek("set", current) f:close()
if size then return FmtSz(size) end
else
if e then OnError(e:sub(1,2)) return e:sub(1,2) end
end
end

FmtSz = function(int)
local i,u,x= int or 0,{"","K","M","G","T","P"},1
while i > 1024 do i,x = i/1024,x+1 end return string.format("%.2f %sB.",i,u[x])
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Save_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
hFile:write( sTab.."}")
end

Save_File = function(file,table, tablename )
local hFile = io.open (file , "wb")
Save_Serialize(table, tablename, hFile)
hFile:flush()
hFile:close()
collectgarbage("collect")
end

pairsByKeys = function(t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0      -- iterator variable
local iter = function ()   -- iterator function
i = i + 1
if a[i] == nil then
return nil
else
return a[i], t[a[i]]
end
end
return iter
end
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Hellraiser on 17 October, 2013, 09:53:19
Thanks a ton, sphinx_spb!!   :)

Cheers! :beer:
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: wafiqfarhan on 03 April, 2014, 19:29:11
hi,

can someone provide the list command?

quite new here for scripting. thanks
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: wafiqfarhan on 10 June, 2014, 13:49:57
Hey,

How to use fill a request in release script by Daywalker?

!fillreq <genre> <ID> <release>

genre and id in release or request ? and release ?

it's working so good for now. but I dont know how fill a request script works.

thanks.
Title: Re: ReleaseBot 1.0 RC1 LUA 5.11 [API 2]
Post by: Hellraiser on 11 June, 2014, 08:05:51
id is request id genre is what the request genre was and release is the magnet link of the file with which you want to fill the request

hope that helps