PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: Herodes on 03 June, 2004, 07:00:12

Title: Usercount Graph
Post by: Herodes on 03 June, 2004, 07:00:12
This is it finally ... ;)
Grab it and give it a try .. :D
--#-- GraphBot by Herodes
-- Working Version (but after repeating the cmd x 5 times u don't get any refresh on the tables ...)
-- fixed correction of kb, mb, gb, tb display
-- now the user count centers on top of the column...
-- input from NotRambitWombat made it even shorter.. :)
-- Tried to get the extra tables working but I couldn't .. :(
-- Making progress on this ... Added tables tried to get them to work again ..
-- It gets the values to the tables but it has an error (indicated in script) [ 8:20 pm 30-5-2004 ]
-- After heavy tutoring session with plop, The Script is working as Intented !
--##-- thanx to All the ppl who helped ... bonus to plop  5:02 am 3-6-2004
--- Returns a graph of the present user count along with the present share and the time
--- Remembers up to three previous graphs and displays simultaneously
---** Trying the command while you are the only user turns up with error (fixed //  1:29 pm 3-6-2004 // )
---** ...  no worries wait for someone to join and then try it again ... (fixed //  1:29 pm 3-6-2004 // )

gBot = "CountGraph" -- you may edit the bot to whatever u want
graphcmd = "!graph" -- you may edit the command to whatever u want
fullcell = "   :?:\t"
emptycell = "\t"
count = 0
tTab = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tTable = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol1= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol2= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol3= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };


----------------------------------------------------------------------- the command
function DataArrival(user, data)
   if (strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd~=nil then
         if cmd==graphcmd then
if (frmHub:GetUsersCount() == 1) then
user:SendData(gBot, "Where did everybody go ?")
else TransferAll()
end
         end
      end
   end
end
----------------------------------------------------------------------- place the values in table and return table
function AddValues()
   tTable = {}
   GetNumbers()
   if usrC > 1 then
      local pivot = 11 - floor(usrC / maxU * 10)
      for i = 1,10 do
         if ( i < pivot ) then
            tTable[i] = emptycell
         elseif ( i == pivot ) then
            tTable[i] = userCount
         else
            tTable[i] = fullcell
         end
      end
   end
   if usrC == 1 then
      SendToAll(gBot, "Where did everybody go ?")
   end
   tTable[11] = Time
   tTable[12] = hubshrS
   return tTable
end
----------------------------------------------------------------------- push the values in a > b
function FixTable(table1, table2)
   for i, v in table1 do
      i = tonumber(i)
      if i == nil then
         i = 1
      end
      table2[i]= v
   end
end
----------------------------------------------------------------------- logical route for handling the tables ..
function TransferAll()
if count == 1 then
FixTable(tCol2, tCol3)
FixTable(tCol1, tCol2)
FixTable(tTable, tCol1)
AddValues()
GiveGraph()
else
DoTranferTab()
AddValues()
GiveGraph()
end
end
----------------------------------------------------------------------- straigth run ? pushing the tables ..
function DoTranferTab()
   if tTable[11] ~= "\t" then
      if tCol3[11] == "\t"then
         FixTable(tCol2, tCol3)
         FixTable(tCol1, tCol2)
         FixTable(tTable, tCol1)
      elseif tCol2[11] == "\t" then
         FixTable(tCol1, tCol2)
         FixTable(tTable, tCol1)
      elseif tCol1[11] == "\t" and count == 1 then
         FixTable(tTable, tCol1)
         count = 0
      end
   end
count = count +1
end
----------------------------------------------------------------------- the graph showing the values of all tables
function GiveGraph()
   tMsg = "\r\n\t\t\t- "..frmHub:GetHubName().." - User Count Graph -"
   tMsg = tMsg.."\r\n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -o-0-o- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
   tMsg = tMsg.."\r\n -> Share\t:\t"..tTable[12].."\t\t"..tCol1[12].."\t\t"..tCol2[12].."\t\t"..tCol3[12]
   tMsg = tMsg.."\r\n 100% ("..maxU..")\t\t"..tTable[1].."\t"..tCol1[1].."\t"..tCol2[1].."\t"..tCol3[1]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[2].."\t"..tCol1[2].."\t"..tCol2[2].."\t"..tCol3[2]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[3].."\t"..tCol1[3].."\t"..tCol2[3].."\t"..tCol3[3]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[4].."\t"..tCol1[4].."\t"..tCol2[4].."\t"..tCol3[4]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[5].."\t"..tCol1[5].."\t"..tCol2[5].."\t"..tCol3[5]
   tMsg = tMsg.."\r\n 50% ("..midU..")\t\t"..tTable[6].."\t"..tCol1[6].."\t"..tCol2[6].."\t"..tCol3[6]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[7].."\t"..tCol1[7].."\t"..tCol2[7].."\t"..tCol3[7]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[8].."\t"..tCol1[8].."\t"..tCol2[8].."\t"..tCol3[8]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[9].."\t"..tCol1[9].."\t"..tCol2[9].."\t"..tCol3[9]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[10].."\t"..tCol1[10].."\t"..tCol2[10].."\t"..tCol3[10]
   tMsg = tMsg.."\r\n- 0% (0). . . . . . . . . . \t. .:?:. . . . . . . . . . . . .\t. .:?:. . . . . . . . . . . . .\t. .:?:. . . . . . . . . . . . .\t. .:?:. . . . . . . . . . . . ."
   tMsg = tMsg.."\r\n ->  Time\t:            "..tTable[11].."\t             "..tCol1[11].."\t             "..tCol2[11].."\t             "..tCol3[11]
   SendToAll(gBot, tMsg)
end
----------------------------------------------------------------------- get the data (numbers) needed, format and return them
function GetNumbers()
   Time, userCount, maxU, hubshare = "\t"
   Time = date("%H")..":"..date("%M")..":"..date("%S")
   usrC = frmHub:GetUsersCount()
   userCount = AddSpacesToKey(usrC)
   maxU = frmHub:GetMaxUsers()
   midU = maxU/2
   local thubshare = format("%0.1f", ( frmHub:GetCurrentShareAmount() / 1024))
   hubshrS = thubshare.." kb"
   if tonumber(thubshare) >= 1024 and tonumber(thubshare) < (1024^2) then
      hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^2))).." mb"
   elseif tonumber(thubshare) >= (1024^2) and tonumber(thubshare) < (1024^3) then
      hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^3))).." gb"
   elseif tonumber(thubshare) >= (1024^3) then
      hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^4))).." tb"
   end
   return Time, userCount, maxU, midU, hubshare, usrC, hubshrS
