Release/Request Bot
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Release/Request Bot

Started by jiten, 19 May, 2005, 15:29:07

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jiten

-------/-------------------------------------------------------------------------------------------------------------------------
-- Release or Request bot v1.0 by jiten (5/19/2005)
-- For PtokaX 0.3.3.0 build 17.02 or Higher
-------/-------------------------------------------------------------------------------------------------------------------------
Settings = {
	sBot = frmHub:GetHubBotName(),			-- Default Bot Name or -- sBot = "custombot"
	sFolder = "Releases",				-- Folder where the Release/Request database is stored
	regBot = 1,				-- 1 = Register Bot Name automatically, 0 = erm...
	Release = 1,				-- 1 = Act as Release Bot, 0 = Act as Request Bot
	autoClean = 1,				-- 1 = Auto clean Releases/Requests older than iClean, 0 = not
	iClean = 1,				-- Maximum time for releases to be stored (in days)
	iMax = 30,					-- Maximum releases/requests to be shown
	fRelease = "Release.tbl",			-- File where the Releases are stored
	AllowedProfile = { [2] = 0, [3] = 0, [-1] = 0, },	-- Other Profiles allowed to use bot commands (apart from OPs) -- 1 = yes; 0 = no
	tPrefixes = {},
}
Releases = {}
-------/-------------------------------------------------------------------------------------------------------------------------
Main = function()
	if regBot == 1 then frmHub:RegBot(Settings.sBot) end
	if not loadfile(Settings.sFolder.."/"..Settings.fRelease) then os.execute("mkdir "..Settings.sFolder) end
	if loadfile(Settings.sFolder.."/"..Settings.fRelease) then dofile(Settings.sFolder.."/"..Settings.fRelease) end
	for a,b in pairs(frmHub:GetPrefixes()) do Settings.tPrefixes[b] = 1 end
	if Settings.Release == 1 then Mode = "Release" else Mode = "Request" end
	SetTimer(1000*60*60*12) StartTimer()
end

ChatArrival = function(sUser,sData) 
	local sData = string.sub(sData,1,-2) 
	local s,e,sPrefix,cmd = string.find(sData,"%b<>%s*(%S)(%S+)")
	if sPrefix and Settings.tPrefixes[sPrefix] then
		local tCmds = {
		["add"] =	function(user,data)
				local s,e,rel,desc = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")
				if rel == nil or desc == nil then
					user:SendData(Settings.sBot,"*** Error: Type !add <"..Mode.."> ")
				elseif (string.len(rel) > 26) then
					user:SendData(Settings.sBot,"*** Error: The "..Mode.." Name can't have more than 26 characters.")
				elseif (string.len(desc) > 41) then
					user:SendData(Settings.sBot,"*** Error: The Description can't have more than 41 characters.")
				else
					table.insert( Releases, { user.sName, rel, desc, os.date(),} )
					SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
					SendToAll(Settings.sBot, user.sName.." added a new "..Mode..": "..rel..". For more details type: !show")
				end
			end,
		["del"] =	function(user,data)
				local s,e,i = string.find(data,"%b<>%s+%S+%s+(%S+)")
				if i then
					if Releases[tonumber(i)] then
						table.remove(Releases,i)
						SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
						user:SendData(Settings.sBot,Mode.." "..i..". was deleted succesfully!")
					else
						user:SendData(Settings.sBot,"*** Error: There is no "..Mode.." "..i..".")
					end
				else
					user:SendData(Settings.sBot,"*** Error: Type !add <"..Mode.."> ")
				end
			end,
		["show"] =	function(user,data)
				local s,e,begin,stop = string.find(data,"%b<>%s+%S+%s+(.+)%-(.*)")
				if begin == nil or stop == nil then
					msg = ShowReleases(table.getn(Releases), table.getn(Releases) - Settings.iMax + 1, -1, 1, false, false,"\t\t\t\t\t\t\t\tLast "..Settings.iMax.." "..Mode.."s\r\n")
					user:SendPM(Settings.sBot,msg)
				else
					msg = ShowReleases(begin, stop, 1, 1, false, false, "\t\t\t\t\t\t\tShowing "..begin.."-"..stop.." of "..table.getn(Releases).." "..Mode.."s\r\n")
					user:SendPM(Settings.sBot,msg)
				end
			end,
		["find"] =	function(user,data)
				local s,e,cat,str = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")
				if cat and str then
					user:SendPM(Settings.sBot,ShowReleases(1, table.getn(Releases), 1, 2, cat, str, "\t\t\t\t\t\t\tSearch Results of: "..cat.." "..str.."\r\n"))
				else
					user:SendData(Settings.sBot,"*** Error: Type !find  \r\n\t\t        Category can be: date, poster, release or description")
				end
			end,
		["clear"] = function(user,data)
				Releases = nil Releases = {} SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
				user:SendData(Settings.sBot,"All "..Mode.."s have been deleted successfully")
			end,
		}
		if tCmds[cmd] then
			if Settings.AllowedProfile[sUser.iProfile] == 1 or sUser.bOperator then
				return tCmds[cmd](sUser,sData), 1
			else
				return sUser:SendData(Settings.sBot,"*** Error: You are not authorized to use this command."), 1
			end
		end
	end
