eggdrop mimic script lua 5/ptokax 17.09
 

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

eggdrop mimic script lua 5/ptokax 17.09

Started by GILLIS, 09 June, 2005, 23:07:03

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GILLIS

i am lookin for a script that would mimic what the irc bot "eggdrop" does in an irc channel - in to a script for DC.

bastya_elvtars wrote a script called "egg crop" and it works great. but if a couple of features could be added to this script it would be flawless. -

have the bot always turned on

have it only announce the folders once they are uploaded to the dir

have the folders that were already announced saved to a .txt file for later access and have the folders that were already announced never announced again. example :

:: [ RLS ] :: [ Metallica Live In Austin Texas (Bootleg) 1989 RwMP3 ]:: [ Jun-09 22:48:57 ] ::

:: [ RLS ] :: [ Jazz Voice No131 Lou Rawls Stormy Monday 2004 FERiCE ]:: [ Jun-09 23:01:32 ] ::

this would show in main. and then be saved to a .txt where then can be used with a simple release script to access it for later use with a command.


-- EggCrop by bastya_elvtars
-- some code from RabidWombat and plop
-- does the same as eggdrop for IRC
-- shows new folders from an ftp root dir
-- removes reeases older than x days, this can be set

-- How does it work?
-- It makes a dirlist from the desired directory.

---- ========= CONFIG START


DirToShow="M://Movie" --  no \ on the end!!!!

PtokaXDir="I://ptokax1601"

Bot="EggCrop"

TimetoLive=1 -- in days, after which releases are considered non-new

TimeBetweenAnnounces=2 -- in hours

---- ========= CONFIG END

function Main()
	local f=io.open("getdirs.bat","w+")
		-- create a windows BAT executable that makes a dirlist
		f:write("dir \""..DirToShow.."\" /b /a:d /o:n > \""..PtokaXDir.."//scripts//ftpdirs.lst\"")
	f:close()
	SetTimer(TimeBetweenAnnounces*1000*3600)
	StartTimer()
end

function AnnounceNew()
	local list=GetList()
	local msg="\r\n----------------- # Announcing latest FTP uploaded files #----------------- \r\n"
	if table.getn(list)==0 then
		msg=msg.."\r\nNo files. :("
	else
		for k=1,table.getn(list) do
			msg=msg.."\r\n"..list[k]
		end
	end
	SendToAll(Bot,msg)
end

function OnTimer()
	AnnounceNew()
end

function GetList()
	local tbl={}
	os.execute(frmHub:GetPtokaXLocation().."/scripts/getdirs.bat")
	local f=io.open("ftpdirs.lst","r")
	if f then
		for line in f:lines() do
			table.insert(tbl,line)
		end
		f:close()
	end
	return tbl
end

function PruneList(tbl) -- not in use
	local cnt,cnt2=0,0
	local now=JulianDate(SplitTimeString(os.date("%Y. %m. %d. %X")))
	local oldest=TimetoLive*1440 -- converting days to mins
	for a,b in tbl do
		cnt=cnt+1
		local notnow=JulianDate(SplitTimeString(b))
		local diff=now-notnow
		local hours, mins= math.floor(diff) * 24 + math.floor(frac(diff) * 24), math.floor(frac(frac(diff)*24)*60)
		local usrtime=hours*60+mins
		if usrtime > oldest then
			cnt2=cnt2+1
			tbl[a]=nil
		end
		SaveList(tbl)
	end
	if cnt2~=0 then
		SendToOps(Bot,cnt.." releases were parsed, and older then "..TimetoLive.." were deleted ("..cnt2").")
	end
end

-- Split a specific Time string into its components
-- New Format: D. M. Y. HR:MN:SC" - 24hr time
-- return: Y,M,D,HR,MN,SC  HR is in 24hr string.format
function SplitTimeString(TimeString) -- 
	local D,M,Y,HR,MN,SC
	if string.find(TimeString,"/") then
		if not string.find (TimeString,"[AP]M") then
			_,_,D,M,Y,HR,MN,SC=string.find(TimeString,"([^/]+).([^/]+).(%S+) ([^:]+).([^:]+).(%S+)")
		else
			if string.find (TimeString,"PM") then
				_,_,D,M,Y,hr,MN,SC=string.find(TimeString,"([^/]+).([^/]+).(%S+) ([^:]+).([^:]+).(%S+)")
				HR=tostring(tonumber(hr)+12)
			else
				_,_,D,M,Y,HR,MN,SC=string.find(TimeString,"([^/]+).([^/]+).(%S+) ([^:]+).([^:]+).(%S+)")
			end
		end
	elseif string.find (TimeString,"%d%-%d") then
		 _,_,Y,M,D,HR,MN,SC = string.find(TimeString, "([^-]+).([^-]+).(%S+) ([^:]+).([^:]+).(%S+)")
	elseif string.find (TimeString,"%d%d.%d%d.%d%d%d%d%s+") then
		 _,_,D,M,Y,HR,MN,SC = string.find(TimeString, "([^.]+).([^.]+).(%S+). ([^:]+).([^:]+).(%S+)")
	else
		 _,_,Y,M,D,HR,MN,SC = string.find(TimeString, "([^.]+).([^.]+).([^.]+). ([^:]+).([^:]+).(%S+)")
	end
	D = tonumber(D)
	M = tonumber(M)
	Y = tonumber(Y)
	HR = tonumber(HR)
	--assert(HR < 24)
	MN = tonumber(MN)
	--assert(MN < 60)
	SC = tonumber(SC)
	--assert(SC < 60)

	assert(HR < 24);
	assert(MN < 60);
	assert(SC < 60);
	return D,M,Y,HR,MN,SC
end

function JulianDate(DAY, MONTH, YEAR, HOUR, MINUTE, SECOND) -- HOUR is 24hr string.format
	local jy, ja, jm;
	assert(YEAR ~= 0);
	assert(YEAR ~= 1582 or MONTH ~= 10 or DAY < 4 or DAY > 15);
	--The dates 5 through 14 October, 1582, do not exist in the Gregorian system!");
	if(YEAR < 0 ) then
		YEAR = YEAR + 1;
	end
	if( MONTH > 2) then 
		jy = YEAR;
		jm = MONTH + 1;
	else
		jy = YEAR - 1;
		jm = MONTH + 13;
	end
	local intgr = math.floor( math.floor(365.25*jy) + math.floor(30.6001*jm) + DAY + 1720995 );
	--check for switch to Gregorian calendar
	local gregcal = 15 + 31*( 10 + 12*1582 );
	if(DAY + 31*(MONTH + 12*YEAR) >= gregcal ) then
		ja = math.floor(0.01*jy);
		intgr = intgr + 2 - ja + math.floor(0.25*ja);
	end
	--correct for half-day offset
	local dayfrac = HOUR / 24 - 0.5;
	if( dayfrac < 0.0 ) then
		dayfrac = dayfrac + 1.0;
		intgr = intgr - 1;
	end
	--now set the fraction of a day
	local frac = dayfrac + (MINUTE + SECOND/60.0)/60.0/24.0;
	--round to nearest second
	local jd0 = (intgr + frac)*100000;
	local  jd  = math.floor(jd0);
	if( jd0 - jd > 0.5 ) then jd = jd + 1 end
	return jd/100000;
end

function frac(num)
	return num - math.floor(num);
end

if anyone can add to this. it would be greatly appritiated.

GILLIS?

SMF spam blocked by CleanTalk