-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuptime.tcl
More file actions
48 lines (36 loc) · 1.23 KB
/
uptime.tcl
File metadata and controls
48 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
bind pub - !uptime doUptime
bind pub - !botup doBotUp
#setudef flag do_uptime
proc doUptime {nick uhost hand chan arg} {
# Comment this out if you want it to work on a global concept
if {![channel get $chan "do_uptime"]} { return }
global botnick
if {[llength [join $arg]] > 0} {
if {[string compare -nocase [lindex [join $arg] 0] $botnick]} {
return
}
}
catch {exec uptime} uptime
catch {exec hostname} hostname
set hostname [string tolower $hostname]
catch {exec lsb_release -ds} distro
set distro [string trim $distro "\""]
set osver [lindex [unames] 0]
putquick "PRIVMSG $chan :Uptime for $hostname ($distro): $uptime"
}
proc doBotUp {nick uhost hand chan arg} {
# Comment this out if you want it to work on a global concept
if {![channel get $chan "do_uptime"]} { return }
global botnick
if {[llength [join $arg]] > 0} {
if {[string compare -nocase [lindex [join $arg] 0] $botnick]} {
return
}
}
global uptime
global server-online
set myuptime [duration [expr [clock seconds] - $uptime]]
set myonline [duration [expr [clock seconds] - ${server-online}]]
putquick "PRIVMSG $chan :I have been running for $myuptime"
putquick "PRIVMSG $chan :I have been connected for $myonline"
}