FTP Upload log feed 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

FTP Upload log feed Bot?

Started by GILLIS, 16 October, 2005, 00:34:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GILLIS

Im looking for a script that can read a .txt log file for new threads. the script would have to find specific text such as "MKD" which is the command for "make new dir"
everytime it finds this command it could announce it in the hubs main/or PM.

the script could also have an "add text" "remove text" feature to the thread that gets announced in the hubs main/pm.

example full thread from ftp upload log file.."[2] Sat 15Oct05 19:27:09 - (000082) MKD /=MP3=/1015/VA-Dirty_Money_And_Big_Mike-The_Come_Up_DVD_Vol._7_(Da_Freestyle_Ed.)-(Bootleg)-2005-C4"

thread read from upload log and transferd to the hubs main/pm - "/=MP3=/1015/VA-Dirty_Money_And_Big_Mike-The_Come_Up_DVD_Vol._7_(Da_Freestyle_Ed.)-(Bootleg)-2005-C4"

if this is possible this would be a great script. im sure tons of people could use this script in their hubs :)

please get back at me..

GILLIS?
Owner/founder BeaveR-BanK's FinesT?

GILLIS

could someone please help me out on this one. it is a very simple script compaired to some of the other ones..

id really appritiate it if someone even gave a crack at it :)

please reply. thanks again..

GILLIS

GILLIS

heres the script :) thanks so much. hopfully someone can help.

-- -- 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="E://=MP3=//1021" --  no \ on the end!!!!

PtokaXDir="C:/ptokax"

Bot="?BBF-PRED?"

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

TimeBetweenAnnounces=1 -- 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.RELEASES.FOR.TODAY]-[?BBF-0DAY-MP3-DUMP?1?] # ================= # \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

SMF spam blocked by CleanTalk