PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Request for scripts => Topic started by: Dreams on 24 March, 2010, 23:04:21

Title: ShareChecker
Post by: Dreams on 24 March, 2010, 23:04:21
Im in need of a script like this script --> ShareCheck 1.01 - LUA 5.1 by Herman
Can get that script to work on the newest ptokax.. is there a script like that one or can i get the ShareCheck script somewhere working?

It would be so simple to clean others share if i had that script.

Regards //
Title: Re: ShareChecker
Post by: DeAn on 25 March, 2010, 16:34:56
What does this script do ?



Thanks,
DeAn
Title: Re: ShareChecker
Post by: Dreams on 25 March, 2010, 22:09:30
Dean: in this script you can add a list with users whos share hasnt been cleaned so that every OP can se it, so that every OP on the hub doesnt send clean to the same user all the time, and the users who has gotten cleaned can be added to a cleaned user list.. im not that good at explaining but i hope you understod.

Mutor: So then that is what i will post..

http://forum.ptokax.org/index.php?topic=8199.0 (http://forum.ptokax.org/index.php?topic=8199.0)
Title: Re: ShareChecker
Post by: DeAn on 26 March, 2010, 08:28:14
Quote from: Dreams on 25 March, 2010, 22:09:30
Dean: in this script you can add a list with users whos share hasnt been cleaned so that every OP can se it, so that every OP on the hub doesnt send clean to the same user all the time, and the users who has gotten cleaned can be added to a cleaned user list.. im not that good at explaining but i hope you understod.

Sorry Dreams, but I didn't get it. Clean in what sense ?



Thanks,
DeAn
Title: Re: ShareChecker
Post by: Dreams on 26 March, 2010, 11:10:52
Every user on the hub is listed on one list, cause they havnt been cleaned by an OP, but when an OP has sent them clean, they appear on a list where all OPs has sent clean to users, so they wont have to be cleaned anymore for example a week, then they apear on the non cleaned user list again and so on.. This script is for the OP/Owners who has a large hub, you just cant clean everyone and do a good job when you have around some hundreds/thousends of users =) this is a must to have if you have a private large hub.
Title: Re: ShareChecker
Post by: Dreams on 12 April, 2010, 23:27:44
So i did find a script for this, that i translated into english.. But i have some requests, that i wish could be done.

First, a little fix. When restarting the script, the tSC_list should only be in script/Sharecheck but it gets but in a folder under ptokax too.

And second, if someone has the time, would be nice with a sorted RC.

Have tested it a little bit and it works fine except for this little fix i requested.

--[[

ShareCheck 2.03 - LUA 5.11   [API 2]  by Herman
???????????????????????????????????????
To get control over what users share in Private Hubbs.

--Content
Best idea on which user to check at the moment.
Info on when a users last got checked.
Statistics and lists.
And more...

--Short help on how it works
You can get a proposal on a user in the RC and put the user in "pulled".
When the user is checked and done you put the user under "done".
You can put a user under "check" if you dont have time right now but the users share has to be checked.

-----------------------------------------
1.01 - changelog
added clean mem function
changed some formating
changed  the way to upgrade the sorted list
fixed a few small bugs
added some more things on show info on user
added new RC "myinfo"
-----------------------------------------
-----------------------------------------
1.02 - changelog
added option to change opname
added hub info
fixed so exlude works on checked users
some changes in myinfo
formating and optimization
-----------------------------------------
2.01 - changelog
upgrade to -API 2-
-----------------------------------------
2.02 - changelog
Bugfix - forgott to upgrade a part
-----------------------------------------
2.03 - changelog
Bugfix - To much copy and paste when upgrading
Bugfix - Found a problem with makelist that should have happend in the future

-----------------------------------------
-------------------------------------------------
---Not Added functions. maybe later---
-------------------------------------------------
RC remove "Done"
cleanup of database
----------------------------------------------
]]--

tSettings = {

-- Bot Name
sBot_I = "-Informer-",

-- Who will get the errormessages
AdminNick = "Herman",

-- Max amount for the sorted list of users who will get checked.
-- 1000 should work for most. But if you have a really large hub (increase) or if you want to save resources (decrease) the amount of users in the list
iMaxList = 1000,

-- Day of start of the week check, if you have a requirement on the amount of filelists per week
-- (as a decimal number with Sunday as 0 (0-6) )
iDay = 5,

-- RightClick Menu
sMenu = "?  Commands\\Share Check Commands",

-- Directory for files
filedir = "Sharecheck\\",

-- User DB
fuserDB = "tSC_user.tbl",

-- OP DB
fopDB = "tSC_op.tbl",

-- Check DB
fcheckDB = "tSC_check.tbl",

-- Pulled DB
fpulledDB = "tSC_pulled.tbl",

-- Sorted List With Users Who Has To Get Checked
flistDB = "tSC_list.tbl",

-- Log with users that is done
fdoneLOG = "tSC_done.log",

-- Profils who will see admin commands.
tAdminRCcmds = {[0] = 1, [1] = 0, [2] = 0, [3] = 0},

-- Exlude people in the list of users to check = flistDB
-- Profiles that will be exluded ( = 1 )
tProfiles = { [0] = 1, [1] = 1, [2] = 0, [3] = 0 },

-- User that will not be checked -- Use lowercase
tUser = {[""] = 1,[""] = 1},

-- Prefix that not will be checked -- Use lowercase
tPrefix = {
"[Crew]",
"[]"
}
}

--===============================================================================================================
--     Edit below this on your own risk.                 No support if you do :P
--===============================================================================================================

-- username <> times checked, last check, op checked
tuserDB = {} --  ( iCounter, iTime, sOP )

-- opname <> filelist checked, first time checked, last week
topDB = {} --( iCounter, iTime )

-- username <> op reported, time
tcheckDB = {} --( iTime, sOP )

-- username <> op checked, time
tpulledDB = {} --( iTime, sOP )

-- username
tlistDB = {}

-- static numbers
statWeek = 604800
statDay = 86400
statHour = 3600

OnStartup = function()
-- Register BotName if not registered
if tSettings.sBot_I ~= SetMan.GetString(21) then Core.RegBot(tSettings.sBot_I,"","",true) end
-- Load DB content
--os.execute("mkdir "..tSettings.filedir)
local r,e = os.rename("web","web")
if e then
if not e:find("Permission denied") then
os.execute("mkdir "..tSettings.filedir)
end
end
if loadfile(tSettings.filedir..tSettings.flistDB) then dofile(tSettings.filedir..tSettings.flistDB) end
if loadfile(tSettings.filedir..tSettings.fpulledDB) then dofile(tSettings.filedir..tSettings.fpulledDB) end
if loadfile(tSettings.filedir..tSettings.fcheckDB) then dofile(tSettings.filedir..tSettings.fcheckDB) end
if loadfile(tSettings.filedir..tSettings.fuserDB) then dofile(tSettings.filedir..tSettings.fuserDB) end
if loadfile(tSettings.filedir..tSettings.fopDB) then dofile(tSettings.filedir..tSettings.fopDB) end


-- Make a sorted list of users who shall be checked if it not exist or is to small
if not next(tlistDB) then
MakeCheckList()
end
end

NewUserConnected = function(user)

local tRealNick = GetRealNick(user.sNick,tpulledDB)
if tRealNick then
Core.SendPmToNick(tpulledDB[tRealNick].sOP, tSettings.sBot_I, "ShareCheck: User: "..user.sNick.." has connected. Can be found in your pulled")
end

