PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: SaintSinner on 11 November, 2003, 22:24:16

Title: looking for user hubtime
Post by: SaintSinner on 11 November, 2003, 22:24:16
hey guys im looking for a user hubtime script
or which script does it, for example
-uptime saintisnner
saintsinner has been in this hub for 29 hours.

i would like it to check the consistency of users i download large files from.
possible?
Title:
Post by: plop on 11 November, 2003, 22:48:57
this looks like a yes.
=====================================
  Here is the info from: [TGA-OP]plop
=====================================
  IP: xxx.xxx.xxx.xxx
  Client type: DC++
  Version: 0.241
  Mode: active
  Hub(s) as regular user: 0
  Hub(s) as registered user: 0
  Hub(s) as operator: 2
  Upload slot(s): 4
  Connection type: DSL
  Sharing: 69.62 GB
  Total time in hub: 20 days 23 hours 10 mins
  This visit: 3 mins
  Description: ikke
  Processing time: 0 seconds
=====================================
 
soon 2 be released A.I. bot.
after that i'll release a stand alone version of the userinfo part.
there is also another script around wich does something like it but it saves the data every minute.
no idea who made that 1.

plop
Title:
Post by: SaintSinner on 12 November, 2003, 13:48:26
wow sweet exactly what im looking for :D  :D
Title:
Post by: SaintSinner on 12 November, 2003, 13:51:06
X( damn doublepost X(  X(
Title:
Post by: c h i l l a on 12 November, 2003, 13:53:55
I highly disagree every minute, tsk...

sinner check my site the hubtime-v.1.63

or this thread

http://board.univ-angers.fr/thread.php?threadid=403&boardid=12&styleid=1&sid=d4010c0ae4432277e0c62ae7c124f95e (http://board.univ-angers.fr/thread.php?threadid=403&boardid=12&styleid=1&sid=d4010c0ae4432277e0c62ae7c124f95e)
Title:
Post by: SaintSinner on 12 November, 2003, 14:07:17
nice chilla
can you get it to pull only one name from the file like
+uptime saintsinner

He has been online for::0 Months, 0 Days, 0 Hours, 1 Min ( 1 min ).
Title:
Post by: c h i l l a on 12 November, 2003, 14:25:08
sure here you go


--OnHub Time Logger V.1.63
--27.9.03 by c h i l l e r
--thx to tezlo for the nice calculation from minutes to months, days, etc., and to Nagini, and to RabidWombat
--Create a "txt" Folder in the PtokaX scripts Folder, like this /scripts/txt/

--ChangeLog :
--27.9.03 Added Serialisation.

-- Name this bot to what you want
bot="-= Hub Time =-"

--Name the commands to what you like
cmd1 = "+myhubtime"
cmd2 = "+allhubtime"
cmd3 = "+hubtime"
cmd4 = "+uptime"

--This number stands for the maximum of displayed users, set it to what U like
Max = 20
--This number is for the timespan between each data saving in minutes.
Max1 = 30
--This number stands for time in minutes, a user must be online till he is saved to the file.
Max2 = 10
---------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------

File1 = "UserHubTime.txt"

sec = 1000
min = 60 * sec

var1 = 0

assert(dofile("txt/"..File1), "txt/"..File1.." for HubTime-V.163.lua not found")

function Main()
SetTimer(1 * min)
StartTimer()
end

function OnTimer()
for i,v in UserHubTime do
if GetItemByName(i) or i=="HubUpTime" then
v=v+1
UserHubTime[i]=v
end
end
var1 = var1 + 1
if var1 == Max1 then
WriteFile(UserHubTime, "UserHubTime", File1)
var1 = 0
end
end

function NewUserConnected(curUser)
if UserHubTime[curUser.sName]==nil then
UserHubTime[curUser.sName]=0
end
end

function OpConnected(curUser)
if UserHubTime[curUser.sName]==nil then
UserHubTime[curUser.sName]=0
end
end

function DataArrival(curUser,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s+(%S+)" )

if (cmd and strlower(cmd) == strlower(cmd1) and UserHubTime[curUser.sName] ) then
local tmp = UserHubTime[curUser.sName]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
curUser:SendData(bot, "You have been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ). That is "..format("%.2f",tmp/UserHubTime["HubUpTime"]*100).." % of the total HubUpTime.")
return 1

if (cmd and strlower(cmd) == strlower(cmd4)) then
local _,_,user = strfind( data, "%b<>%s+%S+%s+(%S+)" )
if user and UserHubTime[user] then
local tmp = UserHubTime[user]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
curUser:SendData(bot, "User: "..user.." has been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ). That is "..format("%.2f",tmp/UserHubTime["HubUpTime"]*100).." % of the total HubUpTime.")
return 1
end

elseif (cmd and strlower(cmd) == strlower(cmd2)) then
curUser:SendData(bot, "   -= The Top "..Max.." Campers =-\r\n"..
GetUserMaxTime().."\r\n")
return 1

elseif (cmd and strlower(cmd) == strlower(cmd3)) then
local tmp = UserHubTime["HubUpTime"]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
curUser:SendData(bot, "The hub has now been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ).")
return 1

end
end
end
----------------------------------------------------------------------------------------------------------
function WriteFile(table, tablename, file)
local handle = openfile("txt/"..file, "w")
write(handle, tablename.." = {\n" )
for key, value in table do
if value >= Max2 then
write(handle, "\t"..format("[%q]",key).." = "..value..",\n")
end
end
write(handle, "}");
  closefile(handle)
end
----------------------------------------------------------------------------------------------------------
function GetUserMaxTime()
local TCopy={}
for i,v in UserHubTime do
if i~="HubUpTime" then
tinsert( TCopy, { tonumber(v),i } )
end
end
sort( TCopy, function(a, b) return (a[1] > b[1]) end)
local msg ="\r\n"
for i = 1,Max do
if TCopy[i] then
local months, days, hours, minutes = floor(TCopy[i][1]/43200), floor(mod(TCopy[i][1]/1440, 30)), floor(mod(TCopy[i][1]/60, 24)), floor(mod(TCopy[i][1]/1, 60))
msg = msg.."\t\t# "..i.."  -  "..TCopy[i][2].."\t::\t"..months.." Months, "..days.." Days, "..hours.." Hours, "..minutes.." Min ( "..TCopy[i][1].." min ).\r\n"
end
end
local TCopy={}
return msg
end
----------------------------------------------------------------------------------------------------------
Title:
Post by: SaintSinner on 12 November, 2003, 14:30:34
WOOHOO thanx
 :D  :D  :D  :D  :D
Title:
Post by: SaintSinner on 12 November, 2003, 14:35:07
ok im getting this
Syntax Error: `end' expected (to close `if' at line 72);
  last token read: `if' at line 78 in string "--OnHub Time Logger V.1.63

it has to do with this line
if (cmd and strlower(cmd) == strlower(cmd1) and UserHubTime[curUser.sName] ) then

under the function DataArrival(curUser,data)

 :(
Title:
Post by: c h i l l a on 12 November, 2003, 14:48:49
stupid mistake grrrr.

new code




--OnHub Time Logger V.1.63
--27.9.03 by c h i l l e r
--thx to tezlo for the nice calculation from minutes to months, days, etc., and to Nagini, and to RabidWombat
--Create a "txt" Folder in the PtokaX scripts Folder, like this /scripts/txt/

--ChangeLog :
--27.9.03 Added Serialisation.

-- Name this bot to what you want
bot="-= Hub Time =-"

--Name the commands to what you like
cmd1 = "+myhubtime"
cmd2 = "+allhubtime"
cmd3 = "+hubtime"
cmd4 = "+uptime"

--This number stands for the maximum of displayed users, set it to what U like
Max = 20
--This number is for the timespan between each data saving in minutes.
Max1 = 30
--This number stands for time in minutes, a user must be online till he is saved to the file.
Max2 = 10
---------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------

File1 = "UserHubTime.txt"

sec = 1000
min = 60 * sec

var1 = 0

assert(dofile("txt/"..File1), "txt/"..File1.." for HubTime-V.163.lua not found")

function Main()
SetTimer(1 * min)
StartTimer()
end

function OnTimer()
for i,v in UserHubTime do
if GetItemByName(i) or i=="HubUpTime" then
v=v+1
UserHubTime[i]=v
end
end
var1 = var1 + 1
if var1 == Max1 then
WriteFile(UserHubTime, "UserHubTime", File1)
var1 = 0
end
end

function NewUserConnected(curUser)
if UserHubTime[curUser.sName]==nil then
UserHubTime[curUser.sName]=0
end
end

function OpConnected(curUser)
if UserHubTime[curUser.sName]==nil then
UserHubTime[curUser.sName]=0
end
end

function DataArrival(curUser,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s+(%S+)" )

if (cmd and strlower(cmd) == strlower(cmd1) and UserHubTime[curUser.sName] ) then
local tmp = UserHubTime[curUser.sName]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
curUser:SendData(bot, "You have been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ). That is "..format("%.2f",tmp/UserHubTime["HubUpTime"]*100).." % of the total HubUpTime.")
return 1

elseif (cmd and strlower(cmd) == strlower(cmd4)) then
local _,_,user = strfind( data, "%b<>%s+%S+%s+(%S+)" )
if user and UserHubTime[user] then
local tmp = UserHubTime[user]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
curUser:SendData(bot, "User: "..user.." has been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ). That is "..format("%.2f",tmp/UserHubTime["HubUpTime"]*100).." % of the total HubUpTime.")
return 1
end

elseif (cmd and strlower(cmd) == strlower(cmd2)) then
curUser:SendData(bot, "   -= The Top "..Max.." Campers =-\r\n"..
GetUserMaxTime().."\r\n")
return 1

elseif (cmd and strlower(cmd) == strlower(cmd3)) then
local tmp = UserHubTime["HubUpTime"]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
curUser:SendData(bot, "The hub has now been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ).")
return 1

end
end
end
----------------------------------------------------------------------------------------------------------
function WriteFile(table, tablename, file)
local handle = openfile("txt/"..file, "w")
write(handle, tablename.." = {\n" )
for key, value in table do
if value >= Max2 then
write(handle, "\t"..format("[%q]",key).." = "..value..",\n")
end
end
write(handle, "}");
  closefile(handle)
end
----------------------------------------------------------------------------------------------------------
function GetUserMaxTime()
local TCopy={}
for i,v in UserHubTime do
if i~="HubUpTime" then
tinsert( TCopy, { tonumber(v),i } )
end
end
sort( TCopy, function(a, b) return (a[1] > b[1]) end)
local msg ="\r\n"
for i = 1,Max do
if TCopy[i] then
local months, days, hours, minutes = floor(TCopy[i][1]/43200), floor(mod(TCopy[i][1]/1440, 30)), floor(mod(TCopy[i][1]/60, 24)), floor(mod(TCopy[i][1]/1, 60))
msg = msg.."\t\t# "..i.."  -  "..TCopy[i][2].."\t::\t"..months.." Months, "..days.." Days, "..hours.." Hours, "..minutes.." Min ( "..TCopy[i][1].." min ).\r\n"
end
end
local TCopy={}
return msg
end
----------------------------------------------------------------------------------------------------------
Title:
Post by: SaintSinner on 12 November, 2003, 14:49:30
@chilla i think i fixed it
here is what i did
im not a scripter so tell me if i did something wrong :D
i end the
function DataArrival(curUser,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s+(%S+)" )

if (cmd and strlower(cmd) == strlower(cmd1) and UserHubTime[curUser.sName] ) then
local tmp = UserHubTime[curUser.sName]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
curUser:SendData(bot, "You have been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ). That is "..format("%.2f",tmp/UserHubTime["HubUpTime"]*100).." % of the total HubUpTime.")
return 1
end


i gave it a end  and i got no errors
what do you think? :]
Title:
Post by: SaintSinner on 12 November, 2003, 14:50:16
oops i was  too slow

thanks
Title:
Post by: c h i l l a on 12 November, 2003, 14:51:59
you are calling a if function  in a if function

so I think it won't work...   but hey check out  write your own bot,  in the how too's section...  you will learn a lot, at least how to not do such damn mistakes ;).

hey I was faster ;),  usually I'm the slow one.
Title:
Post by: SaintSinner on 12 November, 2003, 14:54:33
QuoteOriginally posted by c h i l l a
you are calling a if function  in a if function

so I think it won't work...   but hey check out  write your own bot,  in the how too's section...  you will learn a lot, at least how to not do such damn mistakes ;).

hey I was faster ;),  usually I'm the slow one.


yups im on my way there

thanks again
Title:
Post by: plop on 12 November, 2003, 15:45:26
cool 1 chilla, i gotta add that HubUpTime 2 my script.
nice 2 see a 3de way of calculating the time.
i'm using the julian day function from tezlo.
this way i can save when a user leaves the hub, every xx users it saves 2 file.

plop