return [showintervalsecs/[opt timeformat] $howlong $abbrev]
}
+proc formatsf {pfx value} {
+ foreach {min format} { 100 %.0f 10 %.1f 0 %.2f} {
+ set fval [format $format $value]
+ if {$fval < $min} continue
+ return [format "$fval${pfx}" $value]
+ }
+}
+
+proc showintervalsecs/beat {howlong abbrev} {
+ # We split in two to avoid overflow problems.
+ if {$howlong < 86 } {
+ # mB's
+ set pfx mB
+ return [format "%.0fmB" [expr {round($howlong * 1.157)*10} ]]
+ } else {
+ if {$howlong < 86400 } {
+ # B's
+ set pfx B
+ set value [expr {$howlong / 86.4}]
+ } else {
+ # kB's
+ set pfx kB
+ set value [expr {$howlong / 86400.0}]
+ }
+ }
+ return [formatsf $pfx $value]
+}
+
proc showintervalsecs/ks {howlong abbrev} {
if {$howlong < 1000} {
return "${howlong}s"
} else {
if {$howlong < 1000000} {
- set pfx k
+ set pfx ks
set scale 1000
} else {
- set pfx M
+ set pfx Ms
set scale 1000000
}
set value [expr "$howlong.0 / $scale"]
- foreach {min format} {100 %.0f 10 %.1f 1 %.2f} {
- if {$value < $min} continue
- return [format "$format${pfx}s" $value]
- }
+ return [formatsf $pfx $value]
}
}
}
proc leaving {lchan} {
+ global nick_onchans
foreach luser [array names nick_onchans] {
upvar #0 nick_onchans($luser) oc
set oc [grep tc {"$tc" != "$lchan"} $oc]
lappend nlist $nl
nick_ishere $n
}
-proc msg_PART {p c chan} {
+proc msg_PART {p c chan args} {
prefix_nick
- recordlastseen_n $n "leaving $chan" 1
+ set msg "leaving $chan"
+ if {[llength $args]} {
+ set why [lindex $args 0]
+ if {"[irctolower $why]" != "[irctolower $n]"} { append msg " ($why)" }
+ }
+ recordlastseen_n $n $msg 1
process_kickpart $chan $n
}
proc msg_QUIT {p c why} {
if {[llength names_chans] > 1} {
set oc [grep tc {[lsearch -exact $tc $names_chans] >= 0} $oc]
}
- if {![llength $oc]} { lnick_forget $n }
+ if {![llength $oc]} { lnick_forget $luser }
}
unset names_chans
}
switch -exact $tf {
ks { return "Times will be displayed in seconds or kiloseconds." }
hms { return "Times will be displayed in hours, minutes, etc." }
+ beat { return "Times will be displayed in beats (1000B = 1d)." }
default { error "invalid timeformat: $v" }
}
}
s { set u 1 }
ks { set u 1000 }
m { set u 60 }
- h { set u 3600 }
+ mb { set u 0.0864 }
+ b { set u 86.4 }
+ kb { set u 86400 }
default { error "unknown unit of time $unit" }
}
if {$value > 86400*21/$u} { error "marktime interval too large" }
- set mt [expr {$value*$u}]
+ set mt [expr {round($value*$u)}]
if {$mt < $marktime_min} { error "marktime interval too small" }
} else {
error "invalid syntax for marktime"
ucmdr "Pleased to see you, $username." {}
}
+def_ucmd kill {
+ global nick
+ prefix_nick
+ set target [ta_nick]
+ if {![nickdb_exists $target]} { error "$target is not a registered nick." }
+ set wantu [nickdb_get $target username]
+ if {![string length $wantu]} { error "$target is insecurely registred." }
+ upvar #0 nick_username([irctolower $n]) nu
+ if {![info exists nu]} { error "You must identify yourself first." }
+ if {"$wantu" != "$nu"} {
+ error "You are the wrong user, $nu - $target belongs to $wantu."
+ }
+ set reason "at request of user $nu"
+ if {[ta_anymore]} { append reason "; $text" }
+ sendout KILL $target $reason
+}
+
def_ucmd summon {
set target [ta_word]
ta_nomore
+ # fixme would be nice if the rest of the text was passed on instead
check_username $target
prefix_nick
catch { exec uptime } uptime
set nnicks [llength [array names nick_onchans]]
if {[regexp \
- {^ *([0-9:apm]+) +up.*, +(\d+) users, +load average: +([0-9., ]+) *$} \
+ {^ *([0-9:apm]+) +up.*, +(\d+) users?, +load average: +([0-9., ]+) *$} \
$uptime dummy time users load]} {
regsub -all , $load {} load
set uptime "$time $nnicks/$users $load"
}
proc connected {} {
+ global operuserpass
+ if {[info exists operuserpass]} {
+ eval sendout OPER $operuserpass
+ }
foreach chan [chandb_list] {
if {[chandb_get $chan autojoin]} { dojoin $chan }
}