--tAdmin = 1,
--tAdminRCcmds = {[0]
if Core.GetUserAllData(user) then
-- Supports UserCommands
if user.bUserCommand and user.bOperator then
-- For each entry in table
for i, v in pairs(tCommands) do
-- If member
if v.tAdmin == 1 then
if tSettings.tAdminRCcmds[user.iProfile] == 1 then
-- For each type
for n in ipairs(v.tRC) do
-- Send
Core.SendToNick(user.sNick,"$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
"$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
end
end

else
for n in ipairs(v.tRC) do
-- Send
Core.SendToNick(user.sNick,"$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
"$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
end
end
end
for i, v in pairs(tCommands2) do
-- If member
if v.tAdmin == 1 then
if tSettings.tAdminRCcmds[user.iProfile] == 1 then
-- For each type
for n in ipairs(v.tRC) do
-- Send
Core.SendToNick(user.sNick,"$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
"$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
end
end
else
for n in ipairs(v.tRC) do
-- Send
Core.SendToNick(user.sNick,"$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
"$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
end
end
end
end
end
end

OpConnected = NewUserConnected

ChatArrival = function(user, data)
local _,_, to = string.find(data, "^$To:%s(%S+)%s+From:")
local _,_, msg = string.find(data, "%b<>%s(.*)|$")
-- Message sent to Bot or in Main
if (to and to == tSettings.sBot_I) or not to then
-- Parse command
local _,_, cmd = string.find(msg, "^%p(%S+)")
-- Exists
if cmd and tCommands[string.lower(cmd)] then

if Core.GetUserAllData(user) and user.bOperator then

cmd, user.SendPM = string.lower(cmd), user.SendData
-- PM
if to == tSettings.sBot_I then user.SendPM = user.SendPM end

if tCommands[cmd].tAdmin == 1 then
if tSettings.tAdminRCcmds[user.iProfile] == 1 then
return tCommands[cmd].fFunction(user, msg), true
else
return Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: You are not allowed to use this command!"), true
end
else
return tCommands[cmd].fFunction(user, msg), true
end
else
return Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: You are not allowed to use this command!"), true
end

elseif cmd and tCommands2[string.lower(cmd)] then
if Core.GetUserAllData(user) and user.bOperator then
cmd, user.SendPM = string.lower(cmd), user.SendData
-- PM
if to == tSettings.sBot_I then user.SendPM = user.SendPM end
-- If user has permission
if tCommands2[cmd].tAdmin == 1 then
if tSettings.tAdminRCcmds[user.iProfile] == 1 then
return tCommands2[cmd].fFunction(user, msg), true
else
return Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: You are not allowed to use this command!"), true
end

else
return tCommands2[cmd].fFunction(user, msg), true
end
else
return Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: You are not allowed to use this command!"), true
end
end
end
end

ToArrival = ChatArrival

tCommands2 = {
suggestiononuser = {
fFunction = function(user, data)
--loops through check first to see if someone is online
if next(tcheckDB) then
for i, v in pairs(tcheckDB) do
if Core.GetUser(i) then
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: The most recommended user to check right now -->  "..i)
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: Remember to add the user to the pulled list before you begin")
return true
end
end
end
--if there is no hits in check list the other list loops through and takes the first person online
if next(tlistDB) then
for i = 1, table.maxn(tlistDB), 1 do
if Core.GetUser(tlistDB[i]) then
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: The most recommended user to check right now -->  "..tlistDB[i])
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: Remember to add the user to the pulled list before you begin")
return true
end
end
end
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: Has no one to recommend right now, but will update the database, so try again later.")
MakeCheckList()

end,
tAdmin = 0,
tRC = { { "Best Idea On User To Check", "" } }
},
sharecheck = {
fFunction = function(user, data)
local _,_, nick,typ = string.find(data, "^%S+%s+(%S+)%s+(%S+)$")

if nick and typ then

if typ == "pulled" then
if GetRealNick(nick,tpulledDB) then
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: "..nick.." is already in the pulled list.")
else

local sText = ""
for i, v in pairs(RegMan.GetRegs()) do
if string.lower(v.sNick)==string.lower(nick) then
tpulledDB[v.sNick] ={iTime=os.time(os.date("*t")),sOP=user.sNick}
local hFile = io.open(tSettings.filedir..tSettings.fpulledDB, "w+") Serialize(tpulledDB, "tpulledDB", hFile); hFile:close()
sText = "*** Was successful:"
end
end
if sText == "" then
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Failed: "..nick.." isn't a registered user! Check the nick again")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "ShareCheck: Added "..nick.." to the pulled list")

-- Remove the user from sorted check list
if next(tlistDB) then
for i = 1, table.maxn(tlistDB), 1 do
if string.lower(tlistDB[i]) == string.lower(nick)  then
--tlistDB[i] = nil
table.remove (tlistDB , i)
local hFile = io.open(tSettings.filedir..tSettings.flistDB, "w+") Serialize(tlistDB, "tlistDB", hFile); hFile:close()
break
end
end
end

-- Remove the user from check
local tRealNick = GetRealNick(nick,tcheckDB)
if tRealNick then
tcheckDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fcheckDB, "w+") Serialize(tcheckDB, "tcheckDB", hFile); hFile:close()
end
end
end
elseif typ == "check"  then
if GetRealNick(nick,tcheckDB) then
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: "..nick.." is already in the check list.")
else
local sText = ""
for i, v in pairs(RegMan.GetRegs()) do
if string.lower(v.sNick)==string.lower(nick) then
tcheckDB[v.sNick] ={iTime=os.time(os.date("*t")),sOP=user.sNick}
local hFile = io.open(tSettings.filedir..tSettings.fcheckDB, "w+") Serialize(tcheckDB, "tcheckDB", hFile); hFile:close()
sText = "*** Was successful:"
end
end
if sText == "" then
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Failed: "..nick.." isn't a registered user! Check the nick again")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "ShareCheck: Added "..nick.." to the check list")
end
end
elseif typ == "done" then

-- Check if the user is avalible
local iIsReg = 0
for i, v in pairs(RegMan.GetRegs()) do
if string.lower(v.sNick)==string.lower(nick) then

-- Add to done logfile
local hFile = io.open(tSettings.filedir..tSettings.fdoneLOG, "a+")
local tTime = os.time(os.date("*t"))

hFile:write(os.date("%Y-%m-%d %H:%M ",tTime)..nick.." "..user.sNick.." ".."\r\n")
hFile:close()

-- Remove the user from pulled
local tRealNick = GetRealNick(nick,tpulledDB)
if tpulledDB[tRealNick] then
tpulledDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fpulledDB, "w+") Serialize(tpulledDB, "tpulledDB", hFile); hFile:close()
end

-- Remove the user from check
local tRealNick = GetRealNick(nick,tcheckDB)
if tRealNick then
tcheckDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fcheckDB, "w+") Serialize(tcheckDB, "tcheckDB", hFile); hFile:close()
end

-- Remove the user from sorted check list
if next(tlistDB) then
for i = 1, table.maxn(tlistDB), 1 do
if string.lower(tlistDB[i]) == string.lower(nick)  then
--tlistDB[i] = nil
table.remove (tlistDB , i)
local hFile = io.open(tSettings.filedir..tSettings.flistDB, "w+") Serialize(tlistDB, "tlistDB", hFile); hFile:close()
break
end
end
end

-- Add to stat to opDB
local tRealNick = GetRealNick(user.sNick,topDB)
if tRealNick then
topDB[tRealNick].iCounter = topDB[tRealNick].iCounter + 1
else
topDB[user.sNick] ={iTime=os.time(os.date("*t")),iCounter = 1}
end
local hFile = io.open(tSettings.filedir..tSettings.fopDB, "w+") Serialize(topDB, "topDB", hFile); hFile:close()


-- Add to userDB
local tRealNick = GetRealNick(nick,tuserDB)
if tRealNick then
tuserDB[tRealNick].iTime = os.time(os.date("*t"))
tuserDB[tRealNick].sOP = user.sNick
tuserDB[tRealNick].iCounter = tuserDB[tRealNick].iCounter + 1
else
tuserDB[nick] ={iTime=os.time(os.date("*t")),sOP=user.sNick,iCounter = 1}
end
local hFile = io.open(tSettings.filedir..tSettings.fuserDB, "w+") Serialize(tuserDB, "tuserDB", hFile); hFile:close()

-- Send info to all ops in main
Core.SendPmToOps(tSettings.sBot_I, "ShareCheck: "..user.sNick.." Added "..nick.." to the done list")
--
iIsReg = 1

end
end
-- Check if the person excisted or not
if iIsReg == 0 then Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Failed: "..nick.." isn't a registered user! Check the nick again") end


else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Syntax Error: You have to choose \"pulled\" , \"done\" or \"check\" ")
end
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Syntax Error: No nickname or type")
end
--clean Memory
CleanMem()
end,
tAdmin = 0,
tRC = { { "Add User", " %[line:Full Nickname] %[line:Type: pulled, done, check]" }, { "Add This User", " %[nick] %[line:Type: pulled, done, check]" } }
},
}


tCommands = {
sc_showuser = {
fFunction = function(user, data)
-- Return
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")

if nick then

local msg = "\r\n\r"..string.rep("-", 60).."\r\nUserInfo For "..nick..":\r\n"..string.rep("-", 60).."\r\n"
--msg = msg.."Username:      \t"..nick.."\r\n"


local tRealNick = GetRealNick(nick,tuserDB)
if tRealNick then
msg = msg.."Last Check:    \t"..os.date("%Y-%m-%d %H:%M",tuserDB[tRealNick].iTime).."\r\n"
msg = msg.."By Who:        \t"..tuserDB[tRealNick].sOP.."\r\n"
msg = msg.."Times checked: \t"..tuserDB[tRealNick].iCounter.."\r\n"
else
msg = msg.."Last Check:    \tNever\r\n"
end

local tRealNick1 = GetRealNick(nick,tpulledDB)
if tRealNick1 then
msg = msg.."In \"Pulled\":      \tYes by "..tpulledDB[tRealNick1].sOP.."\r\n"
else
msg = msg.."In \"Pulled\":      \tNo\r\n"
end
local tRealNick2 = GetRealNick(nick,tcheckDB)
if tRealNick2 then
msg = msg.."In \"Check\": \tYes\r\n"
else
msg = msg.."In \"Check\": \tNo\r\n"
end

msg = msg..string.rep("-", 60)
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")

end
end,
tAdmin = 0,
tRC = { { "Check Info\\Show Info On A User", " %[line:Full Nickname]" }, { "Check Info\\Show Info On This User", " %[nick]" } }
},
sc_showinfo = {
fFunction = function(user)

local msg = "\r\n\r"..string.rep("=", 40).."\r\nInformation On "..user.sNick..":\r\n"..string.rep("=", 40).."\r\n"
--msg = msg.."Username:      \t"..nick.."\r\n"


local tRealNick = GetRealNick(user.sNick,topDB)
if tRealNick then

--Weeklists
local tempDay = tonumber(os.date("%w"))
if tSettings.iDay > tempDay then tempDay = tempDay + 7 end
tempDay = tempDay - tSettings.iDay +7
local tWList = WeekList(0,1,tRealNick)
local tWListNow = WeekList(0,0,tRealNick)
--If you havnt done one yet you have to fill the values
if tWList[tRealNick] == nil then
tWList[tRealNick]={iCounter=0,iUsers="no users"}
end
if tWListNow[tRealNick] == nil then
tWListNow[tRealNick]={iCounter=0,iUsers="no users"}
end
--Average
local iDays = (os.time(os.date("*t")) - topDB[tRealNick].iTime)/statDay
local iAmount =string.format("%.2f", ((topDB[tRealNick].iCounter/iDays)*7))


--Pulled
--local iCount = 0
local sPulled ="\r\nPulled users:\r\n"
for i, v in pairs(tpulledDB) do
if string.lower(v.sOP)==string.lower(user.sNick) then
sPulled = sPulled..os.date("%Y-%m-%d %H:%M",v.iTime).."\t"..i.."\r\n"
--iCount = iCount + 1
end
end

msg = msg.."First filelist checked at:      \t"..os.date("%Y-%m-%d",topDB[tRealNick].iTime).."\r\n"
msg = msg.."Amount of lists checked:      \t"..topDB[tRealNick].iCounter.."\r\n"
msg = msg.."Average checked (week): \t"..iAmount.."\r\n\r\n"
msg = msg.."Checked present week: \t"..tWListNow[tRealNick].iCounter.." st\r\n"
msg = msg..tWListNow[tRealNick].iUsers.."\r\n\r"
msg = msg.."Checked the last "..tempDay.." days: \t"..tWList[tRealNick].iCounter.." st\r\n"
msg = msg..tWList[tRealNick].iUsers.."\r\n"
msg = msg..sPulled..""

else
msg = msg.."Your not in the database. You have to add a done filelist first\r\n"
end



msg = msg..string.rep("-", 80)
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
--clean Memory
CleanMem()


end,
tAdmin = 0,
tRC = { { "Check Info\\Show My Info", "" } }
},
sc_showhubinfo = {
fFunction = function(user)

local msg = "\r\n\r"..string.rep("=", 50).."\r\nStatistics On Filechecking Control In The Hub\r\n"..string.rep("=", 50).."\r\n"
--msg = msg.."Username:      \t"..nick.."\r\n"



--Amount checked
--Average checked
--First list checked
--Amount of OP
--OP whos checked the most - amount + name
-----------------------------------------
--Amount of users thats never been checked
--The most checked user - amount + person
--A users average times checked


if next(topDB) then
local iAchecked,iFirstChecked,iAmountOp,iMostOpAmount,sMostOp =0,0,0,0,""

-- Loop through hubbers
for i, v in pairs(topDB) do

iAChecked = iAchecked + v.iCounter

if iFirstChecked == 0 or v.iTime < iFirstChecked then
iFirstChecked = v.iTime
end

iAmountOp = iAmountOp + 1

if iMostOpAmount == 0 or v.iCounter > iMostOpAmount then
iMostOpAmount = v.iCounter
sMostOp = i
end


end

-- Average
local iDays = (os.time(os.date("*t")) - iFirstChecked)/statDay
local iAverageAmount =string.format("%.1f", ((iAchecked/iDays)*7))




msg = msg.."First filelist checked at:      \t\t"..os.date("%Y-%m-%d",iFirstChecked).."\r\n"
msg = msg.."Amount of lists checked:      \t\t"..iAchecked.." st\r\n"
msg = msg.."Average amount (week): \t\t"..iAverageAmount.." st\r\n"
msg = msg.."Amount of OP that has checked lists:\t"..iAmountOp.." st\r\n"
msg = msg.."OP whos checked the most lists: \t"..sMostOp.." , "..iMostOpAmount.." st\r\n\r\n"



local iAUser,iUserChecked,iNotChecked,iMostChecked,sMostChecked,iAverage = 0,0,0,0,"",0

for i, v in pairs(tuserDB) do

iAUser = iAUser +1
iUserChecked = iUserChecked + v.iCounter

if iMostChecked == 0 or v.iCounter > iMostChecked then
iMostChecked = v.iCounter
sMostChecked = i
end
end

iNotChecked = table.maxn(RegMan.GetRegs()) - iAUser
iAverage = string.format("%.2f",iUserChecked/table.maxn(RegMan.GetRegs()))

msg = msg.."Users thats been checked:\t\t"..iAUser.." st\r\n"
msg = msg.."Users thats never been checked:\t"..iNotChecked.." st\r\n"
msg = msg.."The most checked user: \t\t"..sMostChecked.." , "..iMostChecked.." ggr\r\n"
msg = msg.."Amount of times users been checked:\t"..iAverage.." ggr\r\n"



else
msg = msg.."There is no OPdatabase\r\n"
end

msg = msg..string.rep("-", 100)
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
--clean Memory
CleanMem()

end,
tAdmin = 0,
tRC = { { "Check Info\\Show Hub Info", "" } }
},
scop_delpulled = {
fFunction = function(user, data)
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")

if nick then
local tRealNick = GetRealNick(nick,tpulledDB)
if tRealNick then
tpulledDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fpulledDB, "w+") Serialize(tpulledDB, "tpulledDB", hFile); hFile:close()
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: "..nick.." is removed from the pulled list")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: "..nick.." isn't found in the pulled list")
end
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Syntax Error: Add nickname")
end

end,
tAdmin = 1,
tRC = { { "Owners List\\Remove User From The Pulled List", " %[line:Nick]" } }
},
scop_delcheck = {
fFunction = function(user, data)
-- Return
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")
if nick then
local tRealNick = GetRealNick(nick,tcheckDB)
if tRealNick then
tcheckDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fcheckDB, "w+") Serialize(tcheckDB, "tcheckDB", hFile); hFile:close()
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: "..nick.." is removed from the check list")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: "..nick.." isn't found in the check list")
end
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Syntax Error: Add nickname")
end