end

ToArrival = ChatArrival

OnTimer = function()
	if (Settings.autoClean == 1) then -- RegCleaner based
		local juliannow = jdate(tonumber(os.date("%d")), tonumber(os.date("%m")), tonumber(os.date("%Y"))) 
		local oldest, chkd, clnd, x = Settings.iClean, 0, 0, os.clock()
		for i = 1, table.getn(Releases) do
			chkd = chkd + 1 
			local s, e, month, day, year = string.find(Releases[i][4], "(%d+)%/(%d+)%/(%d+)"); 
			local julian = jdate( tonumber(day), tonumber(month), tonumber("20"..year) )
			if ((juliannow - julian) > oldest) then 
				clnd = clnd + 1
				Releases[i] = nil
				SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
			end; 
		end
		if clnd ~= 0 then SendToAll(Settings.sBot,chkd.." "..Mode.."s were processed; "..clnd.." were deleted ( "..string.format("%0.2f",((clnd*100)/chkd)).."% ) in: "..string.format("%0.4f", os.clock()-x ).." seconds.") end
	end
end

ShowReleases = function(a,z,x,mode,sCat,str,eMsg)
	local msg, border = "\r\n",string.rep("-", 250)
	msg = msg.."\t"..border.."\r\n"..eMsg.."\t"..string.rep("-- --",50).."\r\n\t\tNr.\tDate - Time\t\tPoster\t\t\t"..Mode.." - Description\r\n"
	msg = msg.."\t"..string.rep("-- --",50).."\r\n"
	for i = a, z, x do
		if Releases[i] then
			if tonumber(string.len(Releases[i][1])) < 8 then sTmp = "\t\t\t" elseif tonumber(string.len(Releases[i][1])) < 16 then sTmp = "\t\t" else sTmp = "\t" end
			if mode == 1 then
				msg = msg.."\t\t"..i..".\t"..Releases[i][4].."\t\t"..Releases[i][1]..sTmp..Releases[i][2].." - "..Releases[i][3].."\r\n"
			else
				if sCat == string.lower("poster") then where = Releases[i][1] elseif sCat == string.lower("release") or string.lower("request") then where = Releases[i][2] 
				elseif sCat == string.lower("description") then where = Releases[i][3] elseif sCat == string.lower("date") then where = Releases[i][4] end
				if string.find(where,str) then
					msg = msg.."\t\t"..i..".\t"..Releases[i][4].."\t\t"..Releases[i][1]..sTmp..Releases[i][2].." - "..Releases[i][3].."\r\n"
				end
			end
		end
	end
	msg = msg.."\t"..border.."\r\n" return msg
end

jdate = function(d, m, y)
	local a, b, c = 0, 0, 0
	if m <= 2 then y = y - 1; m = m + 12; end
	if (y*10000 + m*100 + d) >= 15821015 then a = math.floor(y/100); b = 2 - a + math.floor(a/4) end
	if y <= 0 then c = 0.75 end return math.floor(365.25*y - c) + math.floor(30.6001*(m+1) + d + 1720994 + b)
end

Serialize = function(tTable,sTableName,hFile,sTab)
	sTab = sTab or "";
	hFile:write(sTab..sTableName.." = {\n");
	for key,value in tTable do
		if (type(value) ~= "function") then
			local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
			if(type(value) == "table") then
				Serialize(value,sKey,hFile,sTab.."\t");
			else
				local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
				hFile:write(sTab.."\t"..sKey.." = "..sValue);
			end
			hFile:write(",\n");
		end
	end
	hFile:write(sTab.."}");
end

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

Star

Nice. Tnx jiten

//Star

jiten

QuoteOriginally posted by Star
Nice. Tnx jiten

