Tackling errors in modified version of Release/Request script by Daywalker
 

Tackling errors in modified version of Release/Request script by Daywalker

Started by RPGamer, 25 January, 2016, 12:06:01

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RPGamer

There are some errors popping when I try to put a release (and possibly also for request). The genre table is working fine, there are no errors when new genres are added (now I haven't put any more genres). The error keeps showing up every minute and to tackle the problem I have to stop the script, manually delete the release and request tables and then restart it. Can someone rectify or point out the exact cause of error?

Pasting error messages being shown:
Quote\Ptokax\scripts\ReleaseBot_Daywalker.lua:756: attempt to concatenate field 'Release' (a nil value)
stack traceback:
Ptokax\scripts\ReleaseBot_Daywalker.lua:756: in function 'SendRel'
Ptokax\scripts\ReleaseBot_Daywalker.lua:123: in function <...kh\Downloads\Ptokax\scripts\ReleaseBot_Daywalker.lua:120>

Pasting the code below:
Code: Lua
--[[

	09-02-2008

	ReleaseBot 1.0 LUA 5.11 [API 2] made by Daywalker
	Edited by RPGamer
	Using some code snibbets from Sir American Idiot 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 = "Request/Release",
-- 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 = 90,
-- Time to do the cleaning repeatly [ 24*(60*60000)  =  1 day]
DoClean = 90*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.SendPmToNick(user.sNick,RelCfg.Bot,"<"..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.SendPmToNick(user.sNick,RelCfg.Bot,"<"..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] = 1,[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\t\tEdited by RPGamer"..
				"\n\t\tUsing some code snibbets from Sir American Idiot 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] = 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,
	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 American Idiot 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 Registered acount, cause minimal profile to download is Registered 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 or ask\n"..
				"\tRPGamer for a registered account... 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 Registered acount, cause minimal profile to download is Registered 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 or ask\n"..
				"\tRPGamer for a registered account... 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

the-master

Try this, found some minor issues in string handling.. your version couldn't read or write from/to file
Code: Lua
--[[

	09-02-2008

	ReleaseBot 1.0 LUA 5.11 [API 2] made by Daywalker
	Edited by RPGamer
	Using some code snibbets from Sir American Idiot 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 = "Request/Release",
-- 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 = 90,
-- Time to do the cleaning repeatly [ 24*(60*60000)  =  1 day]
DoClean = 90*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.SendPmToNick(user.sNick,RelCfg.Bot,"<"..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.SendPmToNick(user.sNick,RelCfg.Bot,"<"..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 _,_,genre,release = data:find("%b<>%s+%S+%s+(%S+)%s+(.*)|$")
--			local s,e,genre,release = data.find("%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] = 1,[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\t\tEdited by RPGamer"..
				"\n\t\tUsing some code snibbets from Sir American Idiot 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 = data.find("%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] = 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,
	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 American Idiot 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 Registered acount, cause minimal profile to download is Registered 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 or ask\n"..
				"\tRPGamer for a registered account... 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 Registered acount, cause minimal profile to download is Registered 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 or ask\n"..
				"\tRPGamer for a registered account... 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


Btw.. this script is working on lua versions higher, just delete the 3 lines code:
   if _VERSION ~= "Lua 5.1" then
      return OnError("Error! This script is incompatible with ".._VERSION), true
   end
keep on sharing :)

RPGamer

@the-master
I tried your code and replaced all the sections that you edited or corrected the indentation, but whenever I try to add a new request this error occurs:
QuotePtokax\scripts\ReleaseBot_Daywalker.lua:558: bad argument #2 to 'find' (string expected, got no value)
stack traceback:
   [C]: in function 'find'
        Ptokax\scripts\ReleaseBot_Daywalker.lua:558: in function '?'
        Ptokax\scripts\ReleaseBot_Daywalker.lua:151: in function <...kh\Downloads\Ptokax\scripts\ReleaseBot_Daywalker.lua:129>
Add Release seems to be working now, though I might edit it for having an extra field for magnet links.
PS: If you could highlight line no.s while changing, that would be appreciated: I'd learn that way. I'm unable to do a side by side comparison of text...

the-master

Try changing string.find(data,  into   data.find(  in the line giving you the error
keep on sharing :)

RPGamer

It was already data.find in that line when error was showing up. I tried changing it to string.find and still the error persists. Seems to be a data type mismatch.

the-master

I'll take a look at it today, has to be a small typo or missing a sign somewhere, could be I changed a line to many to.. :(
keep on sharing :)

RPGamer

I found the error, it was a syntax error. The correct line is:
local s,e,genre,request = string.find(data, "%b<> %p%w+%s(.*)%s(.*)|$")

Now a new problem arises (lol):
I tried to add request "Person of Interest Season 5" under genre "TV Series", but gives me the following reply by hub bot:
QuoteThe genre: >> TV Series Person of Interest Season << is not available yet..
The table of request is also empty when viewed.

EDIT:

I tinkered around the code and now it's almost solved. Now the code for addreq is:
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 already 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,


The problem: only one word is being absorbed (taken into account) when reading the genre name for comparison (instead of TV Series, the function is reading it as TV) and then gives the error:
QuoteThe genre: >> TV << is not available yet..

the-master

Already noticed ;-)
Change Line 557:             local s,e,genre,request = string.find( data, "%b<> %p%w+%s(.*)%s(.*)|$")
into:            local s,e,genre,request = data:find("%b<>%s+%S+%s+(%S+)%s+(.*)|$")
and in Line 570.                                                table.insert(RelCfg.Rel,RequestUpdate)
is a small typo, it should be RelCfg.Req,RequestUpdate
The easiest way to tackle TV Series would be TV-Series because you would get the same problem at release section..
[09:00:29] <PtokaX> Genre: TV-Series is added by [NL]-Harrie to the ReleaseBot
[09:00:56] <PtokaX> Request: anything new is added by [NL]-Harrie to the RequestBot under genre: TV-Series
Theres only one small problem to tackle, if you try to show request for a section thats not used, it shows an empty list, should give error on empty section..

keep on sharing :)

SMF spam blocked by CleanTalk