end,
tAdmin = 1,
tRC = { { "Owners List\\Remove User From The Check List", " %[line:Nick]" } }
},
sc_donelist = {
fFunction = function(user)
local f = io.open(tSettings.filedir..tSettings.fdoneLOG,"r") --if f then f:close()
if f then
local msg = "\r\n\r"..string.rep("=", 47).."\r\nUsers That "..user.sNick.." Has Done\r\n"..string.rep("-", 94).."\r\n"
msg = msg.."Checked At\tOP Who Added \tUser\r\n"..string.rep("-", 94).."\r\n"

for line in f:lines() do
local _,_, iTime,sUser,sOp = string.find(line, "(%S+%s%S+)%s(%S+)%s(%S+)")
if string.lower(sOp) == string.lower(user.sNick) then
msg = msg..iTime.."\t"..sOp.."  \t"..sUser.."\r\n"
end
end

msg = msg..string.rep("-", 94)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")

f:close()
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: There's no done logfile")
end
end,
tAdmin = 0,
tRC = { { "Check List\\Users I Have Done", " %[Nick]" } }
},
sc_pulledlist = {
fFunction = function(user, data)
-- Table isn't empty
if next(tpulledDB) then
local _,_, tVar = string.find(data, "^%S+%s+(%S+)$")

local msg = "\r\n\r"..string.rep("=", 47).."\r\nUsers In The Pulled List:\r\n"..string.rep("-", 94).."\r\n"
msg = msg.."Added At\t\tOP Who Added\tUser\r\n"..string.rep("-", 94).."\r\n"
local tCopy ={}
-- Loop through hubbers

for i, v in pairs(tpulledDB) do
-- Insert stats to temp table
if tVar == "me" and string.lower(v.sOP)==string.lower(user.sNick) then
table.insert(tCopy, { sUser = i, iTime = v.iTime, sOP =v.sOP } )
elseif tVar == "all" then
table.insert(tCopy, { sUser = i, iTime = v.iTime, sOP =v.sOP } )
end
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iTime < b.iTime) end)
-- Loop through temp table

for i, v in pairs(tCopy) do
msg = msg..os.date("%Y-%m-%d %H:%M",v.iTime).."\t"..v.sOP.."  \t"..v.sUser.."\r\n"
end

msg = msg..string.rep("-", 94)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: Pulled list is empty")
end
end,
tAdmin = 0,
tRC = { { "Check List\\All Users Whos Filelists Has Been Pulled", " all" }, { "Check List\\All Users Whos Filelists I Have Pulled", " me" } }
},
sc_checklist = {
fFunction = function(user)
-- Table isn't empty
if next(tcheckDB) then

local msg = "\r\n\r"..string.rep("=", 47).."\r\nUsers In The Check List:\r\n"..string.rep("-", 94).."\r\n"
msg = msg.."Added At\t\tUser\t\tOP Who Added\r\n"..string.rep("-", 94).."\r\n"
local tCopy ={}
-- Loop through hubbers

for i, v in pairs(tcheckDB) do
-- Insert stats to temp table
table.insert(tCopy, { sUser = i, iTime = v.iTime, sOP =v.sOP } )
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iTime < b.iTime) end)
-- Loop through temp table

for i, v in pairs(tCopy) do
msg = msg..os.date("%Y-%m-%d %H:%M",v.iTime).."\t"..v.sUser.."\t"..v.sOP.."\r\n"
end

msg = msg..string.rep("-", 94)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: Check list is empty")
end
end,
tAdmin = 0,
tRC = { { "Check List\\Users Who Has To Be Checked", "" } }
},
sc_toplist = {
fFunction = function(user)
if next(topDB) then

local msg = "\r\n\r"..string.rep("=", 40).."\r\nTop Filelist Checker:\r\n"..string.rep("-", 80).."\r\n"
msg = msg.."Amount\t\tOp\r\n"..string.rep("-", 80).."\r\n"
local tCopy ={}
-- Loop through hubbers
for i, v in pairs(topDB) do
-- Insert stats to temp table
table.insert(tCopy, { sOp = i, iAmount = v.iCounter } )
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iAmount > b.iAmount) end)
-- Loop through temp table
for i, v in pairs(tCopy) do
msg = msg..""..v.iAmount.."\t\t"..v.sOp.."\r\n"
end