//Star
You're welcome. Btw, every request and comment is welcome. Just need more free time to fill them all  ;)
QuoteDid u forget to add the Prefixes for the commands?
Nope, I'm using the ones you chose in PtokaX - Options tab.
QuoteError msg (can't add more then 100 characters) I only added 40 characters. =)
It will be optimized.
QuoteCan u add Description in a separate column?
The releases and descriptions' size are variable and when using the show command they may not appear with the correct tabbing. But, I'll think about it.
QuoteAdd a Link column (and settings if request the link or not in the !add command)
Change the !clear command to !delall (!clear not work if use RC) i can change it but maybe others can't.
And now one last thing  users/reg cant use !show etc... But if i set users/reg = 1, then they can use !del to. So separate profile handeling.
Add a command to set self cleaner function on/off (OP only)
Sure.
QuoteTurn the list to 1,2,3... etc. (Now it's ...3,2,1)
This is because the releases/request are shown from the most recent to the oldest.
QuoteThe del function: add so i can write !del aswell. (Not only !del )
Well, can't do it. The way it is now it's the most simple and efficient one :D
QuoteAdd a +reqdone function so users can use it, and a notice in main shows. e.g. got
Can you explain this better?

Best regards

Star

#3
Quote
QuoteDid u forget to add the Prefixes for the commands?
Nope, I'm using the ones you chose in PtokaX - Options tab.
Well. I cant get it to work without  edit the line and set some prefixes.
EDIT: I restart the hub. And now it works. Tnx


Quote
QuoteCan u add Description in a separate column?
The releases and descriptions' size are variable and when using the show command they may not appear with the correct tabbing. But, I'll think about it.
Can u use the column-stuff that nErBoS wrote? It's not perfect. But OK.


Quote
QuoteThe del function: add so i can write !del aswell. (Not only !del )
Well, can't do it. The way it is now it's the most simple and efficient one :D
It's good if u want to delete one release. But if u want to delete more then one release it's not so good.
Then u have to type !show between every time u delete a release. Cause the number of the release is change when u delete one.


Quote
QuoteAdd a +reqdone function so users can use it, and a notice in main shows. e.g. got
Can you explain this better?
Sure. It's almost the same as the !del command.
The different is that non op can use this command to.
And with this command the script write " got "  in main, for all in the hub.
And then delete the request from the list.


//Tnx Star

Star

#4
And some other things.

- Add the commands to the settings.
cmd1 = "add"
cmd2 = "relhelp", ....
local tCmds = { [Settings.cmd1]
And here to
user:SendData(Settings.sBot,"*** Error: Type "..sPrefix..Settings.cmd1.." <"..Mode.."> " )

- And only one search word needed , and it search in both description and release/request. (Now it's !find )

- *** Error: The Description can't have more than 41 characters.
41!! huh :)
The numbers in the list look nice but take space. So, get rid of the numbers and make som space here :)

- And for the autocleaner function, add a msg to main when it cleans: The "..Mode.." cleaner delete x "..Mode.." from the list. hey where more then "..iClean.." days old.
And a on/off function in Settings for that.

Example look:
Works for 1024x768 and up, and DC standard font (MS Sans Serif, normal, 8 ), and look bether in DC then  here :)
  ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
									Last 30 Releases									
  -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
  Date - Time	 Poster		Type	 Description							Link
  -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
  5/20/05 10:37:30	 [SU]username__	DVD	 Test								[URL]www.blablabla.com[/URL]
  5/20/05 11:59:31	 [SU]user		TV.Show	 Release								http:://tsdlknm.com/ksdnfgjsdn/l,sndgkjfdngndf/snfjdngn.html
  5/20/05 11:59:32	 [SU]user		TV.Show	 Release								http:://tsdlknm.com/ksdnfgjsdn/l,sndgkjfdngndf/snfjdngn.html
  5/20/05 11:59:33	 [SU]user		TV.Show	 Release								http:://tsdlknm.com/ksdnfgjsdn/l,sndgkjfdngndf/snfjdngn.html
  5/20/05 11:59:34	 [SU]user		TV.Show	 Release								http:://tsdlknm.com/ksdnfgjsdn/l,sndgkjfdngndf/snfjdngn.html
  5/20/05 11:59:35	 [SU]user		TV.Show	 123456789,123456789,123456789,123456789,123456789,123456789_62	http:://tsdlknm.com/ksdnfgjsdn/l,sndgkjfdngndf/snfjdngn.html
  5/20/05 11:59:36	 [SU]user		TV.Show	 __________________________________________________________60	http:://tsdlknm.com/ksdnfgjsdn/l,sndgkjfdngndf/snfjdngn.html
  ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Love it. Tnx Star

jiten

QuoteOriginally posted by Star
- Add the commands to the settings.
cmd1 = "add"
cmd2 = "relhelp", ....
local tCmds = { [Settings.cmd1]
And here to
user:SendData(Settings.sBot,"*** Error: Type "..sPrefix..Settings.cmd1.." <"..Mode.."> " )
And for the autocleaner function, add a msg to main when it cleans: The "..Mode.." cleaner delete x "..Mode.." from the list. hey where more then "..iClean.." days old.
It's in my todo list ;)  
Quote- And only one search word needed , and it search in both description and release/request. (Now it's !find )
Do you mean searching without the "category"?
QuoteThe numbers in the list look nice but take space. So, get rid of the numbers and make som space here :)
And a on/off function in Settings for that.
Fixed.

Best regards

Star

QuoteOriginally posted by jiten
Do you mean searching without the "category"?
Yes. Like this:
 *** Error: Type !find
              String can be: date, poster, release, description or link

And about the date. Can u put something in settings to so I can change the order of the yyyy mm dd (We have other standards here)

Tnx Star

jiten

Added almost every request. Have fun...
-------/-------------------------------------------------------------------------------------------------------------------------
-- Release or Request bot v1.1 by jiten (5/20/2005)
-- For PtokaX 0.3.3.0 build 17.02 or Higher
-------/-------------------------------------------------------------------------------------------------------------------------
Settings = {
	sBot = frmHub:GetHubBotName(),			-- Default Bot Name or -- sBot = "custombot"
	iVer = "1.1",				-- Script Version
	sFolder = "Releases",				-- Folder where the Release/Request database is stored
	regBot = 1,				-- 1 = Register Bot Name automatically, 0 = erm...
	Release = 0,				-- 1 = Act as Release Bot, 0 = Act as Request Bot
	autoClean = 1,				-- 1 = Auto clean Releases/Requests older than iClean, 0 = not
	iClean = 7,				-- Maximum time for releases to be stored (in days)
	iMax = 30,					-- Maximum releases/requests to be shown
	fRelease = "Release.tbl",			-- File where the Releases are stored
	RelSize = 18,				-- Release's size
	DescSize = 20,				-- Description's size
	pCleaner = 1,				-- 1 = Sends cleaner actions to all; 0 = doesn't
	-- Commands -----------------------------------------------------------------------------
	addCmd = "add", delCmd = "del", showCmd = "show", findCmd = "find",
	delAllCmd = "delall", helpCmd = "relhelp", clnCmd = "cleaner", rDoneCmd = "reqdone",
	-----------------------------------------------------------------------------------------
	tPrefixes = {},
}
Releases = {}
-------/-------------------------------------------------------------------------------------------------------------------------
Main = function()
	if regBot == 1 then frmHub:RegBot(Settings.sBot) end
	if not loadfile(Settings.sFolder.."/"..Settings.fRelease) then os.execute("mkdir "..Settings.sFolder) end
	if loadfile(Settings.sFolder.."/"..Settings.fRelease) then dofile(Settings.sFolder.."/"..Settings.fRelease) end
	for a,b in pairs(frmHub:GetPrefixes()) do Settings.tPrefixes[b] = 1 end
	if Settings.Release == 1 then Mode = "Release" else Mode = "Request" end
	SetTimer(1000*60*60*12) StartTimer()
end

ChatArrival = function(sUser,sData) 
	local sData = string.sub(sData,1,-2) 
	local s,e,sPrefix,cmd = string.find(sData,"%b<>%s*(%S)(%S+)")
	if sPrefix and Settings.tPrefixes[sPrefix] then
		local tmp = "\r\n\t"..string.rep("-", 220)
		local sOpHelpOutput = tmp.."\r\n\t\t\t\t\t\tRelease/Request v."..Settings.iVer.." bot by jiten\t\t\t("..Mode.." Mode)\r\n\t"..string.rep("-",220).."\r\n\tOperator Commands:".."\r\n\r\n"
		local sHelpOutput = tmp.."\r\n\tNormal Commands:".."\r\n\r\n"
		local tCmds = {
		[Settings.addCmd] = {	function(user,data)
				local s,e,rel,desc = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)") local s,e,link = string.find(data,"%b<>%s+%S+%s+%S+%s+%S+%s+(%S+)")
				if (rel == nil or desc == nil) then
					user:SendData(Settings.sBot,"*** Error: Type "..sPrefix..Settings.addCmd.." <"..Mode..">   (link is optional)")
				else
					if (string.len(rel) > Settings.RelSize) then
						user:SendData(Settings.sBot,"*** Error: The "..Mode.." Name can't have more than "..Settings.RelSize.." characters.")
					elseif (string.len(desc) > Settings.DescSize) then
						user:SendData(Settings.sBot,"*** Error: The Description can't have more than "..Settings.DescSize.." characters.")
					else
						if link == nil then link = "(empty)" end
						table.insert( Releases, { user.sName, rel, desc, os.date(), link, } )
						SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
						SendToAll(Settings.sBot, user.sName.." added a new "..Mode..": "..rel..". For more details type: "..sPrefix..Settings.showCmd)
					end
				end
			end, 1, "\tAdds a "..Mode..". Example: "..sPrefix..Settings.addCmd.." Blade3 Movie [URL]http://www.blade.com[/URL] (link is optional)", },
		[Settings.delCmd] = {	function(user,data)
				local s,e,begin,stop = string.find(data,"%b<>%s+%S+%s+(.+)%-(.*)")
				if not (begin == nil and stop == nil) then
					ShowReleases(begin, stop, 1, 3, false,"")
					SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
				else
					local s,e,i = string.find(data,"%b<>%s+%S+%s+(%S+)")
					if i then
						if Releases[tonumber(i)] then
							table.remove(Releases,i)
							SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
							user:SendData(Settings.sBot,Mode.." "..i..". was deleted succesfully!")
						else
							user:SendData(Settings.sBot,"*** Error: There is no "..Mode.." "..i..".")
						end
					else
						user:SendData(Settings.sBot,"*** Error: Type "..sPrefix..Settings.delCmd.." <"..Mode.." number>")
					end
				end
			end, 0, "\tDeletes single or multiple "..Mode.."s. Example: "..sPrefix..Settings.delCmd.." 15; "..sPrefix..Settings.delCmd.." 1-2", },
		[Settings.showCmd] = { function(user,data)
				local s,e,begin,stop = string.find(data,"%b<>%s+%S+%s+(.+)%-(.*)")
				if begin == nil or stop == nil then
					msg = ShowReleases(table.getn(Releases), table.getn(Releases) - Settings.iMax + 1, -1, 1, false, "\t\t\t\t\t\t\t\tLast "..Settings.iMax.." "..Mode.."s\r\n")
					user:SendPM(Settings.sBot,msg)
				else
					msg = ShowReleases(begin, stop, 1, 1, false, "\t\t\t\t\t\t\tShowing "..begin.."-"..stop.." of "..table.getn(Releases).." "..Mode.."s\r\n")
					user:SendPM(Settings.sBot,msg)
				end
			end, 1, "\tShows all/group of "..Mode.."s. Example: "..sPrefix..Settings.showCmd.."; "..sPrefix..Settings.showCmd.." 10-15" },
		[Settings.findCmd] = { function(user,data)
				local s,e,str = string.find(data,"%b<>%s+%S+%s+(%S+)")
				if str then
					user:SendPM(Settings.sBot,ShowReleases(1, table.getn(Releases), 1, 2, str, "\t\t\t\t\t\t\tSearch Results of: "..str.."\r\n"))
				else
					user:SendData(Settings.sBot,"*** Error: Type "..sPrefix..Settings.findCmd.."  \r\n\t\t        Category can be: date, poster, release or description")
				end
			end, 1, "\tFind a "..Mode.." by any category (date, poster, release, description, link). Example: "..sPrefix..Settings.findCmd.." jiten", }, 
		[Settings.delAllCmd] = { function(user,data)
				Releases = nil Releases = {} SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
				user:SendData(Settings.sBot,"All "..Mode.."s have been deleted successfully")
			end, 0, "\tDeletes all "..Mode.."s", },
		[Settings.helpCmd] = { function(user)
				if user.bOperator then
					user:SendData(Settings.sBot, sOpHelpOutput..sHelpOutput.."\t"..string.rep("-",220));
				else
					user:SendData(Settings.sBot, sHelpOutput.."\t"..string.rep("-",220));
				end
			end, 1, "\tDisplays this help message.", },
		[Settings.clnCmd] = { function(user,data,mode)
				local s,e,stat = string.find(data,"%b<>%s+%S+%s+(%S+)")
				if stat == "on" then StartTimer() user:SendData(Settings.sBot,"The "..Mode.."s automatic cleaner has been enabled.")
				elseif stat == "off" then StopTimer() user:SendData(Settings.sBot,"The "..Mode.."s automatic cleaner has been disabled.")
				else user:SendData(Settings.sBot,"*** Error: Type "..sPrefix..Settings.clnCmd.." ") end
			end, 0, "\tSet "..Mode.."s automatic cleaner status. Example: "..sPrefix..Settings.clnCmd.." off; "..sPrefix..Settings.clnCmd.." on", },
		[Settings.rDoneCmd] = { function(user,data)
				local s,e,i = string.find(data,"%b<>%s+%S+%s+(%S+)")
				if Mode == "Request" then
					if i then
						if Releases[tonumber(i)] then
							if Releases[tonumber(i)][1] == user.sName then
								table.remove(Releases,i)
								SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
								SendToAll(Settings.sBot,user.sName.." got the "..Mode.." "..i.."!")
							else
								user:SendData(Settings.sBot,"*** Error: You can't complete "..Mode.." "..i..". as you aren't its poster.")
							end
						else
							user:SendData(Settings.sBot,"*** Error: There is no "..Mode.." "..i..".")
						end
					else
						user:SendData(Settings.sBot,"*** Error: Type "..sPrefix..Settings.delCmd.." <"..Mode.."> ")
					end
				else
					user:SendData(Settings.sBot,"*** Error: This command is only available in Request Mode.")
				end
			end, 1, "\tCompletes a previous Request (only available in Request Mode). Example: "..sPrefix..Settings.rDoneCmd.." 15", },
		}
		for sCmd, tCmd in tCmds do
			if(tCmd[2] == 1) then sHelpOutput   = sHelpOutput.."\t"..sPrefix..sCmd.."\t "..tCmd[3].."\r\n";
			else sOpHelpOutput = sOpHelpOutput.."\t"..sPrefix..sCmd.."\t "..tCmd[3].."\r\n"; end
		end
		if tCmds[cmd] then
			if tCmds[cmd][2] == 1 or sUser.bOperator then return tCmds[cmd][1](sUser,sData), 1
			else return sUser:SendData(Settings.sBot,"*** Error: You are not authorized to use this command."), 1 end
		end
	end
end

ToArrival = ChatArrival

OnTimer = function()
	if (Settings.autoClean == 1) then -- RegCleaner based
		local juliannow = jdate(tonumber(os.date("%d")), tonumber(os.date("%m")), tonumber(os.date("%Y"))) 
		local oldest, chkd, clnd, x = Settings.iClean, 0, 0, os.clock()
		for i = 1, table.getn(Releases) do
			chkd = chkd + 1 
			local s, e, month, day, year = string.find(Releases[i][4], "(%d+)%/(%d+)%/(%d+)"); 
			local julian = jdate( tonumber(day), tonumber(month), tonumber("20"..year) )
			if ((juliannow - julian) > oldest) then 
				clnd = clnd + 1
				Releases[i] = nil
				SaveToFile(Settings.sFolder.."/"..Settings.fRelease,Releases,"Releases")
			end; 
		end
		if clnd ~= 0 and Settings.pCleaner == 1 then SendToAll(Settings.sBot,chkd.." "..Mode.."s were processed. "..clnd.." "..Mode.."s were deleted as they were more than "..Settings.iClean.." days old. ( "..string.format("%0.2f",((clnd*100)/chkd)).."% ) in: "..string.format("%0.4f", os.clock()-x ).." seconds.") end
	end
end

ShowReleases = function(a,z,x,mode,str,eMsg)
	local msg, border = "\r\n",string.rep("-", 250)
	msg = msg.."\t"..border.."\r\n"..eMsg.."\t"..string.rep("-- --",50).."\r\n\t   Nr.\tDate - Time\t\tPoster\t\t"..Mode.."\t\tDescription\tLink\r\n"
	msg = msg.."\t"..string.rep("-- --",50).."\r\n"
	for i = a, z, x do
		if Releases[i] then
			DoTabs = function(cat) local sTmp = "" if tonumber(string.len(cat)) < 9 then sTmp = "\t\t" elseif tonumber(string.len(cat)) < 16 then sTmp = "\t" else sTmp = "\t" end return sTmp end
			if mode == 1 then
				msg = msg.."\t   "..i..".\t"..Releases[i][4].."\t\t"..Releases[i][1]..DoTabs(Releases[i][1])..Releases[i][2]..DoTabs(Releases[i][2])..Releases[i][3]..DoTabs(Releases[i][3])..Releases[i][5].."\r\n"
			elseif mode == 2 then
				where = Releases[i][1]..Releases[i][2]..Releases[i][3]..Releases[i][4]..Releases[i][5]
				if string.find(where,str) then
					msg = msg.."\t   "..i..".\t"..Releases[i][4].."\t\t"..Releases[i][1]..DoTabs(Releases[i][1])..Releases[i][2].."\t\t"..Releases[i][3]..DoTabs(Releases[i][3])..Releases[i][5].."\r\n"
				end
			elseif mode == 3 then
				Releases[i] = nil
			end
		end
	end
	msg = msg.."\t"..border.."\r\n" return msg
end

jdate = function(d, m, y)
	local a, b, c = 0, 0, 0
	if m <= 2 then y = y - 1; m = m + 12; end
	if (y*10000 + m*100 + d) >= 15821015 then a = math.floor(y/100); b = 2 - a + math.floor(a/4) end
	if y <= 0 then c = 0.75 end return math.floor(365.25*y - c) + math.floor(30.6001*(m+1) + d + 1720994 + b)
end

Serialize = function(tTable,sTableName,hFile,sTab)
	sTab = sTab or "";
	hFile:write(sTab..sTableName.." = {\n");
	for key,value in tTable do
		if (type(value) ~= "function") then
			local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
			if(type(value) == "table") then
				Serialize(value,sKey,hFile,sTab.."\t");
			else
				local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
				hFile:write(sTab.."\t"..sKey.." = "..sValue);
			end
			hFile:write(",\n");
		end
	end
	hFile:write(sTab.."}");
end

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

Dessamator

hmm well done m8, :)
Ignorance is Bliss.

