PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: sander815 on 06 June, 2005, 14:24:57

Title: [req]scriptconversion statlogger
Post by: sander815 on 06 June, 2005, 14:24:57
i lik ethis script converted into lua5, incl the addional functions i wrote in the thread:
http://board.univ-angers.fr/thread.php?threadid=2359&boardid=12&styleid=1&sid=2f3be16aeeb3237d39da8bde443c80ec
Title:
Post by: Markitos on 06 June, 2005, 15:05:31
-- 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 os.date of that day when users math.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

-- Lua 5 version by Markitos (6/6/2005)


Grab it here(Not tested) (http://mznetwork.mozdesigners.com/i/forum_files/Stat-logger03.rar)

Best regards
Title:
Post by: jiten on 06 June, 2005, 15:15:15
Markitos, you also need to convert the file handling and Arrivals.
"DataArrival" should be changed to "ChatArrival" and the To: part becomes "ToArrival".

Cheers
Title:
Post by: Markitos on 06 June, 2005, 15:22:13
QuoteOriginally posted by jiten
Markitos, you also need to convert the file handling and Arrivals.
"DataArrival" should be changed to "ChatArrival" and the To: part becomes "ToArrival".

Cheers
Didn't understand dis part " and the To: part becomes "ToArrival". "
It's something like this "ToArrival = ChatArrival" can u you give me an example?

Respectfully...
Title:
Post by: Dessamator on 06 June, 2005, 15:49:01
-- 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 = os.date("%d")
MM = os.date("%m")
Y = os.date("%y")


statlogfile = ("Data/"..D..""..MM..""..Y..".txt")

function Main()
if io.open("Stat-logger03.cfg","r") then   -- is used for the settings
dofile("Stat-logger03.cfg")
else
BOTName = "Stat-logger"
Version = "Stat-logger03"
end
frmHub:RegBot(BOTName)


if not io.open("Data/check.dat","r") then
os.execute("mkdir Data")
io.output("Data/check.dat")
io.close()
io.output()

end
SendToAll("( >>>>  "..Version.." Started"..os.date(" the %d/%m-%Y at %X ").."  <<<< )")
end

function ChatArrival(user,data)

data=string.sub(data,1,-2)
s,e,cmd = string.find(data,"%b<>%s+(%S+)")
cmd = string.sub(cmd, 2,string.len(cmd))
if io.open("Data/"..cmd..".txt") then
showtext(user, cmd)
return 1
end
end
function ToArrival(user,data)
s,e,cmd = string.find(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
cmd = string.sub(cmd, 2,string.len(cmd))
if io.open("Data/"..cmd..".txt") then
showtext(user, cmd)
return 1
end
end


function OpConnected(user)
description,email,share=MyInfoString(user.sMyInfoString)
local share2 = string.format("%0.2f",(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")
file=io.open(statlogfile,"a+")
file:write("\t","On the "..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - "..user.sName.." with e-mail "..email..", IP "..user.sIP.." and with share "..share2.."Gb connected \r\n")
file:close()

end

NewUserConnected = OpConnected

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


function showtext(user, cmd)
lines = "\r\n\r\n"
for line in io.lines("Data/"..cmd..".txt") do
if line == nil then
io.close()
break
end
lines = lines..line.."\r\n"
end
user:SendPM(BOTName, lines)
end



Done!
Title:
Post by: Dessamator on 06 June, 2005, 15:58:27
QuoteOriginally posted by Markitos
QuoteOriginally posted by jiten
Markitos, you also need to convert the file handling and Arrivals.
"DataArrival" should be changed to "ChatArrival" and the To: part becomes "ToArrival".

Cheers
Didn't understand dis part " and the To: part becomes "ToArrival". "
It's something like this "ToArrival = ChatArrival" can u you give me an example?

Respectfully...

hmm, he was talking about this :
 if(strsub(data, 1, 4) == "$To:") then    

when u are converting to lua 5 u change that to this :

function ToArrival(user,data)
and this two parts of code u change from this :

function DataArrival(user,data)
if( strsub(data, 1, 1) == "<" ) then  
end
 

to this :

function ChatArrival(user,data)
Title:
Post by: Penguin on 06 June, 2005, 16:21:06
Hi Dessamator,

Thank you very much for convert Troubadour's Stat-Logger into LUA5!!!

But I have one problem!
In the file for e.g.: 060605.txt -> I have only log of the newest user (who last logged on the hub)!
Older logs of users were enter on the hub didn't save into this file (The newer log rewrite older log) :(


    How's that?

   Thanks in adnvance for answer!

                  Penguin
P.S.
Sorry for my English!  :rolleyes:
Title:
Post by: Dessamator on 06 June, 2005, 16:28:18
QuoteOriginally posted by Penguin
Hi Dessamator,

Thank you very much for convert Troubadour's Stat-Logger into LUA5!!!

But I have one problem!
In the file for e.g.: 060605.txt -> I have only log of the newest user (who last logged on the hub)!
Older logs of users were enter on the hub didn't save into this file (The newer log rewrite older log) :(


    How's that?

   Thanks in adnvance for answer!

                  Penguin
P.S.
Sorry for my English!  :rolleyes:
Fixed !
Post edited !
Title:
Post by: sander815 on 06 June, 2005, 16:29:58
yes, thanx a lot for converting it, but as requested in the other thread, i would like this script to log on a per user base users details...

so i can do this:
+statlog [nick]
On the 06.06.05 - 16:28 - [nick] with e-mail nick@mail.com, IP 192.168.1.100 and with share 19.943974516355Gb connected
On the 07.06.05 - 16:28 - [nick] with e-mail nick@mail.com , IP 192.168.1.100 and with share 29.943974516355Gb connected
On the 07.06.05 - 22:21 - [nick] with e-mail nick@mail.com , IP 192.168.1.100 and with share 13.943974516355Gb connected

so i can log users activity
Title:
Post by: Dessamator on 06 June, 2005, 16:35:05
QuoteOriginally posted by sander815
yes, thanx a lot for converting it, but as requested in the other thread, i would like this script to log on a per user base users details...

so i can do this:
+statlog [nick]
On the 06.06.05 - 16:28 - [nick] with e-mail nick@mail.com, IP 192.168.1.100 and with share 19.943974516355Gb connected
On the 07.06.05 - 16:28 - [nick] with e-mail nick@mail.com , IP 192.168.1.100 and with share 29.943974516355Gb connected
On the 07.06.05 - 22:21 - [nick] with e-mail nick@mail.com , IP 192.168.1.100 and with share 13.943974516355Gb connected

so i can log users activity

no need to add that in this script, for starters a similar script already  exists, userinfo database by nightlitch, and others, theres iplog which does the same too, hope u understand :)
Title:
Post by: Penguin on 06 June, 2005, 16:37:48
QuoteOriginally posted by Dessamator
Fixed !
Post edited !

OK, Thank you very much Dessamator!!!
Title:
Post by: sander815 on 06 June, 2005, 17:23:52
point me to them then, if possible

i have never found a script that does what i describe..
Title:
Post by: jiten on 06 June, 2005, 17:37:33
QuoteOriginally posted by sander815
point me to them then, if possible

i have never found a script that does what i describe..
As I pointed before, search for "Connection Log". It does that...

Cheers
Title:
Post by: Dessamator on 06 June, 2005, 17:38:49
Quote"userinfo" database by nightlitch, and others, theres "iplog" which does the same too,

click on the links in my signature and learn how to search my boy, search !
Title:
Post by: XPMAN on 06 June, 2005, 19:57:43
K, got a question.. does the Stat-logger 0.3 add a log for each day?.... if it does a way to keep the folder where the txt files are stored from getting huge would be nice. Maybe a clear command or del command to ..........time limit to self delete :) ..... just asking. I didnt see anyway of deleting the files except going into the scripts folder and manually doing it.
Title:
Post by: Dessamator on 06 June, 2005, 20:38:36
hmm,indeed thats a good point, but, how long should it stay there?
Title:
Post by: XPMAN on 07 June, 2005, 05:40:15
maybe be settable by the master\Op before auto delete or even yet at the very least have an option to say....... delete  050605-080205 :)  ..... a range. Just an idea.
Title:
Post by: Dessamator on 07 June, 2005, 09:23:25
hmm, indeed, ill see what i can do ! i think ill set it to a week on default :)
Title:
Post by: Dessamator on 07 June, 2005, 17:28:27
--Lua 5 By Dessamator
-- Stat-logger 0.3a
-- added !lastips(request by Penguin)

-- 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 = os.date("%d")
MM = os.date("%m")
Y = os.date("%y")
a={}

statlogfile = ("Data/"..D..""..MM..""..Y..".txt")
MaxLogins = 15

function Main()
if io.open("Stat-logger03.cfg","r") then   -- is used for the settings
dofile("Stat-logger03.cfg")
else
BOTName = "Stat-logger"
Version = "Stat-logger03"
end
frmHub:RegBot(BOTName)


if not io.open("Data/check.dat","r") then
os.execute("mkdir Data")
io.output("Data/check.dat")
io.close()
io.output()

end
SendToAll("( >>>>  "..Version.." Started"..os.date(" the %d/%m-%Y at %X ").."  <<<< )")
end

function ChatArrival(user,data)

data=string.sub(data,1,-2)
s,e,cmd = string.find(data,"%b<>%s+(%S+)")
local n,temp=0,"The last "..MaxLogins.."logged users\r\n"
if cmd =="!lastips" then
for line in io.lines("Data/"..D..""..MM..""..Y..".txt") do
table.insert(a, line)
end
for i=table.getn(a),1, -1 do
if n temp=temp..a[i].."\r\n"
n=n+1
end
end
user:SendData(BOTName,temp)
end
cmd = string.sub(cmd, 2,string.len(cmd))
if io.open("Data/"..cmd..".txt") then
showtext(user, cmd)
return 1
end
end


function ToArrival(user,data)
s,e,cmd = string.find(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
cmd = string.sub(cmd, 2,string.len(cmd))
if io.open("Data/"..cmd..".txt") then
showtext(user, cmd)
return 1
end

end


function OpConnected(user)
description,email,share=MyInfoString(user.sMyInfoString)
local share2 = string.format("%0.2f",(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")
file=io.open(statlogfile,"a+")
file:write("\t","On the "..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - "..user.sName.." with e-mail "..email..", IP "..user.sIP.." and with share "..share2.."Gb connected \r\n")
file:close()

end

NewUserConnected = OpConnected

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


function showtext(user, cmd)
lines = "\r\n\r\n"
for line in io.lines("Data/"..cmd..".txt") do
if line == nil then
break
end
lines = lines..line.."\r\n"
end
io.close()
user:SendPM(BOTName, lines)
end
Title:
Post by: Penguin on 07 June, 2005, 19:24:11
QuoteOriginally posted by Dessamator
-- added !lastips(request by Penguin)

Hey Dessamator,
Thank you very much!!!
Title:
Post by: Dessamator on 07 June, 2005, 21:15:21
QuoteOriginally posted by Penguin
QuoteOriginally posted by Dessamator
-- added !lastips(request by Penguin)

Hey Dessamator,
Thank you very much!!!

no prob, btw i edited the script above, it might resolve ur prob(im unsure)
Title:
Post by: Penguin on 07 June, 2005, 21:38:50
QuoteOriginally posted by Dessamator
no prob, btw i edited the script above, it might resolve ur prob(im unsure)

OK -> THX
I test it.
Title:
Post by: Dessamator on 07 June, 2005, 22:37:24
goody :)
Title:
Post by: XPMAN on 08 June, 2005, 06:45:15
Thanks for yet another awesome script :)

Well done!
Title:
Post by: jiten on 08 June, 2005, 14:33:14
QuoteOriginally posted by Dessamator
goody :)
m8, maybe it's better to post this one in the Finished Scripts section as it's a wanted one :D

Cheers
Title:
Post by: Dessamator on 08 June, 2005, 14:59:47
QuoteOriginally posted by jiten
QuoteOriginally posted by Dessamator
goody :)
m8, maybe it's better to post this one in the Finished Scripts section as it's a wanted one :D

Cheers

Done !
Title:
Post by: Genius on 09 June, 2005, 17:32:50
Hi

Can?t make a function in bot for me?
User join in the hub, and this bot our another, send pm for Master.

Exemple:

1? -User xxx Ip: xxxx share: xxxx description: xxx are join in the Hub.

2? -User xxx Ip: xxxx share: xxxx description: xxx are left.
Title:
Post by: jiten on 09 June, 2005, 17:44:07
QuoteOriginally posted by ?[-?Genius?-]?
Hi

Can?t make a function in bot for me?
User join in the hub, and this bot our another, send pm for Master.

Exemple:

1? -User xxx Ip: xxxx share: xxxx description: xxx are join in the Hub.

2? -User xxx Ip: xxxx share: xxxx description: xxx are left.
Looks a bit like the "IP Monitoring" script with some extra code.
Title:
Post by: Dessamator on 09 June, 2005, 19:50:58
QuoteOriginally posted by •[-•Genius•-]•
Hi

Can?t make a function in bot for me?
User join in the hub, and this bot our another, send pm for Master.

Exemple:

1? -User xxx Ip: xxxx share: xxxx description: xxx are join in the Hub.

2? -User xxx Ip: xxxx share: xxxx description: xxx are left.

ur obviously not serious, in a hub with more than 500 users, the master would get 500 PMs, each time the hub is restarted, in other words flooding the Master (not a good idea)