end

----------------------------------------------------------------------- adding appropriate number of spaces to a string
function AddSpacesToKey(data)
   local ratio = (5 - strlen(data))
   local tcell = strrep(" ", ratio)..data.."\t"
   return tcell
end
[*edit*] The Graphs are designed for use with MS Sans Serif, 8pt, Regular ...
For any other font, don't expect anything lining up.
Althought the script will still function properly....
[*edit *] Fixed bug on user count is 1 .. ;)
Title:
Post by: [PT]CableGuy on 03 June, 2004, 12:42:30
INCREDIBLE STUFF !!! CONGRATULATIONS Herodes !!! :D

Here is a "preview": (2 users with 13.16G each)
- Myhub Testing - User Count Graph -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -o-0-o
 -> Share : 26.3 gb 13.2 gb 13.2 gb
 100% (100)
 --- - -  -   -
 --- - -  -   -
 --- - -  -   -
 --- - -  -   -
 50% (50)
 --- - -  -   -
 --- - -  -   -
 --- - -  -   -
 --- - -  -   -
- 0% (0). . . . . . . . . . . .:?:. . . . . . . . . . . . . . .:?:. . ......

 ->  Time :            11:35:01             11:34:41             11:32:42            

One thing though:

Syntax Error: attempt to concat a nil value
Syntax Error: attempt to concat a nil value

Since i've only used this script , this "error" must be from it....sorry.
Great Job , Thanks. :]

***EDITED***
I think the Syntax Error: attempt to concat a nil value  , was generated when:
-I had only 1 user and typed the !graph command
There are more users inside the hub now and no more "errors" appeared.
***EDITED***
Title: edited comments .. :)
Post by: Herodes on 03 June, 2004, 13:04:09
thank you for ur good words :D ..
yep, sorry for not mantioning that one ! ...
it is now added to the comments ...  ;)
Title:
Post by: blackwings on 03 June, 2004, 13:06:33
before I ask a stupid thing(because I haven't tested it), I aks a less stupid question. Does this graoh show statics for the whole day, or just for a few hours?

if yes, then I ask this =

this is a really nice script, but it would be nice if it showed for the past 24 hours. If it doesn't work because of the size of all symbols, then maybe you could like have several graphs, like the first one show the first 3 hours, then it's the next 3 hours on the other one.
Title:
Post by: Herodes on 03 June, 2004, 13:18:34
QuoteOriginally posted by blackwings
... Does this graoh show statics for the whole day, or just for a few hours?
No It shows the present graph  and carries on (if there are) with the three latest graphs produced with ' !graph ' ...
QuoteOriginally posted by blackwings this is a really nice script, but it would be nice if it showed for the past 24 hours. If it doesn't work because of the size of all symbols, then maybe you could like have several graphs, like the first one show the first 3 hours, then it's the next 3 hours on the other one.
I need a bit of time,... there's more to come ... :D
But,... I'm taking of from UK ro Greece for good and I need to start packing .. it could take time .. :(
I'll try my best ...
Title:
Post by: Herodes on 03 June, 2004, 14:32:36
One more small edit .. for the user count is 1 bug .. :D
Feel free to post an impressive graph .. ;)
Title: Gr8 Script
Post by: Psycho_Chihuahua on 03 June, 2004, 15:34:51
Could someone please adapt the script to fit in a Hub where we have

Tahoma Standard 9

