
##############################################################################
#                                                                            #
# TCL Editat in limba romana de catre http://solidservices.ro                #
#                                                                            #
##############################################################################

#Seteaza numele serverului:
#
set bshserv "Nume Server"

set asus(bot) "0"
set asus(msgtype) "2"
set asus(trig) "!"
set asus(flag) ""


set asus(version) "1.0.0"
putlog "uptime.tcl v$asus(version) by WWW.al1n.US \002loaded\002" 

bind PUB $asus(flag) $asus(trig)uptime asus_pub_uptime
bind MSG $asus(flag) uptime asus_msg_uptime

proc asus_msg {who what} {
 global asus
  if {$asus(msgtype) == "1"} {
   puthelp "NOTICE $who :$what"
  } else {
  puthelp "PRIVMSG $who :$what"
 }
}

proc asus_pub_uptime {nick uhost hand chan vasus} {
 global asus botnick
 asus_uptime $nick $uhost $hand $chan $vasus
}

proc asus_msg_uptime {nick uhost hand vasus} {
 global asus botnick
 set chan [lindex [split $vasus] 0]
 if {$asus(msgtype) == "2"} {
  if {[lindex $vasus 0] == ""} {
   puthelp "NOTICE $nick :Usage: /msg $botnick uptime <#chan>"
   return 0
   }
  }.
 asus_uptime $nick $uhost $hand $chan $vasus
}

proc asus_uptime {nick uhost hand chan vasus} {
 global botnick asus timezone version admin uptime server server-online bshserv
  catch {exec hostname} asus(hostname)
  if {$asus(msgtype) == "2"} {
   set asus_who $chan
  } else {
   set asus_who $nick
  } 
 if {$asus(bot) == "0"} {set asus(bote) Eggdrop} else {set asus(bote) Windrop}
 if {$asus(bot) == "0"} {catch {exec uptime} asus(uptime)} else {set asus(uptime)
 [duration [expr [clock clicks] / 1000]]}  
 asus_msg $asus_who "$bshserv :\002\00312 $asus(uptime)\002\003"
}

proc asus_time {time} {
 set ltime [expr [unixtime] - $time]
 set seconds [expr $ltime % 60]
 set ltime [expr ($ltime - $seconds) / 60]
 set minutes [expr $ltime % 60]
 set ltime [expr ($ltime - $minutes) / 60]
 set hours [expr $ltime % 24]
 set days [expr ($ltime - $hours) / 24]
 set asus_times ""
 if {$days} {
  append asus_times "$days "
  if {$days == "1"} {
   append asus_times "day "
   } else {
    append asus_times "days "
    }
   }
  if {$hours} {
   append asus_times "$hours "
   if {$hours == "1"} {
    append asus_times "hour "
    } else {
     append asus_times "hours "
    }
   }
  if {$minutes} {
   append asus_times "$minutes "
   if {$minutes == "1"} {
    append asus_times "minute "
    } else {
     append asus_times "minutes"
    }
   }
  if {$seconds} {
   append asus_times " $seconds "
   if {$seconds == "1"} {
    append asus_times "second"
    } else {
     append asus_times "seconds"
    }
   }
 return $asus_times
}





        

