SearchCount-V.1.3
 

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

SearchCount-V.1.3

Started by Dessamator, 15 May, 2005, 14:52:37

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dessamator

--SearchCount-V.1.3
--30.9.03 by c h i l l e r
--lua 5 by Dessamator
-- added tth filter

--To enable right click write --> true
Rightclick = false
--This number stands for the maximum of shown items
Max1 = 100
--This number stands for the maximum of stored items
Max2 = 1000
--Timespan in minutes between each saving
Max3 = 60

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

File1 = "txt/TopSearches.txt"
SearchItems={}

sec = 1000 
min = 60 * sec 

function Main()
local handle = io.open(File1,"r")
	if handle then 
		dofile(File1)
	else
		io.output(File1) 
		io.write("")          -- creates the file
	        io.output()
	end
	SetTimer(Max3 * min ) 
	StartTimer()
end

--user command(right click)
function NewUserConnected(user)
	if Rightclick == true then
		user:SendData("$UserCommand 1 3 Search logger\\Most Wanted $<%[mynick]> !mostwanted||")
		if user.bOperator then
			user:SendData("$UserCommand 1 3 Search logger\\Clear Logs $<%[mynick]> !clrslog||") 
		end
	end
end
OpConnected = NewUserConnected
--
function OnExit()
	OnTimer()
end

function OnTimer()
	SaveToFile(File1,SearchItems, "SearchItems")
end

function ChatArrival(curUser, data)
	data = string.sub(data,1,string.len(data)-1)
	s,e,cmd = string.find(data, "%b<>%s+(%S+)")
	if cmd=="!mostwanted" then
		curUser:SendData("\r\n".."\t\t\THE    MOST   WANTED\r\n"..
		"\t"..string.rep("-",70).."\r\n"..
		"\t\- - HITS - -\t\- - ITEM - -\r\n"..
		TopSearches().."\r\n"..
		"\t"..string.rep("-",70))
		return 1
	elseif cmd=="!clrslog" and curUser.bOperator then
		SearchItems="nil"
		SearchItems={}
		curUser:SendData("Searchlogger","All previous searches have been purged from the logs")
		return 1
	end
end
function SearchArrival(User, data)
	local _,_,sestring = string.find( data, "$Search %S+%s%S+?%S+?%S+?%S+?(.*)" )
	local s,e, findtth = string.find(sestring,"(TTH%:)")
	if sestring and string.len(sestring) < 50 and not(findtth) then
		sestring = string.sub(sestring,1,string.len(sestring)-1)
		sestring = string.lower(sestring)
		sestring = string.gsub(sestring, "$+", " ")
		if SearchItems[sestring]==nil then
			SearchItems[sestring]=1
		else
			SearchItems[sestring]=SearchItems[sestring]+1
		end
	end
end
------------------------------------------------------------------------------------------------------------------
function TopSearches()
	local TCopy={}
	for i,v in SearchItems do
		table.insert( TCopy, {tonumber(v),i} )
	end
	table.sort( TCopy, function(a, b) return (a[1] > b[1]) end)
	local msg ="\r\n" 
	for i = 1,Max1 do
		if TCopy[i] then
			msg = msg.."                     "..TCopy[i][1].."                    "..TCopy[i][2].."\r\n"
		end
	end
	local TCopy={}
	return msg
end
------------------------------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, sTab) 
        assert(tTable, "tTable equals nil"); 
        assert(sTableName, "sTableName equals nil"); 
 
        assert(type(tTable) == "table", "tTable must be a table!"); 
        assert(type(sTableName) == "string", "sTableName must be a string!"); 
 
        sTab = sTab or ""; 
        sTmp = "" 
 
        sTmp = sTmp..sTab..sTableName.." = {\n" 
 
        for key, value in tTable do 
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key); 
 
                if(type(value) == "table") then 
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t"); 
                else 
                        local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value); 
                        sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue 
                end 
 
                sTmp = sTmp..",\n" 
        end 
 
        sTmp = sTmp..sTab.."}" 
        return sTmp 
end 
 
function SaveToFile(file , table , tablename) 
	local handle = io.open(file,"w+") 
        handle:write(Serialize(table, tablename)) 
	handle:flush() 
        handle:close() 
end 
------------------------------------------------------------------------------------------------------------------
Ignorance is Bliss.

chettedeboeuf