msg = msg..string.rep("-", 80)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: There is no OPstats list")
end
end,
tAdmin = 0,
tRC = { { "Check List\\Total Amount Done", "" }}
},
scop_donelistowner = {
fFunction = function(user, data)
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")
if nick then
local f = io.open(tSettings.filedir..tSettings.fdoneLOG,"r")
if f then
local msg = "\r\n\r"..string.rep("=", 47).."\r\nUsers Who Is Done\r\n"..string.rep("-", 94).."\r\n"
msg = msg.."Checked At\tOP Who Added\tUser\r\n"..string.rep("-", 94).."\r\n"

if nick == "all" then
for line in f:lines() do
local _,_, iTime,sUser,sOp = string.find(line, "(%S+%s%S+)%s(%S+)%s(%S+)")
msg = msg..iTime.."\t"..sOp.."\t"..sUser.."\r\n"
end
else
for line in f:lines() do
local _,_, iTime,sUser,sOp = string.find(line, "(%S+%s%S+)%s(%S+)%s(%S+)")
if string.lower(sOp) == string.lower(nick) then
msg = msg..iTime.."\t"..sOp.."\t"..sUser.."\r\n"
end
end
end
msg = msg..string.rep("-", 94)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")

f:close()
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: There is no done logfile")
end
end
end,
tAdmin = 1,
tRC = { { "Owners List\\Show Users An OP Done", " %[line:OpNick]" }, { "Owners List\\Show All Done Users", " all" } }
},
scop_toplistaverage = {
fFunction = function(user)
-- Table isn't empty
if next(topDB) then

local msg = "\r\n\r"..string.rep("=", 40).."\r\nAverage Per Week:\r\n"..string.rep("-", 80).."\r\n"
msg = msg.."Average\tOP\r\n"..string.rep("-", 80).."\r\n"
local tCopy ={}

--iCounter, iTime )
local iNow = os.time(os.date("*t"))
local iDays, iAmount
-- Loop through hubbers
for i, v in pairs(topDB) do

iDays = (iNow - v.iTime)/statDay
iAmount =string.format("%.2f", ((v.iCounter/iDays)*7))


--iWeeks = math.ceil((iNow - v.iTime)/statWeek)
--iAmount =string.format("<%.2f>", (v.iCounter/iWeeks))

--local _,_,iAmount = string.find((v.iCounter/iWeeks),"(%d+%.?%d?)")




-- Insert stats to temp table
table.insert(tCopy, { sOp = i, iAverage = tonumber(iAmount) } )
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iAverage > b.iAverage) end)
-- Loop through temp table

for i, v in pairs(tCopy) do
msg = msg..""..v.iAverage.."\t"..v.sOp.."\r\n"
end

msg = msg..string.rep("-", 80)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: There is no one in the OPstats list")
end
end,
tAdmin = 1,
tRC = { { "Owners List\\Show The Average Amount Of Checked Users", "" }}
},
scop_weeklist = {
fFunction = function(user, data)
local _,_, tNumber = string.find(data, "^%S+%s+(%d+)$")
local _,_, tStartW,tStopW = string.find(data, "^%S+%s+(%d+)%-(%d+)$")
if tNumber or tStartW then


-- check what weeks user want to see
local iStartWeek,iStopWeek

if tStartW then
iStartWeek = tStartW
iStopWeek = tStopW
tNumber = tStartW.."-"..tStopW
else
iStartWeek = tNumber
iStopWeek = tNumber
end

local tWList = WeekList(iStartWeek,iStopWeek,nil)

-- Printing the list
local msg = "\r\n\r"..string.rep("=", 30).."\r\nShow Info On The Week/Weeks: "..tNumber.."\r\n"..string.rep("=", 30).."\r\n"
for i, v in pairs(tWList) do
msg = msg..""..i.." has done "..v.iCounter.." users.\r\n\r\n"..v.iUsers.."\r\n"..string.rep("-", 60).."\r\n"
end

Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
tWList ={}

end
end,
tAdmin = 1,
tRC = {{ "Owners List\\Show How Many Users Is Done - A Week", " %[line:0=present, 1=former, 0-4=several weeks]" } }
},
}

MakeCheckList = function()
local iCounter = 0
local tBol
tlistDB = {}

for i, v in pairs(RegMan.GetRegs()) do
--not checked before
if not GetRealNick(v.sNick,tuserDB) then
-- allowed profile
if tSettings.tProfiles[v.iProfile] and tSettings.tProfiles[v.iProfile] == 1 then

else
--allowed user
if not tSettings.tUser[string.lower(v.sNick)] then
--allowed prefix
tBol = 0
for key, tFix in pairs(tSettings.tPrefix) do
if string.sub(string.lower(v.sNick),1,string.len(tFix)) == string.lower(tFix) then
tBol = 1
end
end
if tBol == 0 then

table.insert(tlistDB,v.sNick)
iCounter = iCounter + 1

if iCounter >= tSettings.iMaxList then
break
end
end
end
end
end
end


if iCounter < tSettings.iMaxList then
local tCopy = {}
for i, v in pairs(tuserDB) do
if not tSettings.tUser[string.lower(i)] then
--allowed prefix
tBol = 0
for key, tFix in pairs(tSettings.tPrefix) do
if string.sub(string.lower(i),1,string.len(tFix)) == string.lower(tFix) then
tBol = 1
end
end
if tBol == 0 then
table.insert(tCopy, { sUser = i, iTime = v.iTime} )
end
end
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iTime < b.iTime) end)
-- Loop through temp table
for i = 1, table.maxn(tCopy), 1 do
-- i exists
if tCopy[i] then
-- Populate
table.insert(tlistDB,tCopy[i].sUser)
iCounter = iCounter + 1
if iCounter >= tSettings.iMaxList then
break
end
end
end
tCopy = {}
end
--save the list
local hFile = io.open(tSettings.filedir..tSettings.flistDB, "w+") Serialize(tlistDB, "tlistDB", hFile); hFile:close()
CleanMem()
end


function WeekList(startw,stopw,user)
local tTempW = {}
local f = io.open(tSettings.filedir..tSettings.fdoneLOG,"r") --if f then f:close()
if f then
-- calculate time in seconds to the last "check time"
local iNow = os.time(os.date("*t"))
local tempDay = tonumber(os.date("%w",iNow))
if tSettings.iDay > tempDay then tempDay = tempDay + 7 end
tempDay = tempDay - tSettings.iDay
local iDiffSec = tempDay*statDay + os.date("%H",iNow)*statHour + os.date("%M",iNow)*60 + os.date("%S",iNow)
local iCheckStart = iNow - iDiffSec

for line in f:lines() do
local _,_, iY,iM,iD,iMin,iS,sUser,sOp = string.find(line, "(%d+)%-(%d+)%-(%d+)%s(%d+)%:(%d+)%s(%S+)%s(%S+)")

if user and string.lower(user) == string.lower(sOp) or not user then

local iTime = os.time({ year = iY, month = iM, day = iD, hour = iH, min = iMin, sec = iS})
local iStop = iCheckStart - (statWeek*stopw)    
local iStart = iCheckStart - (statWeek*startw) + statWeek            

if tonumber(iTime) < tonumber(iStart) and tonumber(iTime) > tonumber(iStop) then
if tTempW[sOp] then
tTempW[sOp].iCounter=tTempW[sOp].iCounter+1
tTempW[sOp].iUsers=tTempW[sOp].iUsers..sUser.." , "
else
tTempW[sOp]={iCounter=1,iUsers=sUser.." , "}
end
end
end
end
f:close()
end
return tTempW

end

-- Clean the memory
function CleanMem()
collectgarbage()
io.flush()
end

OnError = function(msg)
Core.SendPmToNick("Herman", tSettings.sBot_I ,"<"..tSettings.sBot_I.."> "..msg)
Core.SendPmToNick(tSettings.AdminNick, tSettings.sBot_I ,"<"..tSettings.sBot_I.."> "..msg)
--OnError("----")
end

GetRealNick = function(user,db)
-- For each hubber
for i, v in pairs(db) do
-- Compare
if string.lower(i) == string.lower(user) then
-- Return
return i
end
end
end

Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n");
for key, value in pairs(tTable) do
if (type(value) ~= "function") then
local sKey = (type(key) == "string") and string.format("[%q]", key) or string.format("[%d]", key);
if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q", value) or tostring(value);
hFile:write(sTab.."\t"..sKey.." = "..sValue);
end
hFile:write(",\n");
end
end
hFile:write(sTab.."}");
end


Maybe not the best translated, but i think the most of you will understand it.

