-------------------------------------------------------
---------------- Datalog - Lua Edition ----------------
--------------------- Version 1.1 ---------------------
------------------- by DirtyFinger --------------------
---------------- DirtyFinger@gmx.net ------------------
------------------ ICQ : 145873101 --------------------
------- http://mitglied.lycos.de/dirtyfinger01/ -------
-------------------------------------------------------
-------------------------------------------------------
-- This script logs incoming data , connects, disconnects
-- and saves them in three seperate files.
-- I'm pretty sure that absolutely NO ONE needs this script
-- to run a functioning hub.
-- It's rather something to watch at long, cold evenings.
-- Due to the known problems with PtokaX 0.323X the files
-- may not be generated.
-- In that case AND if you use PtokaX 0.324 or higher,
-- use the second set of file locations (directly below).
-- Make sure the Directory Datalog exists !!
Connectlogfile = "Datalog/connectlog.txt"
Datalogfile = "Datalog/datalog.txt"
Statisticsfile = "Datalog/stats.txt"
-- Connectlogfile = "Datalog/connectlog.txt"
-- Datalogfile = "Datalog/datalog.txt"
-- Statisticsfile = "Datalog/stats.txt"
sBotName = "Guat?"
timerIntervall = 10*1000 -- This sets the intervalls in which the files get saved
sDatalog = ""
sConnectlog = ""
Statistics = {
ConnectToMe = 0,
GetNickList = 0,
GetINFO = 0,
Kick = 0,
MainChat = 0,
MultiConnectToMe = 0,
MultiSearch = 0,
MyINFO = 0,
MyPass = 0,
OpForceMove = 0,
Other = 0,
Quit = 0,
RevConnectToMe = 0,
Search = 0,
SearchResult = 0,
To = 0,
ValidateNick = 0,
Version = 0,
ZTotal = 0,
}
--// This function is fired at the serving start
function OnStartup()
Core.SendToAll(sBotName.." "..date(" launched at %B %d %Y %X "))
tmr = TmrMan.AddTimer(timerIntervall)
loadStatistics (Statisticsfile)
end
--// This function is fired when a new data arrives
function DataArrival(curUser, sData)
sDatalog = sDatalog .. "\n" .. "<|"..date("%c|") .. curUser.sNick .. "|" .. curUser.sIP .. "|> " .. sData
local s = splitstring(sData)
if s == "$ConnectToMe" then
Statistics.ConnectToMe = Statistics.ConnectToMe + 1
elseif s == "$GetNickList|" then
Statistics.GetNickList = Statistics.GetNickList + 1
elseif s == "$GetINFO" then
Statistics.GetINFO = Statistics.GetINFO + 1
elseif s == "$Kick" then
Statistics.Kick = Statistics.Kick + 1
elseif s == "<"..curUser.sNick..">" then
Statistics.MainChat = Statistics.MainChat + 1
elseif s == "$MultiConnectToMe" then
Statistics.MultiConnectToMe = Statistics.MultiConnectToMe + 1
elseif s == "$MultiSearch" then
Statistics.MultiSearch = Statistics.MultiSearch + 1
elseif s == "$MyINFO" then
Statistics.MyINFO = Statistics.MyINFO + 1
elseif s == "$MyPass" then
Statistics.MyPass = Statistics.MyPass + 1
elseif s == "$OpForceMove" then
Statistics.OpForceMove = Statistics.OpForceMove + 1
elseif s == "$Quit" then
Statistics.Quit = Statistics.Quit + 1
elseif s == "$RevConnectToMe" then
Statistics.RevConnectToMe = Statistics.RevConnectToMe + 1
elseif s == "$Search" then
Statistics.Search = Statistics.Search + 1
elseif s == "$SR" then
Statistics.SearchResult = Statistics.SearchResult + 1
elseif s == "$To:" then
Statistics.To = Statistics.To + 1
elseif s == "$ValidateNick" then
Statistics.ValidateNick = Statistics.ValidateNick + 1
elseif s == "$Version" then
Statistics.Version = Statistics.Version + 1
else
Statistics.Other = Statistics.Other + 1
end
Statistics.ZTotal = Statistics.ZTotal + 1
end
--// This function is fired when a new user finishes the login
function UserConnected(curUser)
Core.GetUserAllData(curUser)
sConnectlog = sConnectlog .. "\n" .. "<"..date("%c|") .. curUser.sNick .. "|" .. curUser.sIP .. "> " .. "User Connected"
end
function tokenize (inString,token)
_WORDS = {}
local matcher = "([^"..token.."]+)"
gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
return _WORDS
end
--// This function is fired when an operator enters the hub
function OpConnected(curUser)
Core.GetUserAllData(curUser)
sConnectlog = sConnectlog .. "\n" .. "<"..date("%c|") .. curUser.sNick .. "|" .. curUser.sIP .. "> " .. "Operator Connected"
end
--// This function is fired when an user disconnects
function UserDisconnected(curUser)
Core.GetUserAllData(curUser)
sConnectlog = sConnectlog .. "\n" .. "<"..date("%c|") .. curUser.sNick .. "|" .. curUser.sIP .. "> " .. "User Disconnected"
end
--// This function is fired when an operator disconnects
function OpDisconnected(curUser)
Core.GetUserAllData(curUser)
sConnectlog = sConnectlog .. "\n" .. "<"..date("%c|") .. curUser.sNick .. "|" .. curUser.sIP .. "> " .. "Operator Disconnected"
end
function OnTimer(tmr)
-- DirtyUsers:saveToFile(HubSettings.HubDataFile,FileIPList)
if sDatalog ~= "" then
local f = appendto(Datalogfile)
write(sDatalog)
sDatalog = ""
closefile(f)
end
if sConnectlog ~= "" then
local f = appendto(Connectlogfile)
write(sConnectlog)
sConnectlog = ""
closefile(f)
end
saveStatistics (Statisticsfile)
end
function print (...)
local s =""
for i=1,arg.n do
s = s..tostring(arg[i]).."\t"
end
SendToAll ("",s)
end
function splitstring (string,token)
token = token or " "
local n = strfind(string,token)
if n then
return strsub(string,1,n-1) , strsub(string,n+1)
else
return string , ""
end
end
function loadStatistics (file)
assert(readfrom(file),"stats.txt not found.Generating new stats.txt. All is fine. Don't panic.")
dostring(read("*all"))
readfrom()
end
function saveStatistics (file)
writeto(file)
local l = {}
for k,v in pairs(Statistics) do
tinsert(l,k)
end
sort(l)
local s = "Statistics = { \n"
for i=1,getn(l) do
s = s .. "\t" .. l[i] .. " = " .. tostring(Statistics[l[i]]) .. ", \n"
end
local s = s.."}"
write(s)
writeto()
end
RegConnected = UserConnectedRegDisconnected = UserDisconnected
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Report If There Are Any Problems In The Scipt
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
:) Going Gud
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Good script for PtokaX 0.1.1.1 pre-release version, yes :)
This script is outdated, uses Lua4, so nobody can use it.
edited:
Even better. Some code is for new API, so for oldest API. /Lua4 is still Lua4/ :D
You cannot possibly have tested this script.
As Hungarista indicates is it written in LUA 4 and PtokaX simply won't run that anymore.
function DataArrival disappeared together with LUA 4 about 5 years ago as well.
Arrivals are now split in 1 per protocol command.
What documentation have you used while converting this script ?
EDIT:
On closer look, I don't think you have converted shit.
--// This function is fired when an operator disconnects
function OpDisconnected(curUser)
Core.GetUserAllData(curUser)
sConnectlog = sConnectlog .. "\n" .. "<"..date("%c|") .. curUser.sNick .. "|" .. curUser.sIP .. "> " .. "Operator Disconnected"
end
I only know of 1 tool writing such code, we can use it as its signature; Hungarista's API Converter
My conclusion: You just took an old script, dumped it in the Converter, removed the line giving credit to the converter, and posted it here as being your work >:( I hope you can proof me wrong
noob patrick!!
can someone please lock down his posts. He just takes old scripts available on hub and then just uses convertor and posts as if its his work!!