tth:r2hmiaeu5ir7ia6io43gteynjbozczau6qstcza


Is it possible to filter this type of searches ???

chettedeboeuf

Thank you Dessamator

Dessamator

#3
ur welcome :)
Ignorance is Bliss.

Oz

why tth filter doesent work? :(

XPMAN

Thanx for this usefull script :)

One small request though anyway when you list the hub record:

----------------------------------------------------------------------------------------------------
	Record		Value		Date - Time
	----------------------------------------------------------------------------------------------------
	Share		100.2 MB 		06/01/05 11:03:14
	Users		1 user(s)
	---------------------------------------------------------------------------------------------------  

It can also list the Nick of the user that shares the most in the hub. Other words have  :  share record , users , then also list top sharer.. example:

Top share    XPMAN    550 Gigs


All underneath each other.

XPMAN

Can a mod please move this post to the Record bot. I mis posted....yea, thats what i did .... "rolll eyes"

Dessamator

QuoteOriginally posted by Oz
why tth filter doesent work? :(

done, post edited !
Ignorance is Bliss.

jiten

QuoteOriginally posted by XPMAN
Thanx for this usefull script :)

One small request though anyway when you list the hub record:

----------------------------------------------------------------------------------------------------
	Record		Value		Date - Time
	----------------------------------------------------------------------------------------------------
	Share		100.2 MB 		06/01/05 11:03:14
	Users		1 user(s)
	---------------------------------------------------------------------------------------------------  

It can also list the Nick of the user that shares the most in the hub. Other words have  :  share record , users , then also list top sharer.. example:

Top share    XPMAN    550 Gigs


All underneath each other.
Heya m8.
When I get some free time I'll add this to the Record Bot.

Cheers

chettedeboeuf

Hi,
The filter doesn't work !

catwo

Very nice script, any chance of it displaying the actual file name searched for rather than the tth name?  As always thanks for the script and your time and efforts.

Dessamator

QuoteOriginally posted by catwo
Very nice script, any chance of it displaying the actual file name searched for rather than the tth name?  As always thanks for the script and your time and efforts.

Done! , post edited
Ignorance is Bliss.

Dessamator

#12
--SearchCount-V.1.4b
--30.9.03 by c h i l l e r
--lua 5 by Dessamator
-- Added categories/types
-- added tth filter
-- fixed loopy loop bug and sort bug(thnx jiten)

--To enable right click write --> true
Rightclick = false
--This number stands for the maximum of shown items
Max1 = 100
--This number stands for the maximum of stored items
Max2 = 1000
--Timespan in minutes between each saving
Max3 = 60

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

File1 = "txt/TopSearches.txt"
SearchItems={}
cat={[1]="Unknown",[2]="Audio",[3]="Compressed",[4]="Document",[5]="Executable",[6]="Picture",[7]="Video",[8]="Directory",[9]="TTH"}
sec = 1000 
min = 60 * sec 

function Main()
local handle = io.open(File1,"r")
	if handle then 
		dofile(File1)
	else
		io.output(File1) 
		io.write("")          -- creates the file
	        io.output()
	end
	SetTimer(Max3 * min ) 
	StartTimer()
end

--user command(right click)
function NewUserConnected(user)
	if Rightclick == true then
		user:SendData("$UserCommand 1 3 Search logger\\Most Wanted $<%[mynick]> !mostwanted||")
		if user.bOperator then
			user:SendData("$UserCommand 1 3 Search logger\\Clear Logs $<%[mynick]> !clrslog||") 
		end
	end
end
OpConnected = NewUserConnected
--
function OnExit()
	OnTimer()
end

function OnTimer()
	SaveToFile(File1,SearchItems, "SearchItems")
end

function ChatArrival(curUser, data)
	data = string.sub(data,1,string.len(data)-1)
	s,e,cmd = string.find(data, "%b<>%s+(%S+)")
	if cmd=="!mostwanted" then
		curUser:SendData("\r\n".."\t\t\THE    MOST   WANTED\r\n"..
		"\t"..string.rep("-",70).."\r\n"..
		"\t\- - HITS - - \t\- - TYPE - -\t\t\- - ITEM - -\r\n"..
		TopSearches().."\r\n"..
		"\t"..string.rep("-",70))
		return 1
	elseif cmd=="!clrslog" and curUser.bOperator then
		SearchItems="nil"
		SearchItems={}
		curUser:SendData("Searchlogger","All previous searches have been purged from the logs")
		return 1
	end