as standard Font?     Please
It seems to be a bit out of line and i cant get it quit right



- Privat- - User Count Graph -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -o-0-o- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -> Share : 1.6 tb 1.6 tb 1.6 tb 1.6 tb
 100% (100)
 --- - -  -   -
 --- - -  -   -
 --- - -  -   -
 --- - -  -   -
 50% (50)
 --- - -  -   -
 --- - -  -   -
 --- - -  -   -   21   21   21   21
 --- - -  -   -   :?:   :?:   :?:   :?:
- 0% (0). . . . . . . . . . . .:?:. . . . . . . . . . . . . . .:?:. . . . . . . . . . . . . . .:?:. . . . . . . . . . . . . . .:?:. . . . . . . . . . . . .
 ->  Time :            15:55:58             15:38:37             15:31:10             15:18:35

Note: Otherwise everything works, no Bugs :)
Title:
Post by: Flux on 03 June, 2004, 16:18:15
well what can i say Herodes an ew face to this forum who is definately willing to learn LUA and has scripted some very nice new idea scripts...

I can see me watching you and your ideas and making this forum coming alive with ur fresh face hehehe.

I have installed this script and it will run untill new versions progress....

Thank you and keep the spirit up ;)
Title:
Post by: plop on 03 June, 2004, 16:18:16
QuoteOriginally posted by Psycho_Chihuahua
Could someone please adapt the script to fit in a Hub where we have

Tahoma Standard 9

as standard Font?     Please
It seems to be a bit out of line and i cant get it quit right

Note: Otherwise everything works, no Bugs :)

thats a client thingy not a hub thingy.
you can't change the clients font, the client even needs a restart 2 change it.

plop
Title:
Post by: Herodes on 03 June, 2004, 16:43:26
Flux, I am flattered .. ;D
QuotePsycho_Chihuahua:Could someone please adapt the script to fit in a Hub where we have Tahoma Standard 9 as standard Font?
Done , u guys are really making this addictive ,,,
I am starting too get this at a personal level .. :D
--#-- GraphBot by Herodes
-- Working Version (Tahoma, 9pt) -- requested by Psycho_Chihuahua
-- fixed correction of kb, mb, gb, tb display
-- now the user count centers on top of the column...
-- input from NotRambitWombat made it even shorter.. :)
-- Tried to get the extra tables working but I couldn't .. :(
-- Making progress on this ... Added tables tried to get them to work again ..
-- It gets the values to the tables but it has an error (indicated in script) [ 8:20 pm 30-5-2004 ]
-- After heavy tutoring session with plop, The Script is working as Intented !
--##-- thanx to All the ppl who helped ... bonus to plop  5:02 am 3-6-2004
--- Returns a graph of the present user count along with the present share and the time
--- Remembers up to three previous graphs and displays simultaneously

gBot = "CountGraph" -- you may edit the bot to whatever u want
graphcmd = "!graph" -- you may edit the command to whatever u want
fullcell = "   :?:\t"
emptycell = "\t"
count = 0
tTab = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tTable = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol1= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol2= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol3= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };

