PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: sander815 on 17 March, 2005, 08:52:41

Title: please edit stat-logger script, if possible
Post by: sander815 on 17 March, 2005, 08:52:41
can some edit thi script, so that it creates a sort of database for all regged users, in a way that it logs whatever their sharesize is when they log in, so i can check back the amount of Gb they share

this script logs for all users in one txt file per day(althought it only saves to a new file after a script restart, little bug)

-- Stat-logger 0.3 by Troubadour
-- created a seperated config file + gui

-- Stat-logger 0.2 by Troubadour
-- to write all info to a file with the date of that day when users log in (name, e-mail, ip and share)
-- command for viewing the files is !
-- for example !280704 is the command to view the file of 28 juli 2004

-- Stat-logger 0.1 by Troubadour
-- to write all info to a file when a user logs in (name, e-mail, ip and share)
-- command to view the file is !statlog

D = date("%d")
MM = date("%m")
Y = date("%y")

dofile("Stat-logger03.cfg");  -- is used for the settings
statlogfile = ("Data/"..D..""..MM..""..Y..".txt")

function Main()
frmHub:RegBot(BOTName)
SendToAll("( >>>>  "..Version.." Started"..date(" the %d/%m-%Y at %X ").."  <<<< )")
end

function DataArrival(user,data)

data=strsub(data,1,strlen(data)-1)
if( strsub(data, 1, 1) == "<" ) then
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
cmd = strsub(cmd, 2,strlen(cmd))
if readfrom("Data/"..cmd..".txt") then
showtext(user, cmd)
return 1
end
elseif(strsub(data, 1, 4) == "$To:") then
s,e,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
cmd = strsub(cmd, 2,strlen(cmd))
if readfrom("Data/"..cmd..".txt") then
showtext(user, cmd)
return 1
end
end
end

function OpConnected(user)
description,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
--SendToAll("Stat-logger",user.sName.." with e-mail "..email..", IP "..user.sIP.." and with share "..share2.." Gb")
statlogfile = ("Data/"..D..""..MM..""..Y..".txt")
appendto(statlogfile)
write("\t","On the "..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." - "..user.sName.." with e-mail "..email..", IP "..user.sIP.." and with share "..share2.."Gb connected \r\n")
writeto()
end

function NewUserConnected(user)
description,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
--SendToAll("Stat-logger",user.sName.." with e-mail "..email..", IP "..user.sIP.." and with share "..share2.." Gb")
statlogfile = ("Data/"..D..""..MM..""..Y..".txt")
appendto(statlogfile)
write("\t","On the "..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." - "..user.sName.." with e-mail "..email..", IP "..user.sIP.." and with share "..share2.."Gb connected \r\n")
writeto()

end

function MyInfoString(data)
s,e,description,nada,email,share = strfind(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
return description,email,share
end


function showtext(user, cmd)
lines = "\r\n\r\n"
readfrom("Data/"..cmd..".txt")
while 1 do
local line = read()
if line == nil then
readfrom()
break
end
lines = lines..line.."\r\n"
end
user:SendPM(BOTName, lines.." |")
end