Pingelmonster

#9
Syntax ...reaublad\PtokaX 0.3.3.0 16.09\scripts\releasebot.lua:59: attempt to call method `GetPrefixes' (a nil value)

The latest scriptversion (1.1) gave me this error...

My bot is a releasebot:
Release = 1,            -- 1 = Act as Release Bot, 0 = Act as Request Bot
[NL]SimpleDC
simpledchub.no-ip.info

jiten

#10
QuoteOriginally posted by Pingelmonster
Syntax ...reaublad\PtokaX 0.3.3.0 16.09\scripts\releasebot.lua:59: attempt to call method `GetPrefixes' (a nil value)

The latest scriptversion (1.1) gave me this error...

My bot is a releasebot:
Release = 1,            -- 1 = Act as Release Bot, 0 = Act as Request Bot
From what I can see, you are using PtokaX 16.09 and this one is:
-- For PtokaX 0.3.3.0 build 17.02 or Higher
Cheers

Pingelmonster

Oh my god....I am very stupid:P...not reading at all...thnqs:P
[NL]SimpleDC
simpledchub.no-ip.info

Star

Nice.. Thanks jiten :)

Dinok

Syntax ...\PtokaX\scripts\releasebot.lua:12: function arguments expected near `='

I use PtokaX 0.3.3.0 build 17.08 , scriptversion 1.1

jiten

QuoteOriginally posted by Dinok
Syntax ...\PtokaX\scripts\releasebot.lua:12: function arguments expected near `='