----------------------------------------------------------------------- the command
function DataArrival(user, data)
   if (strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd~=nil then
         if cmd==graphcmd then
TransferAll()
         end
      end
   end
end

----------------------------------------------------------------------- place the values in table and return table
function AddValues()
   tTable = {}
   GetNumbers()
   if usrC > 1 then
      local pivot = 11 - floor(usrC / maxU * 10)
      for i = 1,10 do
         if ( i < pivot ) then
            tTable[i] = emptycell
         elseif ( i == pivot ) then
            tTable[i] = userCount
         else
            tTable[i] = fullcell
         end
      end
   end
   if usrC == 1 then
      SendToAll(gBot, "Where did everybody go ?")
   end
   tTable[11] = Time
   tTable[12] = hubshrS
   return tTable
end
----------------------------------------------------------------------- push the values in a > b > c
function FixTable(table1, table2)
   for i, v in table1 do
      i = tonumber(i)
      if i == nil then
         i = 1
      end
      table2[i]= v
   end
end
----------------------------------------------------------------------- straigth run ? pushing the tables ..
function DoTranferTab()
   if tTable[11] ~= "\t" then
      if tCol3[11] == "\t"then
         FixTable(tCol2, tCol3)
         FixTable(tCol1, tCol2)
         FixTable(tTable, tCol1)
      elseif tCol2[11] == "\t" then
         FixTable(tCol1, tCol2)
         FixTable(tTable, tCol1)
      elseif tCol1[11] == "\t" and count == 1 then
         FixTable(tTable, tCol1)
         count = 0
      end
   end
count = count +1
end
----------------------------------------------------------------------- logical route for handling the tables ..
function TransferAll()
if count == 1 then
FixTable(tCol2, tCol3)
FixTable(tCol1, tCol2)
FixTable(tTable, tCol1)
AddValues()
GiveGraph()
else
DoTranferTab()
AddValues()
GiveGraph()
end
end
----------------------------------------------------------------------- the graph showing the values of previous table
function GiveGraph()
   tMsg = "\r\n\t\t\t- "..frmHub:GetHubName().." User Count Graph -"
   tMsg = tMsg.."\r\n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -o-0-o- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
   tMsg = tMsg.."\r\n -> Share\t:\t"..tTable[12].."\t\t"..tCol1[12].."\t\t"..tCol2[12].."\t\t"..tCol3[12]
   tMsg = tMsg.."\r\n 100% ("..maxU..")\t"..tTable[1].."\t"..tCol1[1].."\t"..tCol2[1].."\t"..tCol3[1]
   tMsg = tMsg.."\r\n --- - -  -  -\t"..tTable[2].."\t"..tCol1[2].."\t"..tCol2[2].."\t"..tCol3[2]
   tMsg = tMsg.."\r\n --- - -  -  -\t"..tTable[3].."\t"..tCol1[3].."\t"..tCol2[3].."\t"..tCol3[3]
   tMsg = tMsg.."\r\n --- - -  -  -\t"..tTable[4].."\t"..tCol1[4].."\t"..tCol2[4].."\t"..tCol3[4]
   tMsg = tMsg.."\r\n --- - -  -  -\t"..tTable[5].."\t"..tCol1[5].."\t"..tCol2[5].."\t"..tCol3[5]
   tMsg = tMsg.."\r\n 50% ("..midU..")     \t"..tTable[6].."\t"..tCol1[6].."\t"..tCol2[6].."\t"..tCol3[6]
   tMsg = tMsg.."\r\n --- - -  -  -\t"..tTable[7].."\t"..tCol1[7].."\t"..tCol2[7].."\t"..tCol3[7]
   tMsg = tMsg.."\r\n --- - -  -  -\t"..tTable[8].."\t"..tCol1[8].."\t"..tCol2[8].."\t"..tCol3[8]
   tMsg = tMsg.."\r\n --- - -  -  -\t"..tTable[9].."\t"..tCol1[9].."\t"..tCol2[9].."\t"..tCol3[9]
   tMsg = tMsg.."\r\n --- - -  -  -\t"..tTable[10].."\t"..tCol1[10].."\t"..tCol2[10].."\t"..tCol3[10]
   tMsg = tMsg.."\r\n- 0% (0). . . . . . . .\t. .:?:. . . . . . . . . . .\t. .:?:. . . . . . . . . . .\t. .:?:. . . . . . . . . . .\t. .:?:. . . . . . . . . . . . ."
   tMsg = tMsg.."\r\n ->  Time\t:            "..tTable[11].."\t             "..tCol1[11].."\t             "..tCol2[11].."\t             "..tCol3[11]
   SendToAll(gBot, tMsg)
end
----------------------------------------------------------------------- get the data (numbers) needed, format and return them
function GetNumbers()
   Time, userCount, maxU, hubshare = "\t"
   Time = date("%H")..":"..date("%M")..":"..date("%S")
   usrC = frmHub:GetUsersCount()
   userCount = AddSpacesToKey(usrC)
   maxU = frmHub:GetMaxUsers()
   midU = maxU/2
   local thubshare = format("%0.1f", ( frmHub:GetCurrentShareAmount() / 1024))
   hubshrS = thubshare.." kb"
   if tonumber(thubshare) >= 1024 and tonumber(thubshare) < (1024^2) then
      hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^2))).." mb"
   elseif tonumber(thubshare) >= (1024^2) and tonumber(thubshare) < (1024^3) then
      hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^3))).." gb"
   elseif tonumber(thubshare) >= (1024^3) then
      hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^4))).." tb"
   end
   return Time, userCount, maxU, midU, hubshare, usrC, hubshrS
end

----------------------------------------------------------------------- adding appropriate number of spaces to userCount string
function AddSpacesToKey(data)
   local ratio = (5 - strlen(data))
   local tcell = strrep(" ", ratio)..data.."\t"
   return tcell
end
!!!WARNING!!! This one is for use with 'TAHOMA( 9pt)' font
If u are using a custom Font OFFICIALY in ur Hub  then I suggest u take the script found in the first post !!!
(DC++'s Default font: Ms Sans Serif,8pts)
Title: gee thnx
Post by: Psycho_Chihuahua on 03 June, 2004, 16:57:46
Thanks a lot Herodes

It works perfectly :)

Quotethats a client thingy not a hub thingy

I got an Ascii Picture Bot running set to Tahoma  :D
Title:
Post by: [PT]CableGuy on 06 June, 2004, 03:52:03
Well , what can i say...this script is AWESOME !!!! :D  :D
I'm really LoVinG it. :]

[02:47]
- TUDONOSSO - LINUX User Count Graph -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -o-0-o- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -> Share : 1.8 tb 1.8 tb 1.8 tb 1.8 tb
 100% (100)
 --- - - - -
 --- - - - -
 --- - - - -
 --- - - - -
 50% (50)
 --- - - - -
 --- - - - -   36   36   36   36
 --- - - - - :?: :?: :?: :?:
 --- - - - - :?: :?: :?: :?:
- 0% (0). . . . . . . . . .:?:. . . . . . . . . . . . .:?:. . . . . . . . . . . . .:?:. . . . . . . . . . . . .:?:. . . . . . . . . . . . .
 -> Time : 02:47:54 02:45:57 02:42:27 02:35:59

Have some request though...if i may. :P

It seems that the graph is only "drawned" when someone types the "!graph command".
Could it be possible to "draw" the graph every hour or half-hour ?  
Can this "hourly report" be sent to "hub owner" via PM ?  

Thanks in advance. ;)
Title:
Post by: chill on 06 June, 2004, 19:33:04
Herodes great script, and I hope you didn't mind that I treid to code it myself, just like lines better, plus they come in quite handy.

here the code,

-- Inspired by GraphBot by Herodes

-- User Share Meter V 001 by chill

---user share table
usm = {}

usm.chars = 80 -- lenght of chars
usm.lines = 10 -- number of lines

usm.displchar = "@"

usm.maxshare = 0
usm.maxusers = 0

usm.mShare = {}
usm.tShare = {}
usm.tShare.amount = 0
usm.tShare.count = 0
usm.mUsers = {}
usm.tUsers = {}
usm.tUsers.amount = 0
usm.tUsers.count = 0

usm.updmeter = 1  -- in minutes
usm.setmeter = 1  --in minutes

usm.showstats = 1


function Main()
SetTimer(60*1000)
StartTimer()
BuildTimers()
end

function BuildTimers()
usm.timers = {{0,usm.updmeter,{UpdtShare,UpdtUsers}},{0,usm.setmeter,{UpdmShare,UpdmUsers}},{0,usm.showstats,{DrawShare,DrawUsers}}}
end

function OnTimer()
for i = 1,getn(usm.timers) do
usm.timers[i][1] = usm.timers[i][1] + 1
if (usm.timers[i][1] >= usm.timers[i][2]) then
for i2 = 1,getn(usm.timers[i][3]) do
usm.timers[i][3][i2]()
end
usm.timers[i][1] = 0
end
end
end

function UpdtShare()
local curshare = frmHub:GetCurrentShareAmount()
usm.tShare.amount = usm.tShare.amount + curshare
usm.tShare.count = usm.tShare.count + 1
end

function UpdtUsers()
local curusers = frmHub:GetUsersCount()
usm.tUsers.amount = usm.tUsers.amount + curusers
usm.tUsers.count = usm.tUsers.count +1
end

function UpdmShare()
--get share over "usm.setmeter" minutes
local curshare = usm.tShare.amount / usm.tShare.count
--reset get share
usm.tShare.amount = 0
usm.tShare.count = 0

tinsert(usm.mShare,1,{curshare,date("%H:%M:%S")})
while getn(usm.mShare) > usm.lines do
tremove(usm.mShare,getn(usm.mShare))
end
usm.maxshare = 0
for i = 1,getn(usm.mShare) do
if (usm.mShare[i][1] > usm.maxshare) then
usm.maxshare = usm.mShare[i][1]
end
end
end

function UpdmUsers()
local curusers = usm.tUsers.amount / usm.tUsers.count
usm.tUsers.amount = 0
usm.tUsers.count = 0

tinsert(usm.mUsers,1,{curusers,date("%H:%M:%S")})
while getn(usm.mUsers) > usm.lines do
tremove(usm.mUsers,getn(usm.mUsers))
end
usm.maxusers = 0
for i = 1,getn(usm.mUsers) do
if (usm.mUsers[i][1] > usm.maxusers) then
usm.maxusers = usm.mUsers[i][1]
end
end
end


function GetShareLine(num)
if usm.mShare[num] then
return (usm.mShare[num][1]/usm.maxshare),usm.mShare[num][2],usm.mShare[num][1]
end
return 0,"00:00:00",0
end

function GetUsersLine(num)
if usm.mUsers[num] then
return (usm.mUsers[num][1]/usm.maxusers),usm.mUsers[num][2],usm.mUsers[num][1]
end
return 0,"00:00:00",0
end

function GetCharNum(num)
local curnum = usm.chars*num
local fcurnum = floor(curnum)
if ((curnum - fcurnum) >= 0.5) then
return fcurnum + 1
else
return fcurnum
end
end

function DrawShare()
msg = "\r\n".."AvShare  : "..GetHeadShare().." "..ConvShare(usm.maxshare).."\r\n"
for i = 1,usm.lines do
local snum,date,share = GetShareLine(i)
local charnum = GetCharNum(snum)
local displshare = ConvShare(share)
msg = msg..date.." : "..strrep(usm.displchar,charnum).." "..displshare.."\r\n"
end
SendToAll(msg)
end

function DrawUsers()
msg = "\r\n".."AvUsers  : "..GetHeadUsers().." "..ConvUsers(usm.maxusers).."\r\n"
for i = 1,usm.lines do
local snum,date,users = GetUsersLine(i)
local charnum = GetCharNum(snum)
local displusers = ConvUsers(users)
msg = msg..date.." : "..strrep(usm.displchar,charnum).." "..displusers.."\r\n"
end
SendToAll(msg)
end


