PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: Dessamator on 08 June, 2005, 14:57:17

Title: Stat-logger 0.3a
Post by: Dessamator on 08 June, 2005, 14:57:17
--Lua 5 By Dessamator
-- Stat-logger 0.3b
-- fixed error in saving logs(report by TTB)
-- 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
a={}

MaxLogins = 15

function Main()
--statlogfile = "Data/"..os.date("%d%m%y.txt")

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/"..os.date("%d%m%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/"..os.date("%d%m%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: TTB on 08 June, 2005, 16:16:04
Nice one...

but the script in LUA4 had one point that didn't work very well... The filenames that are used is the date of a day. When not restarting the scripts, the next day is also logged in the previous dayfile.

I will not use this script, because I run RC with also this feature (something like it)...
Title:
Post by: Dessamator on 08 June, 2005, 18:00:32
QuoteOriginally posted by TTB
Nice one...

but the script in LUA4 had one point that didn't work very well... The filenames that are used is the date of a day. When not restarting the scripts, the next day is also logged in the previous dayfile.

I will not use this script, because I run RC with also this feature (something like it)...

hmm ,well id say its similar to optimus ip logger, but this one's better, hehe, its got !lastip :)

but if ur using that ip logger this wouldnt be of much use, except when i add a new feature !
Title:
Post by: Dessamator on 08 June, 2005, 18:36:22
----> Stat-Logger 0.4a By Dessamator
-- Added Search Log(!searchlog)
-- Added SendTo (request by Penguin )
----> Stat-logger 0.3b
-- fixed error in saving logs(report by TTB)
----> Stat-logger 0.3a
-- Added !lastips(request by Penguin)
-- Lua 5 by Dessamator
----> 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


a={}
MaxLogins = 15
SendTo = 2 -- (1 =>MainChat 2=>PM, 3=>Main and pvt (request by Penguin)

function Main()
--statlogfile = "Data/"..os.date("%d%m%y.txt")

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+)")
s,e,ip = string.find(data,"%b<>%s+%S+%s+(%S+)")
local n,temp=0,"The last "..MaxLogins.."logged users\r\n"
if cmd =="!lastips" then
for line in io.lines("Data/"..os.date("%d%m%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
if SendTo == 1 then user:SendData(BOTName,temp)
elseif SendTo == 2 then user:SendPM(BOTName,temp)
elseif SendTo == 3 then SendToAll(BOTName,temp) user:SendPM(BOTName,temp)
end
return 1
elseif cmd=="!searchlog" then
s,e,date = string.find(data, "%b<>%s+%S+%s+%S+%s+(.+)")
findloggedip(user,ip, date)
return 1
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/"..os.date("%d%m%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

function findloggedip(user,ip,date)
local found,check,log ="\r\n\t\t".."The Results of your search:".."\r\n","","Data/"..os.date("%d%m%y")..".txt"

if date then log="Data/"..date..".txt" end

found=found.."\t\t"..string.rep("??",12).."\r\n"
if ip and verify(log) then
for line in io.lines(log) do
local s,e,search =string.find(line,ip)
if not(e==nil) and not(s==nil) then
found=found.."\t"..line.."\r\n"
check=line
e=nil --reset the searcher
s=nil -- "" ""
end
end
elseif not ip then
user:SendPM(BOTName,"Syntax Error. Correct Syntax is : !searchlog eg.: !searchlog 127.0.0.1 060505")
elseif not(verify(log)) then
user:SendPM(BOTName,"There is no log to search in !!!")
end
if not(check=="") then
user:SendPM(BOTName,found)
else
user:SendPM(BOTName,"That ip or nick wasnt found in the logs!!")
end
end

function verify(filename)
local f = io.open(filename, "r")
if f then
f:close()
return true
end
end
Title:
Post by: Dinok on 09 June, 2005, 05:49:59
Syntax ...PtokaX\scripts\Stat-Logger0.4a.lua:123: `=' expected near `=='
Title:
Post by: Dessamator on 09 June, 2005, 10:37:44
well, i just rechecked the script there isnt any syntax error, u must have edited something and caused that
copy the Script again, and/or Paste that line here !