I use PtokaX 0.3.3.0 build 17.08 , scriptversion 1.1
Probably you didn't copy well the script.
The code to copy is the one between the horizontal lines (excluding them).

Cheers

Dinok

All have earned.
I, fool, did not think that one line can so much signify.  :O

Star

I have been thinking and testing the scripts functions
And I have came to this results and requests.
Hope u can help me with it.


- !Find results don't match the !Show results. The columns are different.
- !Find command don't work so well. It's capitalsensitive.
- Cleaner function, change it so it says "Cleaner status: ON" in the help window. Or in the Release Show windows
- And for the appearance, you can look in my other post. :)
- Get rid of the numbers! They only take space
- Add a command to set the link optional or not. e.g. !linkrequire
- Turn the list to 1,2,3... etc. (Now it's ...3,2,1)
- Add so: if Request mode use /Request, and if Release mode use /Release, or different files, so I can have 1rel and 1req script started at the same time.
- I can add several request/releases with the same namn. The bot should say that the release/request already exist.
- Change the name "Link" to "Info Link"

- *** Error: You can't complete Request 12. as you aren't its poster.
U got me wrong here m8. User1 request a release, and if user2 get the release he can use !reqdone. As it is now, only the poster can use that command.

- Wouldn't be nice if the script could handle deleating and filling reqs from the release name istead of the IDs?
Have used ID databases before and well me and others have to many times deleated the wrong IDs (specially if more then one is editing it at the same time)


Keep up the good work m8.
//Star

jiten

QuoteOriginally posted by Star
!Find results don't match the !Show results. The columns are different.
Can you explain this better?
Quote!Find command don't work so well. It's capitalsensitive.
Will be fixed ;)
QuoteCleaner function, change it so it says "Cleaner status: ON" in the help window. Or in the Release Show windows.
I can add several request/releases with the same namn. The bot should say that the release/request already exist.
Change the name "Link" to "Info Link".
It's on my todo list.
QuoteWouldn't be nice if the script could handle deleating and filling reqs from the release name istead of the IDs?
And for the appearance, you can look in my other post. :)
Get rid of the numbers! They only take space
Will think about these and (maybe) add them.
Btw, the numbers are needed because the deleting still goes by ID.
QuoteAdd a command to set the link optional or not. e.g. !linkrequire
I'm thinking about making some changes to the settings (with time).
QuoteTurn the list to 1,2,3... etc. (Now it's ...3,2,1)
As I explained you earlier, the releases are listed from the most recent to the oldest, so, the recent ones logically will have a bigger ID than the others.
QuoteAdd so: if Request mode use /Request, and if Release mode use /Release, or different files, so I can have 1rel and 1req script started at the same time.
Do you mean when the bot is in Release Mode it saves to a file, and when it's on the other one, saves to another? Or being able do use both Modes at the same time and two different files?
QuoteUser1 request a release, and if user2 get the release he can use !reqdone. As it is now, only the poster can use that command.
If you want it this way, any user will be able to "delete" the requests/releases, as, the reqdone does the same as the delete command. It's not that safe if I remove that condition.

Best regards,

jiten

Star

QuoteOriginally posted by jiten Can you explain this better?
Sure. If u add some releases to the list. Then type !show and then type !find it don't look the same with the tabbing.

QuoteWill be fixed ;)
It's on my todo list.
Thank U very much! :)