function ConvShare(share)
local tmes = { {"KB",1024},{"MB",1024*1024},{"GB",1024*1024*1024},{"TB",1024*1024*1024*1024},{"PB",1024*1024*1024*1024*1024} }
local count = 0
for i = getn(tmes),1,-1 do
if share > tmes[i][2] then
return format("%3.2f",share/tmes[i][2]).." "..tmes[i][1]
end
end
return format("%3.2f",share).." B"
end

function ConvUsers(users)
local tmes = { {"KU",1000},{"MU",1000*1000},{"GU",1000*1000*1000},{"TU",1000*1000*1000*1000},{"PU",1000*1000*1000*1000*1000} }
local count = 0
for i = getn(tmes),1,-1 do
if users > tmes[i][2] then
return floor(users/tmes[i][2]).." "..tmes[i][1]
end
end
return floor(users).." U"
end

function GetHeadShare()
local share = usm.maxshare/2
local dsplshare = ConvShare(share)
local lenshare = floor(strlen(dsplshare)/2)
local lenmax = floor(usm.chars/2)-lenshare
local msg = strrep("-",lenmax).." "..dsplshare.." "
local strrest = usm.chars-strlen(msg)
msg = msg..strrep("-",strrest)
return msg
end

function GetHeadUsers()
local users = usm.maxusers/2
local dsplusers = ConvUsers(users)
local lenusers = floor(strlen(dsplusers)/2)
local lenmax = floor(usm.chars/2)-lenusers
local msg = strrep("-",lenmax).." "..dsplusers.." "
local strrest = usm.chars-strlen(msg)
msg = msg..strrep("-",strrest)
return msg
end

Title:
Post by: Herodes on 06 June, 2004, 22:15:29
Nice Stuff chill !!!
I will stare at it until I understand each line ... :D
Thanks for posting it! :)
Other than that, I am about to release an !unexpected! Version of the GraphBot ...
With many more stuff to do ... in a while ... ;)


[*  N O T E   *] Pls feel free to mod the GraphBot ....
[* T O  A L L *] Just Post it on this thread and
[* - - - - - - - *] Let Us know what you Have !! :D
Title:
Post by: plop on 06 June, 2004, 22:41:10
here's my mod.
changed it so it only uses 1 single table for everything.
-- GraphBot by Herodes
-- changed 2 use only 1 table by plop
-- Working Version (but after repeating the cmd x 5 times u don't get any refresh on the tables ...)
-- fixed correction of kb, mb, gb, tb display
-- now the user count centers on top of the column...
-- input from NotRambitWombat made it even shorter.. :)
-- Tried to get the extra tables working but I couldn't .. :(
-- Making progress on this ... Added tables tried to get them to work again ..
-- It gets the values to the tables but it has an error (indicated in script) [ 8:20 pm 30-5-2004 ]


tMain = {
   gBot = "CountGraph",
   tTab={},
   tTable = {},
   tCol1= {},
   tCol2= {},
   tCol3= {},
   fullcell = "    ?\t",
   emptycell = "\t",
   Time = "\t",
   userCount = "\t",
   maxU = "\t",
   hubshare = "\t",
   hubshrS = "",
   maxU = 0,
   midU = 0
}
function Main()
   for a,b in tMain do
      if type(b) == "table" then
         for i=0,12 do
            if i ~= 11 then
            tMain[a][i]="\t"
            end
         end
      end
   end
   --GetNumbers()
end