And to you Herman, hope you dont mind i translated it, its still your script and many thanks to you for creating it.
Title: Re: ShareChecker
Post by: TZB on 13 April, 2010, 07:02:52
Is the conversion of script done using Lua Convertor?
Title: Re: ShareChecker
Post by: Dreams on 13 April, 2010, 07:42:00
Not Converted, just translated from Swedish to English so that more people can use and enjoy this script.
Title: Re: ShareChecker
Post by: TZB on 13 April, 2010, 09:43:20
What kind of changes you need in Right Click.
If you can give it in more details it can be done in minutes.
Title: Re: ShareChecker
Post by: Dreams on 13 April, 2010, 10:01:18
If you look at the script there are these ---> Owners List, Check List and Check Info.
Under thoose three there are some buttons, would be nice if thoose buttons could be sorted by name.
Title: Re: ShareChecker
Post by: TZB on 13 April, 2010, 11:04:03
Those Unsorted Right Click options belonged to Check List According to me so added them up there.
The problem regarding the file getting saved under ptokax folder and Share Check i haven't come across it.May be you are using any Settings saving script and it makes a backup of all the .tbl file.
--[[

ShareCheck 2.03 - LUA 5.11   [API 2]  by Herman
???????????????????????????????????????
To get control over what users share in Private Hubbs.

--Content
Best idea on which user to check at the moment.
Info on when a users last got checked.
Statistics and lists.
And more...

--Short help on how it works
You can get a proposal on a user in the RC and put the user in "pulled".
When the user is checked and done you put the user under "done".
You can put a user under "check" if you dont have time right now but the users share has to be checked.

-----------------------------------------
1.01 - changelog
added clean mem function
changed some formating
changed  the way to upgrade the sorted list
fixed a few small bugs
added some more things on show info on user
added new RC "myinfo"
-----------------------------------------
-----------------------------------------
1.02 - changelog
added option to change opname
added hub info
fixed so exlude works on checked users
some changes in myinfo
formating and optimization
-----------------------------------------
2.01 - changelog
upgrade to -API 2-
-----------------------------------------
2.02 - changelog
Bugfix - forgott to upgrade a part
-----------------------------------------
2.03 - changelog
Bugfix - To much copy and paste when upgrading
Bugfix - Found a problem with makelist that should have happend in the future

-----------------------------------------
-------------------------------------------------
---Not Added functions. maybe later---
-------------------------------------------------
RC remove "Done"
cleanup of database
----------------------------------------------
       
        13/04/2010
        Fixed Right Click Requested:Dreams By ||-T-z-B-||
]]--

tSettings = {

-- Bot Name
sBot_I = "-Informer-",

-- Who will get the errormessages
AdminNick = "Herman",

-- Max amount for the sorted list of users who will get checked.
-- 1000 should work for most. But if you have a really large hub (increase) or if you want to save resources (decrease) the amount of users in the list
iMaxList = 1000,

-- Day of start of the week check, if you have a requirement on the amount of filelists per week
-- (as a decimal number with Sunday as 0 (0-6) )
iDay = 5,

-- RightClick Menu
sMenu = "?  Commands\\Share Check Commands",

-- Directory for files
filedir = "Sharecheck\\",

-- User DB
fuserDB = "tSC_user.tbl",

-- OP DB
fopDB = "tSC_op.tbl",

-- Check DB
fcheckDB = "tSC_check.tbl",

-- Pulled DB
fpulledDB = "tSC_pulled.tbl",

-- Sorted List With Users Who Has To Get Checked
flistDB = "tSC_list.tbl",

-- Log with users that is done
fdoneLOG = "tSC_done.log",

-- Profils who will see admin commands.
tAdminRCcmds = {[0] = 1, [1] = 0, [2] = 0, [3] = 0},

-- Exlude people in the list of users to check = flistDB
-- Profiles that will be exluded ( = 1 )
tProfiles = { [0] = 1, [1] = 1, [2] = 0, [3] = 0 },

-- User that will not be checked -- Use lowercase
tUser = {[""] = 1,[""] = 1},

-- Prefix that not will be checked -- Use lowercase
tPrefix = {
"[Crew]",
"[]"
}
}

--===============================================================================================================
--     Edit below this on your own risk.                 No support if you do :P
--===============================================================================================================

-- username <> times checked, last check, op checked
tuserDB = {} --  ( iCounter, iTime, sOP )

-- opname <> filelist checked, first time checked, last week
topDB = {} --( iCounter, iTime )

-- username <> op reported, time
tcheckDB = {} --( iTime, sOP )

-- username <> op checked, time
tpulledDB = {} --( iTime, sOP )

-- username
tlistDB = {}

-- static numbers
statWeek = 604800
statDay = 86400
statHour = 3600

OnStartup = function()
-- Register BotName if not registered
if tSettings.sBot_I ~= SetMan.GetString(21) then Core.RegBot(tSettings.sBot_I,"","",true) end
-- Load DB content
--os.execute("mkdir "..tSettings.filedir)
local r,e = os.rename("web","web")
if e then
if not e:find("Permission denied") then
os.execute("mkdir "..tSettings.filedir)
end
end
if loadfile(tSettings.filedir..tSettings.flistDB) then dofile(tSettings.filedir..tSettings.flistDB) end
if loadfile(tSettings.filedir..tSettings.fpulledDB) then dofile(tSettings.filedir..tSettings.fpulledDB) end
if loadfile(tSettings.filedir..tSettings.fcheckDB) then dofile(tSettings.filedir..tSettings.fcheckDB) end
if loadfile(tSettings.filedir..tSettings.fuserDB) then dofile(tSettings.filedir..tSettings.fuserDB) end
if loadfile(tSettings.filedir..tSettings.fopDB) then dofile(tSettings.filedir..tSettings.fopDB) end


-- Make a sorted list of users who shall be checked if it not exist or is to small
if not next(tlistDB) then
MakeCheckList()
end
end

NewUserConnected = function(user)

local tRealNick = GetRealNick(user.sNick,tpulledDB)
if tRealNick then
Core.SendPmToNick(tpulledDB[tRealNick].sOP, tSettings.sBot_I, "ShareCheck: User: "..user.sNick.." has connected. Can be found in your pulled")
end