QuoteWill think about these and (maybe) add them.
I'm hoping u do :)

QuoteBtw, the numbers are needed because the deleting still goes by ID.
Well, if u change so the "deleting",  "show" and "find" goes on the release name insted of a IDnumber u won't need it anymore. And as I wrote earlier, ID deleting only cause problems.

Thats ONE of the resons we want the deleting to go on NAME instead of ID. So we can get rid of the numers.

QuoteAs I explained you earlier, the releases are listed from the most recent to the oldest, so, the recent ones logically will have a bigger ID than the others.
U get me wrong here(I think). The releases should be listed from the most oldest to the recent.

They should of course remain ther own ID number. (If u gone keep the numbers) ;)

QuoteDo you mean when the bot is in Release Mode it saves to a file, and when it's on the other one, saves to another? Or being able do use both Modes at the same time and two different files?
I mean: add so it use different folders in respective modes
So
"REL_bot_v1.1.lua" use /RELEASE    <--Release Mode
"REQ_bot_v1.1.lua" use /REQUEST  <--Request Mode

QuoteIf you want it this way, any user will be able to "delete" the requests/releases, as, the reqdone does the same as the delete command. It's not that safe if I remove that condition.
That's the hole ide with the +reqdone command. It's useless to request a release if u can get it yourself.
And they cant delete a release when the script is in release mode as this command is disabled in release mode anyway.