----------------------------------------------------------------------- the command
function DataArrival(user, data)
   if (strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd~=nil then
         if cmd=="!graph" then
            GiveGraph()
         end
      end
   end
end

----------------------------------------------------------------------- place the values in table and return table
function AddValues()
   GetNumbers()
   if tMain.usrC > 1 then
      local pivot = 11 - floor(tMain.usrC / tMain.maxU * 10)
      for i = 1,10 do
         if ( i < pivot ) then
            tMain.tTable[i] = tMain.emptycell
         elseif ( i == pivot ) then
            tMain.tTable[i] = tMain.userCount
         else
            tMain.tTable[i] = tMain.fullcell
         end
      end
   end
   if tMain.usrC == 1 then
      SendToAll(tMain.gBot, "Where did everybody go ?")
   end
   tMain.tTable[12] = tMain.Time
   tMain.tTable[0] = tMain.hubshrS
end
----------
function ResetTable(table)
   for i = 1, 12 do
      if i ~= 11 then
      table[i] = "\t"
      end
   end
   return table
end
----------------------------------------------------------------------- push the values in a > b > c
function FixTable(table1, table2)
   for i, v in table1 do
      table2[i]= v
   end
end
----------------------------------------------------------------------- push the tables .. (this is the part that the problem is ... :S)
function DoTranferTab()
   if tMain.tTable[12] ~= "\t" then
      if tMain.tCol2[12] ~= "\t"then
         FixTable(tMain.tCol2, tMain.tCol3)
         FixTable(tMain.tCol1, tMain.tCol2)
         FixTable(tMain.tTable, tMain.tCol1)
      elseif tMain.tCol1[12] ~= "\t" then
         FixTable(tMain.tCol1, tMain.tCol2)
         FixTable(tMain.tTable, tMain.tCol1)
      elseif tMain.tCol1[12] == "\t" then
         FixTable(tMain.tTable, tMain.tCol1)
      end
   --else
      --tTable = {}
   end
end


function GetLine(index)
   if tMain.GetLine[index] then
      return tMain.GetLine[index]
   else
      return "\r\n -\t\t"..tMain.tTable[index].."\t"..tMain.tCol1[index].."\t"..tMain.tCol2[index].."\t"..tMain.tCol3[index]
   end
end

function BuildGetLine()
   tMain.GetLine = nil
   tMain.GetLine = {
      [0] = "\r\nShare\t:\t"..tMain.tTable[0].."\t"..tMain.tCol1[0].."\t"..tMain.tCol2[0].."\t"..tMain.tCol3[0],
      [1] = "\r\n 100% ("..tMain.maxU..")\t"..tMain.tTable[1].."\t"..tMain.tCol1[1].."\t"..tMain.tCol2[1].."\t"..tMain.tCol3[1],
      [5] = "\r\n 50% ("..tMain.midU..")\t"..tMain.tTable[5].."\t"..tMain.tCol1[5].."\t"..tMain.tCol2[5].."\t"..tMain.tCol3[5],
      [11] = "\r\n 0% (0)\t\t"..tMain.fullcell.."\t"..tMain.fullcell.."\t"..tMain.fullcell.."\t"..tMain.fullcell,
      [12] = "\r\nTime\t:\t"..tMain.tTable[12].."\t"..tMain.tCol1[12].."\t"..tMain.tCol2[12].."\t"..tMain.tCol3[12]
  }
end

----------------------------------------------------------------------- the graph showing the values of previous table
function GiveGraph()
   DoTranferTab()
   AddValues()
   BuildGetLine()
   local tMsg = "\r\n\t\t\t- "..frmHub:GetHubName().." User Count Graph -"
   for i=0,12 do
      tMsg = tMsg..GetLine(i)
   end
   SendToAll(tMain.gBot, tMsg)
end

----------------------------------------------------------------------- get the data (numbers) needed, format and return them
function GetNumbers()
   tMain.Time = date("%H")..":"..date("%M")..":"..date("%S")
   tMain.usrC = frmHub:GetUsersCount()
   tMain.userCount = AddSpacesToKey(tMain.usrC)
   tMain.maxU = frmHub:GetMaxUsers()
   tMain.midU = tMain.maxU/2
   tMain.thubshare = format("%0.1f", ( frmHub:GetCurrentShareAmount() / 1024))
   tMain.hubshrS = tMain.thubshare.." kb"
   if tonumber(tMain.thubshare) >= 1024 and tonumber(tMain.thubshare) < (1024^2) then
      tMain.hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^2))).." mb"
   elseif tonumber(tMain.thubshare) >= (1024^2) and tonumber(tMain.thubshare) < (1024^3) then
      tMain.hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^3))).." gb"
   elseif tonumber(tMain.thubshare) >= (1024^3) then
      tMain.hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^4))).." tb"
   end
end

----------------------------------------------------------------------- adding appropriate number of spaces to userCount string
function AddSpacesToKey(data)
   local ratio = (5 - strlen(data))
   local tcell = strrep(" ", ratio)..data.."\t"
   return tcell
end
plop
Title:
Post by: chill on 06 June, 2004, 23:35:15
QuoteOriginally posted by Herodes
Nice Stuff chill !!!
I will stare at it until I understand each line ... :D
Thanks for posting it! :)
Other than that, I am about to release an !unexpected! Version of the GraphBot ...
With many more stuff to do ... in a while ... ;)


[*  N O T E   *] Pls feel free to mod the GraphBot ....
[* T O  A L L *] Just Post it on this thread and
[* - - - - - - - *] Let Us know what you Have !! :D

"I wll stare at it until I understand..." lol, thats just what I thaught when I saw your code, so wrote this one :)),
I'll try to make mine look as good as yours, lets see if I get it.
Title: What ?!?
Post by: Cp6uja on 07 June, 2004, 10:44:41
What is this ???
Is this script -:)

I_ 000000 I_



/Cp6uja
Title:
Post by: Herodes on 11 June, 2004, 00:20:02
I was wondering if any people would like to test the new GraphBot ...
I warn u there are parts under construction ...
If someone wants it pls pm me .. . :)

For now a teaser for one of the basic features of the running version...
  - - - - = = Ladies & Gents,... We Are Proud To Announce A New AVERAGE PER USER SHARE RECORD ! ! !  = = - - - -
                                   - - - - = = Our New Share Per User Record is :43.1 GB = = - - - -
                                                - - - - = = Thanks to All the Users = = - - - -