--tAdmin = 1,
--tAdminRCcmds = {[0]
if Core.GetUserAllData(user) then
-- Supports UserCommands
if user.bUserCommand and user.bOperator then
-- For each entry in table
for i, v in pairs(tCommands) do
-- If member
if v.tAdmin == 1 then
if tSettings.tAdminRCcmds[user.iProfile] == 1 then
-- For each type
for n in ipairs(v.tRC) do
-- Send
Core.SendToNick(user.sNick,"$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
"$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
end
end

else
for n in ipairs(v.tRC) do
-- Send
Core.SendToNick(user.sNick,"$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
"$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
end
end
end
for i, v in pairs(tCommands2) do
-- If member
if v.tAdmin == 1 then
if tSettings.tAdminRCcmds[user.iProfile] == 1 then
-- For each type
for n in ipairs(v.tRC) do
-- Send
Core.SendToNick(user.sNick,"$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
"$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
end
end
else
for n in ipairs(v.tRC) do
-- Send
Core.SendToNick(user.sNick,"$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
"$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
end
end
end
end
end
end

OpConnected = NewUserConnected

ChatArrival = function(user, data)
local _,_, to = string.find(data, "^$To:%s(%S+)%s+From:")
local _,_, msg = string.find(data, "%b<>%s(.*)|$")
-- Message sent to Bot or in Main
if (to and to == tSettings.sBot_I) or not to then
-- Parse command
local _,_, cmd = string.find(msg, "^%p(%S+)")
-- Exists
if cmd and tCommands[string.lower(cmd)] then

if Core.GetUserAllData(user) and user.bOperator then

cmd, user.SendPM = string.lower(cmd), user.SendData
-- PM
if to == tSettings.sBot_I then user.SendPM = user.SendPM end

if tCommands[cmd].tAdmin == 1 then
if tSettings.tAdminRCcmds[user.iProfile] == 1 then
return tCommands[cmd].fFunction(user, msg), true
else
return Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: You are not allowed to use this command!"), true
end
else
return tCommands[cmd].fFunction(user, msg), true
end
else
return Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: You are not allowed to use this command!"), true
end

elseif cmd and tCommands2[string.lower(cmd)] then
if Core.GetUserAllData(user) and user.bOperator then
cmd, user.SendPM = string.lower(cmd), user.SendData
-- PM
if to == tSettings.sBot_I then user.SendPM = user.SendPM end
-- If user has permission
if tCommands2[cmd].tAdmin == 1 then
if tSettings.tAdminRCcmds[user.iProfile] == 1 then
return tCommands2[cmd].fFunction(user, msg), true
else
return Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: You are not allowed to use this command!"), true
end

else
return tCommands2[cmd].fFunction(user, msg), true
end
else
return Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: You are not allowed to use this command!"), true
end
end
end
end

ToArrival = ChatArrival

tCommands2 = {
suggestiononuser = {
fFunction = function(user, data)
--loops through check first to see if someone is online
if next(tcheckDB) then
for i, v in pairs(tcheckDB) do
if Core.GetUser(i) then
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: The most recommended user to check right now -->  "..i)
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: Remember to add the user to the pulled list before you begin")
return true
end
end
end
--if there is no hits in check list the other list loops through and takes the first person online
if next(tlistDB) then
for i = 1, table.maxn(tlistDB), 1 do
if Core.GetUser(tlistDB[i]) then
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: The most recommended user to check right now -->  "..tlistDB[i])
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: Remember to add the user to the pulled list before you begin")
return true
end
end
end
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: Has no one to recommend right now, but will update the database, so try again later.")
MakeCheckList()

end,
tAdmin = 0,
tRC = { { "Check List\\Best Idea On User To Check", "" } }
},
sharecheck = {
fFunction = function(user, data)
local _,_, nick,typ = string.find(data, "^%S+%s+(%S+)%s+(%S+)$")

if nick and typ then

if typ == "pulled" then
if GetRealNick(nick,tpulledDB) then
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: "..nick.." is already in the pulled list.")
else

local sText = ""
for i, v in pairs(RegMan.GetRegs()) do
if string.lower(v.sNick)==string.lower(nick) then
tpulledDB[v.sNick] ={iTime=os.time(os.date("*t")),sOP=user.sNick}
local hFile = io.open(tSettings.filedir..tSettings.fpulledDB, "w+") Serialize(tpulledDB, "tpulledDB", hFile); hFile:close()
sText = "*** Was successful:"
end
end
if sText == "" then
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Failed: "..nick.." isn't a registered user! Check the nick again")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "ShareCheck: Added "..nick.." to the pulled list")

-- Remove the user from sorted check list
if next(tlistDB) then
for i = 1, table.maxn(tlistDB), 1 do
if string.lower(tlistDB[i]) == string.lower(nick)  then
--tlistDB[i] = nil
table.remove (tlistDB , i)
local hFile = io.open(tSettings.filedir..tSettings.flistDB, "w+") Serialize(tlistDB, "tlistDB", hFile); hFile:close()
break
end
end
end

-- Remove the user from check
local tRealNick = GetRealNick(nick,tcheckDB)
if tRealNick then
tcheckDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fcheckDB, "w+") Serialize(tcheckDB, "tcheckDB", hFile); hFile:close()
end
end
end
elseif typ == "check"  then
if GetRealNick(nick,tcheckDB) then
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: "..nick.." is already in the check list.")
else
local sText = ""
for i, v in pairs(RegMan.GetRegs()) do
if string.lower(v.sNick)==string.lower(nick) then
tcheckDB[v.sNick] ={iTime=os.time(os.date("*t")),sOP=user.sNick}
local hFile = io.open(tSettings.filedir..tSettings.fcheckDB, "w+") Serialize(tcheckDB, "tcheckDB", hFile); hFile:close()
sText = "*** Was successful:"
end
end
if sText == "" then
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Failed: "..nick.." isn't a registered user! Check the nick again")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "ShareCheck: Added "..nick.." to the check list")
end
end
elseif typ == "done" then

-- Check if the user is avalible
local iIsReg = 0
for i, v in pairs(RegMan.GetRegs()) do
if string.lower(v.sNick)==string.lower(nick) then

-- Add to done logfile
local hFile = io.open(tSettings.filedir..tSettings.fdoneLOG, "a+")
local tTime = os.time(os.date("*t"))

hFile:write(os.date("%Y-%m-%d %H:%M ",tTime)..nick.." "..user.sNick.." ".."\r\n")
hFile:close()

-- Remove the user from pulled
local tRealNick = GetRealNick(nick,tpulledDB)
if tpulledDB[tRealNick] then
tpulledDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fpulledDB, "w+") Serialize(tpulledDB, "tpulledDB", hFile); hFile:close()
end

-- Remove the user from check
local tRealNick = GetRealNick(nick,tcheckDB)
if tRealNick then
tcheckDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fcheckDB, "w+") Serialize(tcheckDB, "tcheckDB", hFile); hFile:close()
end

-- Remove the user from sorted check list
if next(tlistDB) then
for i = 1, table.maxn(tlistDB), 1 do
if string.lower(tlistDB[i]) == string.lower(nick)  then
--tlistDB[i] = nil
table.remove (tlistDB , i)
local hFile = io.open(tSettings.filedir..tSettings.flistDB, "w+") Serialize(tlistDB, "tlistDB", hFile); hFile:close()
break
end
end
end

-- Add to stat to opDB
local tRealNick = GetRealNick(user.sNick,topDB)
if tRealNick then
topDB[tRealNick].iCounter = topDB[tRealNick].iCounter + 1
else
topDB[user.sNick] ={iTime=os.time(os.date("*t")),iCounter = 1}
end
local hFile = io.open(tSettings.filedir..tSettings.fopDB, "w+") Serialize(topDB, "topDB", hFile); hFile:close()


-- Add to userDB
local tRealNick = GetRealNick(nick,tuserDB)
if tRealNick then
tuserDB[tRealNick].iTime = os.time(os.date("*t"))
tuserDB[tRealNick].sOP = user.sNick
tuserDB[tRealNick].iCounter = tuserDB[tRealNick].iCounter + 1
else
tuserDB[nick] ={iTime=os.time(os.date("*t")),sOP=user.sNick,iCounter = 1}
end
local hFile = io.open(tSettings.filedir..tSettings.fuserDB, "w+") Serialize(tuserDB, "tuserDB", hFile); hFile:close()

-- Send info to all ops in main
Core.SendPmToOps(tSettings.sBot_I, "ShareCheck: "..user.sNick.." Added "..nick.." to the done list")
--
iIsReg = 1

end
end
-- Check if the person excisted or not
if iIsReg == 0 then Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Failed: "..nick.." isn't a registered user! Check the nick again") end


else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Syntax Error: You have to choose \"pulled\" , \"done\" or \"check\" ")
end
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Syntax Error: No nickname or type")
end
--clean Memory
CleanMem()
end,
tAdmin = 0,
tRC = { { "Check List\\Add User", " %[line:Full Nickname] %[line:Type: pulled, done, check]" }, { "Check List\\Add This User", " %[nick] %[line:Type: pulled, done, check]" } }
},
}


tCommands = {
sc_showuser = {
fFunction = function(user, data)
-- Return
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")

if nick then

local msg = "\r\n\r"..string.rep("-", 60).."\r\nUserInfo For "..nick..":\r\n"..string.rep("-", 60).."\r\n"
--msg = msg.."Username:      \t"..nick.."\r\n"


local tRealNick = GetRealNick(nick,tuserDB)
if tRealNick then
msg = msg.."Last Check:    \t"..os.date("%Y-%m-%d %H:%M",tuserDB[tRealNick].iTime).."\r\n"
msg = msg.."By Who:        \t"..tuserDB[tRealNick].sOP.."\r\n"
msg = msg.."Times checked: \t"..tuserDB[tRealNick].iCounter.."\r\n"
else
msg = msg.."Last Check:    \tNever\r\n"
end

local tRealNick1 = GetRealNick(nick,tpulledDB)
if tRealNick1 then
msg = msg.."In \"Pulled\":      \tYes by "..tpulledDB[tRealNick1].sOP.."\r\n"
else
msg = msg.."In \"Pulled\":      \tNo\r\n"
end
local tRealNick2 = GetRealNick(nick,tcheckDB)
if tRealNick2 then
msg = msg.."In \"Check\": \tYes\r\n"
else
msg = msg.."In \"Check\": \tNo\r\n"
end

msg = msg..string.rep("-", 60)
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")

end
end,
tAdmin = 0,
tRC = { { "Check Info\\Show Info On A User", " %[line:Full Nickname]" }, { "Check Info\\Show Info On This User", " %[nick]" } }
},
sc_showinfo = {
fFunction = function(user)

local msg = "\r\n\r"..string.rep("=", 40).."\r\nInformation On "..user.sNick..":\r\n"..string.rep("=", 40).."\r\n"
--msg = msg.."Username:      \t"..nick.."\r\n"


local tRealNick = GetRealNick(user.sNick,topDB)
if tRealNick then

--Weeklists
local tempDay = tonumber(os.date("%w"))
if tSettings.iDay > tempDay then tempDay = tempDay + 7 end
tempDay = tempDay - tSettings.iDay +7
local tWList = WeekList(0,1,tRealNick)
local tWListNow = WeekList(0,0,tRealNick)
--If you havnt done one yet you have to fill the values
if tWList[tRealNick] == nil then
tWList[tRealNick]={iCounter=0,iUsers="no users"}
end
if tWListNow[tRealNick] == nil then
tWListNow[tRealNick]={iCounter=0,iUsers="no users"}
end
--Average
local iDays = (os.time(os.date("*t")) - topDB[tRealNick].iTime)/statDay
local iAmount =string.format("%.2f", ((topDB[tRealNick].iCounter/iDays)*7))


--Pulled
--local iCount = 0
local sPulled ="\r\nPulled users:\r\n"
for i, v in pairs(tpulledDB) do
if string.lower(v.sOP)==string.lower(user.sNick) then
sPulled = sPulled..os.date("%Y-%m-%d %H:%M",v.iTime).."\t"..i.."\r\n"
--iCount = iCount + 1
end
end

msg = msg.."First filelist checked at:      \t"..os.date("%Y-%m-%d",topDB[tRealNick].iTime).."\r\n"
msg = msg.."Amount of lists checked:      \t"..topDB[tRealNick].iCounter.."\r\n"
msg = msg.."Average checked (week): \t"..iAmount.."\r\n\r\n"
msg = msg.."Checked present week: \t"..tWListNow[tRealNick].iCounter.." st\r\n"
msg = msg..tWListNow[tRealNick].iUsers.."\r\n\r"
msg = msg.."Checked the last "..tempDay.." days: \t"..tWList[tRealNick].iCounter.." st\r\n"
msg = msg..tWList[tRealNick].iUsers.."\r\n"
msg = msg..sPulled..""

else
msg = msg.."Your not in the database. You have to add a done filelist first\r\n"
end



msg = msg..string.rep("-", 80)
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
--clean Memory
CleanMem()


end,
tAdmin = 0,
tRC = { { "Check Info\\Show My Info", "" } }
},
sc_showhubinfo = {
fFunction = function(user)

local msg = "\r\n\r"..string.rep("=", 50).."\r\nStatistics On Filechecking Control In The Hub\r\n"..string.rep("=", 50).."\r\n"
--msg = msg.."Username:      \t"..nick.."\r\n"



--Amount checked
--Average checked
--First list checked
--Amount of OP
--OP whos checked the most - amount + name
-----------------------------------------
--Amount of users thats never been checked
--The most checked user - amount + person
--A users average times checked


if next(topDB) then
local iAchecked,iFirstChecked,iAmountOp,iMostOpAmount,sMostOp =0,0,0,0,""

-- Loop through hubbers
for i, v in pairs(topDB) do

iAChecked = iAchecked + v.iCounter

if iFirstChecked == 0 or v.iTime < iFirstChecked then
iFirstChecked = v.iTime
end

iAmountOp = iAmountOp + 1

if iMostOpAmount == 0 or v.iCounter > iMostOpAmount then
iMostOpAmount = v.iCounter
sMostOp = i
end


end

-- Average
local iDays = (os.time(os.date("*t")) - iFirstChecked)/statDay
local iAverageAmount =string.format("%.1f", ((iAchecked/iDays)*7))




msg = msg.."First filelist checked at:      \t\t"..os.date("%Y-%m-%d",iFirstChecked).."\r\n"
msg = msg.."Amount of lists checked:      \t\t"..iAchecked.." st\r\n"
msg = msg.."Average amount (week): \t\t"..iAverageAmount.." st\r\n"
msg = msg.."Amount of OP that has checked lists:\t"..iAmountOp.." st\r\n"
msg = msg.."OP whos checked the most lists: \t"..sMostOp.." , "..iMostOpAmount.." st\r\n\r\n"



local iAUser,iUserChecked,iNotChecked,iMostChecked,sMostChecked,iAverage = 0,0,0,0,"",0

for i, v in pairs(tuserDB) do

iAUser = iAUser +1
iUserChecked = iUserChecked + v.iCounter

if iMostChecked == 0 or v.iCounter > iMostChecked then
iMostChecked = v.iCounter
sMostChecked = i
end
end

iNotChecked = table.maxn(RegMan.GetRegs()) - iAUser
iAverage = string.format("%.2f",iUserChecked/table.maxn(RegMan.GetRegs()))

msg = msg.."Users thats been checked:\t\t"..iAUser.." st\r\n"
msg = msg.."Users thats never been checked:\t"..iNotChecked.." st\r\n"
msg = msg.."The most checked user: \t\t"..sMostChecked.." , "..iMostChecked.." ggr\r\n"
msg = msg.."Amount of times users been checked:\t"..iAverage.." ggr\r\n"



else
msg = msg.."There is no OPdatabase\r\n"
end

msg = msg..string.rep("-", 100)
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
--clean Memory
CleanMem()

end,
tAdmin = 0,
tRC = { { "Check Info\\Show Hub Info", "" } }
},
scop_delpulled = {
fFunction = function(user, data)
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")

if nick then
local tRealNick = GetRealNick(nick,tpulledDB)
if tRealNick then
tpulledDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fpulledDB, "w+") Serialize(tpulledDB, "tpulledDB", hFile); hFile:close()
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: "..nick.." is removed from the pulled list")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: "..nick.." isn't found in the pulled list")
end
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Syntax Error: Add nickname")
end

end,
tAdmin = 1,
tRC = { { "Owners List\\Remove User From The Pulled List", " %[line:Nick]" } }
},
scop_delcheck = {
fFunction = function(user, data)
-- Return
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")
if nick then
local tRealNick = GetRealNick(nick,tcheckDB)
if tRealNick then
tcheckDB[tRealNick] = nil
local hFile = io.open(tSettings.filedir..tSettings.fcheckDB, "w+") Serialize(tcheckDB, "tcheckDB", hFile); hFile:close()
Core.SendPmToNick(user.sNick,tSettings.sBot_I, "ShareCheck: "..nick.." is removed from the check list")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: "..nick.." isn't found in the check list")
end
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Syntax Error: Add nickname")
end

end,
tAdmin = 1,
tRC = { { "Owners List\\Remove User From The Check List", " %[line:Nick]" } }
},
sc_donelist = {
fFunction = function(user)
local f = io.open(tSettings.filedir..tSettings.fdoneLOG,"r") --if f then f:close()
if f then
local msg = "\r\n\r"..string.rep("=", 47).."\r\nUsers That "..user.sNick.." Has Done\r\n"..string.rep("-", 94).."\r\n"
msg = msg.."Checked At\tOP Who Added \tUser\r\n"..string.rep("-", 94).."\r\n"

for line in f:lines() do
local _,_, iTime,sUser,sOp = string.find(line, "(%S+%s%S+)%s(%S+)%s(%S+)")
if string.lower(sOp) == string.lower(user.sNick) then
msg = msg..iTime.."\t"..sOp.."  \t"..sUser.."\r\n"
end
end

msg = msg..string.rep("-", 94)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")

f:close()
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: There's no done logfile")
end
end,
tAdmin = 0,
tRC = { { "Check List\\Users I Have Done", " %[Nick]" } }
},
sc_pulledlist = {
fFunction = function(user, data)
-- Table isn't empty
if next(tpulledDB) then
local _,_, tVar = string.find(data, "^%S+%s+(%S+)$")

local msg = "\r\n\r"..string.rep("=", 47).."\r\nUsers In The Pulled List:\r\n"..string.rep("-", 94).."\r\n"
msg = msg.."Added At\t\tOP Who Added\tUser\r\n"..string.rep("-", 94).."\r\n"
local tCopy ={}
-- Loop through hubbers

for i, v in pairs(tpulledDB) do
-- Insert stats to temp table
if tVar == "me" and string.lower(v.sOP)==string.lower(user.sNick) then
table.insert(tCopy, { sUser = i, iTime = v.iTime, sOP =v.sOP } )
elseif tVar == "all" then
table.insert(tCopy, { sUser = i, iTime = v.iTime, sOP =v.sOP } )
end
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iTime < b.iTime) end)
-- Loop through temp table