end
function SearchArrival(User, data)
	local _,_,category,sestring = string.find( data, "$Search %S+%s%S+?%S+?%S+?(%S+)?(.*)" )
	local s,e, findtth = string.find(sestring,"(TTH%:)")
	if sestring and string.len(sestring) < 50 and not(findtth) then
		sestring = string.sub(sestring,1,string.len(sestring)-1)
		sestring = string.lower(sestring)
		sestring = string.gsub(sestring, "$+", " ")
		if SearchItems[sestring]==nil then
			SearchItems[sestring]={}
			SearchItems[sestring]["times"] = 1
			SearchItems[sestring]["Category"] = cat[tonumber(category)]
		else
			SearchItems[sestring]["times"]=SearchItems[sestring]["times"]+1
		end
	end
end
------------------------------------------------------------------------------------------------------------------
function TopSearches()
	local TCopy,TCat={},{}

	for i,v in SearchItems do
		table.insert( TCopy, {SearchItems[i]["times"],i,SearchItems[i]["Category"]} )
	end
	table.sort(TCopy,function(a,b) return (a[1] > b[1]) end)
	local msg ="\r\n" 
	for i = 1,Max1 do
		if TCopy[i] then
			msg = msg.."\t"..TCopy[i][1]
			msg = msg.."\t\t"..TCopy[i][3]
			if string.len(TCopy[i][3]) < 10 then
				msg = msg.."\t\t\t"..TCopy[i][2].."\r\n"
			end
			if string.len(TCopy[i][3]) >= 10 then
				msg = msg.."\t\t"..TCopy[i][2].."\r\n"
			end
		end
	end
	local TCopy={}
	return msg
end
------------------------------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, sTab) 
        assert(tTable, "tTable equals nil"); 
        assert(sTableName, "sTableName equals nil"); 
 
        assert(type(tTable) == "table", "tTable must be a table!"); 
        assert(type(sTableName) == "string", "sTableName must be a string!"); 
 
        sTab = sTab or ""; 
        sTmp = "" 
 
        sTmp = sTmp..sTab..sTableName.." = {\n" 
 
        for key, value in tTable do 
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key); 
 
                if(type(value) == "table") then 
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t"); 
                else 
                        local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value); 
                        sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue 
                end 
 
                sTmp = sTmp..",\n" 
        end 
 
        sTmp = sTmp..sTab.."}" 
        return sTmp 
end 
 
function SaveToFile(file , table , tablename) 
	local handle = io.open(file,"w+") 
        handle:write(Serialize(table, tablename)) 
	handle:flush() 
        handle:close() 
end
Ignorance is Bliss.

chettedeboeuf

:D  :D

Numbers appear on my central chat !!

LoL

Dessamator

#14
lol, it was a debugging "material", i forgot to remove that when it was done, either way post edited :)
Ignorance is Bliss.

chettedeboeuf

Yes, when I start the script, numbers appear on the central chat

[14:15] 44
[14:15] 21

etc ......

With 1.3 no problem

Dessamator

QuoteOriginally posted by chettedeboeuf
Yes, when I start the script, numbers appear on the central chat

[14:15] 44
[14:15] 21

etc ......

With 1.3 no problem
yap i solved the error, copy the script again :)
Ignorance is Bliss.

chettedeboeuf

Thank you dessamator

Dessamator

Ignorance is Bliss.

chettedeboeuf

I've this error :

[17:57] Syntax ...kaX\HUB 0.3.3.0 17.08\scripts\Hit Des Recherches.lua:150: bad argument #1 to `find' (string expected, got nil)

Line 150 :
local s,e, findtth = string.find(sestring,"(TTH%:)")

Thank you

Dessamator

post edited, btw no errors here, that should never happen unless, u edited some part of the script, or unless u didnt search for anything !
Ignorance is Bliss.

chettedeboeuf

What means 'btw' in French, please
Thank you

Dessamator

btw=  by the way = d'ailleurs(at least  google's translator says so)
Ignorance is Bliss.

jiten

QuoteOriginally posted by Dessamator
btw=  by the way = d'ailleurs(at least  google's translator says so)
Nice one m8. I had forgotten the meaning of it too :D

Oz

#24
hi :) how to align colump???



SMF spam blocked by CleanTalk