In my case I trust my users to not delete requests they dont have. But if that's the problem maybe u can add a on/off function in settings for that to.


Thanks
// Star

jiten

-------/-------------------------------------------------------------------------------------------------------------------------
-- Release or Request bot v1.2 by jiten (5/21/2005)
-- For PtokaX 0.3.3.0 build 17.02 or Higher
-------/-------------------------------------------------------------------------------------------------------------------------
Main Commands:

[*]	!show		Shows all/group of Requests. Example: !show; !show 10-15
[*]	!reqdone		Fills up a previous Request (only available in Request Mode). Example: !reqdone 
[*]	!find	 	Find a Request by any category (date, poster, release, description, link). Example: !find jiten
[*]	!add	 	Adds a Request. Example: !add Blade3 Movie [URL]http://www.blade.com[/URL] (Link can be required or not)
[*]	!delall	 	Deletes all Requests
[*]	!del	 	Deletes single or multiple Requests. Example: !del ; !del 1-2
[*]	!setup	 	Configure this bot. Commands: !setup  

Some features:

[*]	Ability to switch from Release to Request mode (vice-versa)
[*]	Releases/Requests older than x Days are automatically deleted (optional)
[*]	Two separate databases: one for the Requests and the other for the Releases

Grab it HERE.

Star

#20
First of all.. Thank u for taking the numbers off the list and added NAME handeling!
Now it's start's to get realy nice m8.

Here's some small things:

-  *** Error: Type !setup
Should't it say: *** Error: !setup
- From !relhelp:   !setup       Configure this bot. Commands: !setup   <---Change "mode" to "release"

-  *** Erorr: There's already a Release named Test.    <--- Erorr :)
-  *** Error: Type !find  <--- Is the category steel there, or did I miss something?
- Can you add "!showall" command? (Or "!show all" )
- If u use one config.tbl, then I can't run two versions at the same time (two lua files at the same time). Make one config file for each mode?
- Get rid of the config.tbl status in the !show results. (Sorry m8 ;) (But keep it in !relhelp)
- If the mode is set to Request. I get Syntax error of I type "!find".  Release.Request.v12.lua:97: bad argument #1 to `getn' (table expected, got nil)
- Tiny thing: change the ( to [ in this: (Mode / Cleaner / Link): (on / on / off) and (Release Mode). It look better.
- This don't seem to work: if loadfile(Settings.rFolder.."/"..Settings.fRequest) then dofile(Settings.rFolder.."/"..Settings.fRequest) end
Or I have just get it wrong :)

- I get a little confused in !show results. The "Release"="Type" right? and the "Description" = "Release_Name" right?
I would say that it should be the other way around.
And this the other way around to : RelSize = 20, DescSize = 50



And now for the big thing.
- I'm begging u to use the tabbig stuff Nerbos wrote. It works good! Or write your own :)
- Can u make the list a little more wide? I?s a little hard to get all the things to fit. Well, alot wider I would say. The releases are, in almost every case wider then that.
I have made a suggestion in a previous post.  What do u think about that?

EDIT: - Could u change so Description comes before Releases in the list?
- If u type !find there's one tabbing more in the "Poster" column.
- Can u set all Examples, in the !relHelp menu, in one column. It Looks good


v1.2 was real good. Thanks m8
//Star

jiten

QuoteOriginally posted by Star
Thank u for taking the numbers off the list and added NAME handeling!
I'm glad you like it ;)
Quote*** Erorr: There's already a Release named Test.
Typos will be fixed and other things I forgot to remove. That's the problem of fast editing. :D
QuoteCan you add "!showall" command?
Get rid of the config.tbl status in the !show results. TypeSize = 20, DescSize = 50
I'm begging u to use the tabbig stuff Nerbos wrote.
Can u make the list a little more wide?
Could u change so Description comes before Releases in the list?
If u type !find there's one tabbing more in the "Poster" column.
Tiny thing: change the ( to [ in this: (Mode / Cleaner / Link): (on / on / off) and (Release Mode). It look better.
Can u set all Examples, in the !relHelp menu, in one column.
I get a little confused in !show results.
It's on my todo list.
Quoteargument #1 to `getn' (table expected, got nil)
- This don't seem to work: if loadfile(Settings.rFolder.."/"..Settings.fRequest) then dofile(Settings.rFolder.."/"..Settings.fRequest) end
This error happened because you were using the commands without having any request saved (so there was no file). Bug fixed anyway ;)
QuoteMake one config file for each mode?
After releasing the v1.3, I'll show you a way to run request and release at the same time (with 2 .lua files). Currently, I won't change it so that only one .lua handles both at the same time.

Cheers

Star

#22
QuoteOriginally posted by jiten
After releasing the v1.3, I'll show you a way to run request and release at the same time (with 2 .lua files). Currently, I won't change it so that only one .lua handles both at the same time.
Thats was what I meant (Running 2 .lua files). Maybe could be fix with two config files in /Request respective /Release folder.
Example:
If mode Request > /Request/Config.tbl
If mode Release > /Release/Config.tbl
Or split the code in the Config.tbl file somehow.

- Could u add a setting to change the date order?
Settings>
DateOrder = "yy/mm/dd"
This is because we have different order standars here. U have mm/dd/yy. We have yy/mm/dd or yyyy/mm/dd
- And could u add 20 before the date year? Ex: 2005/05/22

And then I have a id?.
- Could u add in settings:
Settings >
RelCommand = "rel"
ReqCommand = "req"
If the script is in REL mode it add "rel" before the commands like this: !reladd, !relshow, !reldel...
If the script is in REQ mode it add "req" before the commands like this: !reqadd, !reqshow, !reqdel...
What du u think about this?
I hope u understand what I write. Becous some times I don't understand it my self :)

EDIT:  Forget the last thing. I think I have the energy to change the commands on my own. :)

Thanks
//Star

jiten

QuoteOriginally posted by Star
Thats was what I meant (Running 2 .lua files). Maybe could be fix with two config files in /Request respective /Release folder.
It'll be something like that, but, will be apart from the release.
QuoteCould u add a setting to change the date order?
I don't think it's necessary. I'd have to change all the cleaning code and other parts of the scripts to be compatible with that.
QuoteCould u add in settings: Settings > RelCommand = "rel"
ReqCommand = "req"
Nice to know that you'll manage to do it :D

Best regards

Star

Cant get the bot to register.

Change this?
if regBot == 1 then frmHub:RegBot(Settings.sBot) end
to
if Settings.regBot == 1 then frmHub:RegBot(Settings.sBot) end

/Star

SMF spam blocked by CleanTalk