for i, v in pairs(tCopy) do
msg = msg..os.date("%Y-%m-%d %H:%M",v.iTime).."\t"..v.sOP.."  \t"..v.sUser.."\r\n"
end

msg = msg..string.rep("-", 94)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: Pulled list is empty")
end
end,
tAdmin = 0,
tRC = { { "Check List\\All Users Whos Filelists Has Been Pulled", " all" }, { "Check List\\All Users Whos Filelists I Have Pulled", " me" } }
},
sc_checklist = {
fFunction = function(user)
-- Table isn't empty
if next(tcheckDB) then

local msg = "\r\n\r"..string.rep("=", 47).."\r\nUsers In The Check List:\r\n"..string.rep("-", 94).."\r\n"
msg = msg.."Added At\t\tUser\t\tOP Who Added\r\n"..string.rep("-", 94).."\r\n"
local tCopy ={}
-- Loop through hubbers

for i, v in pairs(tcheckDB) do
-- Insert stats to temp table
table.insert(tCopy, { sUser = i, iTime = v.iTime, sOP =v.sOP } )
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iTime < b.iTime) end)
-- Loop through temp table

for i, v in pairs(tCopy) do
msg = msg..os.date("%Y-%m-%d %H:%M",v.iTime).."\t"..v.sUser.."\t"..v.sOP.."\r\n"
end

msg = msg..string.rep("-", 94)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: Check list is empty")
end
end,
tAdmin = 0,
tRC = { { "Check List\\Users Who Has To Be Checked", "" } }
},
sc_toplist = {
fFunction = function(user)
if next(topDB) then

local msg = "\r\n\r"..string.rep("=", 40).."\r\nTop Filelist Checker:\r\n"..string.rep("-", 80).."\r\n"
msg = msg.."Amount\t\tOp\r\n"..string.rep("-", 80).."\r\n"
local tCopy ={}
-- Loop through hubbers
for i, v in pairs(topDB) do
-- Insert stats to temp table
table.insert(tCopy, { sOp = i, iAmount = v.iCounter } )
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iAmount > b.iAmount) end)
-- Loop through temp table
for i, v in pairs(tCopy) do
msg = msg..""..v.iAmount.."\t\t"..v.sOp.."\r\n"
end

msg = msg..string.rep("-", 80)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: There is no OPstats list")
end
end,
tAdmin = 0,
tRC = { { "Check List\\Total Amount Done", "" }}
},
scop_donelistowner = {
fFunction = function(user, data)
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")
if nick then
local f = io.open(tSettings.filedir..tSettings.fdoneLOG,"r")
if f then
local msg = "\r\n\r"..string.rep("=", 47).."\r\nUsers Who Is Done\r\n"..string.rep("-", 94).."\r\n"
msg = msg.."Checked At\tOP Who Added\tUser\r\n"..string.rep("-", 94).."\r\n"

if nick == "all" then
for line in f:lines() do
local _,_, iTime,sUser,sOp = string.find(line, "(%S+%s%S+)%s(%S+)%s(%S+)")
msg = msg..iTime.."\t"..sOp.."\t"..sUser.."\r\n"
end
else
for line in f:lines() do
local _,_, iTime,sUser,sOp = string.find(line, "(%S+%s%S+)%s(%S+)%s(%S+)")
if string.lower(sOp) == string.lower(nick) then
msg = msg..iTime.."\t"..sOp.."\t"..sUser.."\r\n"
end
end
end
msg = msg..string.rep("-", 94)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")

f:close()
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: There is no done logfile")
end
end
end,
tAdmin = 1,
tRC = { { "Owners List\\Show Users An OP Done", " %[line:OpNick]" }, { "Owners List\\Show All Done Users", " all" } }
},
scop_toplistaverage = {
fFunction = function(user)
-- Table isn't empty
if next(topDB) then

local msg = "\r\n\r"..string.rep("=", 40).."\r\nAverage Per Week:\r\n"..string.rep("-", 80).."\r\n"
msg = msg.."Average\tOP\r\n"..string.rep("-", 80).."\r\n"
local tCopy ={}

--iCounter, iTime )
local iNow = os.time(os.date("*t"))
local iDays, iAmount
-- Loop through hubbers
for i, v in pairs(topDB) do