- To break the Average Share Record we must reach 43.2 GB per user... ( Difficulty Factor is 1.0025 )
Title: New option??
Post by: Shurlock on 12 June, 2004, 00:53:48
I must say: GREAT stuff!

Although I dislike statistics, knowing when the 'real' sharing users are online and when not, is absolutely interesting!

As a mattre of fact, it would be nice if just 1 extra line of info were present:

The average share per user of each measurement!

Hope this makes sence and that any of you bright programmers will be able to apply it!

Thanks!
Title:
Post by: Herodes on 12 June, 2004, 01:38:18
QuoteOriginally posted by Shurlock
I must say: GREAT stuff!

Although I dislike statistics, knowing when the 'real' sharing users are online and when not, is absolutely interesting!

As a mattre of fact, it would be nice if just 1 extra line of info were present:

The average share per user of each measurement!

Hope this makes sence and that any of you bright programmers will be able to apply it!

Thanks!

I 'll allow to my self to say just one thing !

HANG ON, You are about to take a ride !!!

:D:D:D:D:D
Title:
Post by: Shurlock on 12 June, 2004, 03:45:33
Herodes,

Please.... do NOT do this!

I very much  need to go to sleep and you are keeping me from  it!! :rolleyes:

Hope it will be worth staying awake for!!

Greets!
Title:
Post by: Herodes on 12 June, 2004, 04:22:51
QuoteOriginally posted by Shurlock
Herodes,

Please.... do NOT do this!

I very much  need to go to sleep and you are keeping me from  it!! :rolleyes:

Hope it will be worth staying awake for!!

Greets!

Noooo, u don't do that !!!

I am working hard ....
trying my best I want it to finish too ....
Title:
Post by: [PT]CableGuy on 22 June, 2004, 01:33:56
Any news recently ? :]
Title:
Post by: plop on 22 June, 2004, 04:22:15
QuoteOriginally posted by [PT]CableGuy
Any news recently ? :]
herodes is on his way back 2 greece, so he's kinda busy on other things.
infact he prob doesn't even have a working inet connection @ the moment.
but he'll be back as soon as possible.

plop
Title:
Post by: [PT]CableGuy on 22 June, 2004, 12:00:10
Thanks for the info plop . :D
Title: stats
Post by: bluebear on 23 June, 2004, 22:11:48
I'm currently working on a statsbot, to do stats like the ones found on irc...

Please post any ideas of what it should contain :)

I have a test page here: http://www.thewildplace.dk/stats/


//BlueBear
Title: News From the Front ...
Post by: Herodes on 25 June, 2004, 01:51:15
I am terribly sorry to rediscover the world outside the Monitor ....
Matrix Sucks ..!!!!
In fact world out of Internet seems so ....    o-r-g-a-n-i-c  (D:)
I really need some money for the time being so I am doing 3Ds for a local architectural firm ...

In my weekends I try to clean up the script, although I haven't progressed much...  :s

It is difficult even to get free time out here ... pls excuse my slow responses (56K !lol!not! :) ... the thing is that this script is NOT off the table ... not yet!

Glad to "bit" u guys once again ... thanks for the interest shown ...

------------------------------------------------------------
( My deep Sympathies to England, German, Italy for the missing the Best Euro Cup :D
( ok ok ok the Greeks may have stood up to now ..  But its all a big laugh anyway ... We'll Laugh while we can <-- to the Greek National Team ))
------------------------------------------------------------

[*note*] To bluebear : Pls open a thread and pass on script ...  The web output looks terrific m8 !!!! I'd like to see how u do it .. :D
Title:
Post by: bluebear on 25 June, 2004, 15:00:07
It's actually not a lua script, but an visual basic application.. It logs into the hub, stores activity in a database. And generates the html and either publish it  to a local folder, or send it to a remote server via ftp.

It's not a script cause it should be able to login on any hubsoft... Just wrote here cause i saw that you already were talking stats :)

And herodes about the design it's "stolen" from a irc log file parser :) But yes it looks great...
Title:
Post by: [PT]CableGuy on 12 July, 2004, 20:04:00
Hi there:

bluebear  , can you show us the VBScript that you're talking ?
I sure am interested :]

Herodes  , is there a new version of this script ?
I love it !!!! :D
Title:
Post by: Herodes on 12 July, 2004, 20:34:50
I am learning stuff about lua ... All the time ...

and that exactly is the problem with this script lol ...

sorry no new ver available atm ...
troubles with other things in life,
can take more than a couple of months ...

currently it is the 2nd month running that u haven't seen something from this thread ... I am aware of that ...

I am glad u like it and I hope I will find enough time to make the comig version as perf as possible ..

till then .. :)

>Lets code ...
Title:
Post by: [PT]CableGuy on 13 July, 2004, 14:25:15
QuoteOriginally posted by Herodes
till then .. :)

>Lets code ...
LOL , and what about the European Trofy ?
Congratulations to you and all the greeks. :D

I'll be around. :]