--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
------------------------------------------------------------------------------------------------------------------
tth:r2hmiaeu5ir7ia6io43gteynjbozczau6qstcza
Is it possible to filter this type of searches ???
Thank you Dessamator
ur welcome :)
why tth filter doesent work? :(
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.
Can a mod please move this post to the Record bot. I mis posted....yea, thats what i did .... "rolll eyes"
QuoteOriginally posted by Oz
why tth filter doesent work? :(
done, post edited !
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
Hi,
The filter doesn't work !
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.
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
--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
:D :D
Numbers appear on my central chat !!
LoL
lol, it was a debugging "material", i forgot to remove that when it was done, either way post edited :)
Yes, when I start the script, numbers appear on the central chat
[14:15] 44
[14:15] 21
etc ......
With 1.3 no problem
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 :)
Thank you dessamator
ur welcome !
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
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 !
What means 'btw' in French, please
Thank you
btw= by the way = d'ailleurs(at least google's translator says so)
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
hi :) how to align colump???
lol, aligning the column, well, it can be done the problem is, u can search for a thing with more than 200 characters, and it wont be able to align that it will always come out distorted, if u suggest a maximum characters, ill try to add it :)
QuoteOriginally posted by XPMAN
Thanx for this usefull script :)
One small request though anyway when you list the hub record:
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.
Check the Record Bot thread again ;)
Best regards
at command !mostwanted - such mistake
Syntax ...Ptokax\0.3.3.0.b17.08.nt.dbg\scripts\SearchCount.lua:185: attempt to compare number with nil
hmm, no errors here, i just tested it a few mins ago,try copying the script again, and erasing the Topsearches.txt, and then starting the script.
QuoteOriginally posted by Oz
hi :) how to align colump???
Done ! post edited
QuoteOriginally posted by Dessamator
hmm, no errors here, i just tested it a few mins ago,try copying the script again, and erasing the Topsearches.txt, and then starting the script.
works, thank you
this script is great! i dont know how i didnt come across it sooner...
There is a problem though... it doesnt saves the Type correctly, for instance, if i search for "telelista" once, with type any, i stays normal:
Times Type Item
1 Unknown fabio junior
1 Unknown telelista
1 Video sin city ts xvid invfx cd1 avi
1 Video the fifth element divx avi
1 Unknown san andreas
1 Unknown meu dengo
After someone makes another search, the type doesnt moves, just the Item:
- - Times - - - - Type - - - - Item - -
2 Unknown san andreas
1 Unknown fabio junior
1 Video telelista
1 Video the fifth element divx avi
1 Unknown sin city ts xvid invfx cd1 avi
1 Unknown meu dengo
or maybe its just me....still didnt sleep :P
lol, i did that on purpose, it shouldnt save as "any", because its isnt specific, what type/ category is "any"??? in other words any == unknown !
hope u understand !
but if u still want that, just change this ::
cat={[1]="Unknown",[2]="Audio",[3]="Compressed",[4]="Document",[5]="Executable",[6]="Picture",[7]="Video",[8]="Directory",[9]="TTH"}
to this:
cat={[1]="Any",[2]="Audio",[3]="Compressed",[4]="Document",[5]="Executable",[6]="Picture",[7]="Video",[8]="Directory",[9]="TTH"}
If I'm not wrong, [AT]conejodelmal is talking about the tabbing that isn't that accurate.
Maybe you could use nErBoS' DoTabs function. It is almost perfect ;)
Cheers
hmm... i think you didnt understand me :D
notice the word "Telelista", in the first display, with one search, it's searched as Unknown, after someone searches something else, it changed to Video, but no one searched for "Telelista" with Type Video...
Hope its more understandable now :P
ooh, i see so theres a bug in the searching, but how can u be so sure it wasnt searched?, either way ill check it out !
I can be sure it wasnt searched as Video, cause in the first time i typed the command, it was there with one search and as unknown, after a few seconds, i typed it again, and still with one search only it changed do Video.
The same with "sin city ts xvid invfx cd1 avi" first it was searched as Video, after it displayed it as Unknown :(
Fixed, post edited !
(I'm already getting annoying, I know :P)
Still not really perfect.. the last problem looks solved, but right now i searched for " Queens of the Stone Age " as Audio, and it displays it as:
1 Unknown queens of the stone age
If its too much work to fix it, I'm considering to remove the Type.. as anyway most people search as Any
i searched for that and it worked perfectly for me, u must have done something wrong either way, post edited, maybe it will solve ur bug :)
I have error :(
Syntax ...0.3.3.0.b17.08.nt.dbg\scripts\SearchCount-V.1.4b.lua:153: bad argument #1 to `find' (string expected, got nil)
try this :
1.Stop the script
2. delete the file in the txt folder named : TopSearches.txt
3. Start the script !
Ok, i try :)
big thx
ur welcome(if it works)