iDays = (iNow - v.iTime)/statDay
iAmount =string.format("%.2f", ((v.iCounter/iDays)*7))


--iWeeks = math.ceil((iNow - v.iTime)/statWeek)
--iAmount =string.format("<%.2f>", (v.iCounter/iWeeks))

--local _,_,iAmount = string.find((v.iCounter/iWeeks),"(%d+%.?%d?)")




-- Insert stats to temp table
table.insert(tCopy, { sOp = i, iAverage = tonumber(iAmount) } )
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iAverage > b.iAverage) end)
-- Loop through temp table

for i, v in pairs(tCopy) do
msg = msg..""..v.iAverage.."\t"..v.sOp.."\r\n"
end

msg = msg..string.rep("-", 80)
-- Send
Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
else
Core.SendPmToNick(user.sNick, tSettings.sBot_I, "*** Error: There is no one in the OPstats list")
end
end,
tAdmin = 1,
tRC = { { "Owners List\\Show The Average Amount Of Checked Users", "" }}
},
scop_weeklist = {
fFunction = function(user, data)
local _,_, tNumber = string.find(data, "^%S+%s+(%d+)$")
local _,_, tStartW,tStopW = string.find(data, "^%S+%s+(%d+)%-(%d+)$")
if tNumber or tStartW then


-- check what weeks user want to see
local iStartWeek,iStopWeek

if tStartW then
iStartWeek = tStartW
iStopWeek = tStopW
tNumber = tStartW.."-"..tStopW
else
iStartWeek = tNumber
iStopWeek = tNumber
end

local tWList = WeekList(iStartWeek,iStopWeek,nil)

-- Printing the list
local msg = "\r\n\r"..string.rep("=", 30).."\r\nShow Info On The Week/Weeks: "..tNumber.."\r\n"..string.rep("=", 30).."\r\n"
for i, v in pairs(tWList) do
msg = msg..""..i.." has done "..v.iCounter.." users.\r\n\r\n"..v.iUsers.."\r\n"..string.rep("-", 60).."\r\n"
end

Core.SendPmToNick(user.sNick, tSettings.sBot_I, msg.."\r\n")
tWList ={}

end
end,
tAdmin = 1,
tRC = {{ "Owners List\\Show How Many Users Is Done - A Week", " %[line:0=present, 1=former, 0-4=several weeks]" } }
},
}

MakeCheckList = function()
local iCounter = 0
local tBol
tlistDB = {}

for i, v in pairs(RegMan.GetRegs()) do
--not checked before
if not GetRealNick(v.sNick,tuserDB) then
-- allowed profile
if tSettings.tProfiles[v.iProfile] and tSettings.tProfiles[v.iProfile] == 1 then

else
--allowed user
if not tSettings.tUser[string.lower(v.sNick)] then
--allowed prefix
tBol = 0
for key, tFix in pairs(tSettings.tPrefix) do
if string.sub(string.lower(v.sNick),1,string.len(tFix)) == string.lower(tFix) then
tBol = 1
end
end
if tBol == 0 then

table.insert(tlistDB,v.sNick)
iCounter = iCounter + 1

if iCounter >= tSettings.iMaxList then
break
end
end
end
end
end
end


if iCounter < tSettings.iMaxList then
local tCopy = {}
for i, v in pairs(tuserDB) do
if not tSettings.tUser[string.lower(i)] then
--allowed prefix
tBol = 0
for key, tFix in pairs(tSettings.tPrefix) do
if string.sub(string.lower(i),1,string.len(tFix)) == string.lower(tFix) then
tBol = 1
end
end
if tBol == 0 then
table.insert(tCopy, { sUser = i, iTime = v.iTime} )
end
end
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iTime < b.iTime) end)
-- Loop through temp table
for i = 1, table.maxn(tCopy), 1 do
-- i exists
if tCopy[i] then
-- Populate
table.insert(tlistDB,tCopy[i].sUser)
iCounter = iCounter + 1
if iCounter >= tSettings.iMaxList then
break
end
end
end
tCopy = {}
end
--save the list
local hFile = io.open(tSettings.filedir..tSettings.flistDB, "w+") Serialize(tlistDB, "tlistDB", hFile); hFile:close()
CleanMem()
end


function WeekList(startw,stopw,user)
local tTempW = {}
local f = io.open(tSettings.filedir..tSettings.fdoneLOG,"r") --if f then f:close()
if f then
-- calculate time in seconds to the last "check time"
local iNow = os.time(os.date("*t"))
local tempDay = tonumber(os.date("%w",iNow))
if tSettings.iDay > tempDay then tempDay = tempDay + 7 end
tempDay = tempDay - tSettings.iDay
local iDiffSec = tempDay*statDay + os.date("%H",iNow)*statHour + os.date("%M",iNow)*60 + os.date("%S",iNow)
local iCheckStart = iNow - iDiffSec

for line in f:lines() do
local _,_, iY,iM,iD,iMin,iS,sUser,sOp = string.find(line, "(%d+)%-(%d+)%-(%d+)%s(%d+)%:(%d+)%s(%S+)%s(%S+)")

if user and string.lower(user) == string.lower(sOp) or not user then

local iTime = os.time({ year = iY, month = iM, day = iD, hour = iH, min = iMin, sec = iS})
local iStop = iCheckStart - (statWeek*stopw)   
local iStart = iCheckStart - (statWeek*startw) + statWeek           

if tonumber(iTime) < tonumber(iStart) and tonumber(iTime) > tonumber(iStop) then
if tTempW[sOp] then
tTempW[sOp].iCounter=tTempW[sOp].iCounter+1
tTempW[sOp].iUsers=tTempW[sOp].iUsers..sUser.." , "
else
tTempW[sOp]={iCounter=1,iUsers=sUser.." , "}
end
end
end
end
f:close()
end
return tTempW

end

-- Clean the memory
function CleanMem()
collectgarbage()
io.flush()
end

OnError = function(msg)
Core.SendPmToNick("Herman", tSettings.sBot_I ,"<"..tSettings.sBot_I.."> "..msg)
Core.SendPmToNick(tSettings.AdminNick, tSettings.sBot_I ,"<"..tSettings.sBot_I.."> "..msg)
--OnError("----")
end

GetRealNick = function(user,db)
-- For each hubber
for i, v in pairs(db) do
-- Compare
if string.lower(i) == string.lower(user) then
-- Return
return i
end
end
end

Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n");
for key, value in pairs(tTable) do
if (type(value) ~= "function") then
local sKey = (type(key) == "string") and string.format("[%q]", key) or string.format("[%d]", key);
if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q", value) or tostring(value);
hFile:write(sTab.."\t"..sKey.." = "..sValue);
end
hFile:write(",\n");
end
end
hFile:write(sTab.."}");
end
Title: Re: ShareChecker
Post by: Dreams on 13 April, 2010, 11:22:22
Yes, im using automatic configuration saver and i will check if it is that one who is doing that.
When you posted the script, you did a lot of spaces and other stuff, cause there are a lot of syntax errors in the script now. =)

tested it but it wasnt the config saver script that did it.. and i saw that it was created on ptokax startup to, dont really know why
Title: Re: ShareChecker
Post by: TZB on 13 April, 2010, 16:11:36
Yep. My bad Pasted directly from notebook. Now edited the above post try again.
Title: Re: ShareChecker
Post by: Dreams on 13 April, 2010, 17:02:34
This time it works without syntax errors, but cant se that its sorted by name and i have double of everything in the rc now =)
Title: Re: ShareChecker
Post by: TZB on 14 April, 2010, 07:37:19
Please Check your script again i am using the same script i have no issues.
Title: Re: ShareChecker
Post by: Dreams on 14 April, 2010, 10:45:29
Dont know why but i did get it to work without double in the rc, but it still isnt sorted by name, and the add user,add this user and best idea on user to check is put under Check list button.
Title: Re: ShareChecker
Post by: TZB on 14 April, 2010, 12:28:14
Sorted By name? Please provide a clear idea of where exactly you want what king of commands.
Title: Re: ShareChecker
Post by: Dreams on 14 April, 2010, 14:44:35
As i said before but i will do it more detailed this time.

Share Check Commands
                             Owners List
                                       Show Users An OP Done
                                                 Show All Done Users         and so on...

                             Check List
                                       Users I Have Done
                                                 Users Who Has To Be Checked         and so on...   

                             Check Info
                                      Show My Info
                                                Show Hub Info         and so on...


I want those with bold text to be sorted by name..
that was all, except for the fix for the tSC_list i requested.. =)
Title: Re: ShareChecker
Post by: Dreams on 16 April, 2010, 17:38:03
Anyone up for the challenge?
Title: Re: ShareChecker
Post by: TZB on 16 April, 2010, 19:57:08
Well it's not a challenge.
You can Do it yourself.
QuoteCore.SendToNick(user.sNick,"$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
                     "$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
Here it Sends The Right Click using Settings Menu and "RC"
And here after every command RC is defined eg.
QuotetRC = { { "Check List\\Best Idea On User To Check", "" } }
Title: Re: ShareChecker
Post by: Dreams on 16 April, 2010, 22:48:09
well, i dont know what to change it into too make it sort by name.. that my problem :) what lines to change into what.

If i could get helpt with that, it would be great. =)