AuthorMessage
ATAG
n00b
Posts: 12

It's a ported script but works fine  8)
Code:
----------------------------------------------------------------
-- hex_uptime.lua By ATAG
-- version ?? dunno :D ( 0.1)
-- 29.01.2007
-- Originally created by Hungarista for VerliHub
----------------------------------------------------------------
Settings = {
HubName = "error",
}
function Main()
   badclients = {"dcgui"} -- $HubName in dcgui is big suck :D
   passed = {}
   iUptime = Hub.Uptime()
   iTimer = 60
   iTimer2 = 0
   Timer = NewTimer("OnTimer")
   Timer:Set(1000)
   Timer:Start()
   local f,err = io.open("hub.ini","r")
   if not err then
      f:close()
      for line in io.lines("hub.ini") do
         if not string.find(line,"^%b[]") then
            _,_,key,value = string.find(line,"(%S+)=(.*)%s*")
            if Settings[key] then Settings[key]=value end
         end
      end
   end
end
function OnTimer()
   iUptime = iUptime + 1
   iTimer2 = iTimer2 + 1
   if iTimer2 == iTimer then
      topic = GetTopic()
      for i,v in pairs(passed) do
         if topic and topic ~= "" then
            SendDataTo(v,"$HubName "..Settings.HubName.." - "..topic.." - Hub uptime: "..GetParsedUpTime(iUptime).."|")
         else SendDataTo(v,"$HubName "..Settings.HubName.." - Hub uptime: "..GetParsedUpTime(iUptime).."|")
         end
      end
      iTimer2 = 0
   end
end
function ErrorEvent(err)
   SendToAll(Hub.BotName(),err)
end
function UserConnected(curUser)
   goodtag = true
   for i,v in pairs(badclients) do
      if string.find(curUser.sMyINFO, "<"..v) then
         goodtag = false
      end
   end
   if goodtag then table.insert(passed, curUser.iUserID) end
end
function UserDisconnected(curUser)
   local UserID = curUser.iUserID
   for i,v in ipairs(passed) do
      if v == UserID then table.remove(passed,i) end
   end
end
function GetParsedUpTime(int)   -- By  szmeby
   if not int then return "?" end
   local weeks = math.floor(int/(60*60*24*7))
   local days = math.floor(int/(60*60*24))
   local hours = math.floor((int/(60*60))-days*24)
   local mins = math.floor((int/60)-days*60*24-hours*60)
   if weeks == 0 then
      if days == 0 then
            if hours == 0 then
            return GetName(mins,"minute")
         else
            return GetName(hours,"hour")..", "..GetName(mins,"minute")
         end
      else
         return GetName(days,"day")..", "..GetName(hours,"hour")..", "..GetName(mins,"minute")
      end
   else
      return GetName(weeks,"week")..", "..GetName(days,"day")..", "..GetName(hours,"hour")..", "..GetName(mins,"minute")
   end
end 
function GetName(n, name)
   if n > 1 then name = name.."s" end
   return n.." "..name
end
function Unload()
   local topic = GetTopic()
   for i,v in ipairs(passed) do
      if topic then
         SendDataTo(v,"$HubName "..Settings.HubName.." - "..topic.."|")
      else
         SendDataTo(v,"$HubName "..Settings.HubName.."|")
      end
   end
end