chiark
/
gitweb
/
~mdw
/
ircbot
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Intervals in ping messages are abbreviated.
[ircbot]
/
bot.tcl
diff --git
a/bot.tcl
b/bot.tcl
index 0733d2c3fb5470eb89b0a6feae8c9d553da5d868..45af8651d66e0a89a0cd4c15a5a1bba8f555e37b 100755
(executable)
--- a/
bot.tcl
+++ b/
bot.tcl
@@
-275,11
+275,11
@@
proc prefix_nick {} {
}
}
}
}
-proc showintervalsecs {howlong} {
- return [showintervalsecs/[opt timeformat] $howlong]
+proc showintervalsecs {howlong
abbrev
} {
+ return [showintervalsecs/[opt timeformat] $howlong
$abbrev
]
}
}
-proc showintervalsecs/ks {howlong} {
+proc showintervalsecs/ks {howlong
abbrev
} {
if {$howlong < 1000} {
return "${howlong}s"
} else {
if {$howlong < 1000} {
return "${howlong}s"
} else {
@@
-298,15
+298,19
@@
proc showintervalsecs/ks {howlong} {
}
}
}
}
-proc format_qty {qty unit} {
+proc format_qty {qty unit
abbrev
} {
set o $qty
set o $qty
- append o " "
- append o $unit
- if {$qty != 1} { append o s }
+ if {$abbrev} {
+ append o [string range $unit 0 0]
+ } else {
+ append o " "
+ append o $unit
+ if {$qty != 1} { append o s }
+ }
return $o
}
return $o
}
-proc showintervalsecs/hms {qty} {
+proc showintervalsecs/hms {qty
abbrev
} {
set ul {second 60 minute 60 hour 24 day 7 week}
set remainv 0
while {[llength $ul] > 1 && $qty >= [set uv [lindex $ul 1]]} {
set ul {second 60 minute 60 hour 24 day 7 week}
set remainv 0
while {[llength $ul] > 1 && $qty >= [set uv [lindex $ul 1]]} {
@@
-315,10
+319,10
@@
proc showintervalsecs/hms {qty} {
set qty [expr {($qty-$remainv)/$uv}]
set ul [lreplace $ul 0 1]
}
set qty [expr {($qty-$remainv)/$uv}]
set ul [lreplace $ul 0 1]
}
- set o [format_qty $qty [lindex $ul 0]]
+ set o [format_qty $qty [lindex $ul 0]
$abbrev
]
if {$remainv} {
if {$remainv} {
- append o " "
- append o [format_qty $remainv $remainu]
+ if {!$abbrev} { append o " " }
+ append o [format_qty $remainv $remainu
$abbrev
]
}
return $o
}
}
return $o
}
@@
-327,7
+331,7
@@
proc showinterval {howlong} {
if {$howlong <= 0} {
return {just now}
} else {
if {$howlong <= 0} {
return {just now}
} else {
- return "[showintervalsecs $howlong] ago"
+ return "[showintervalsecs $howlong
0
] ago"
}
}
}
}
@@
-1406,7
+1410,7
@@
proc marktime_desc {mt} {
} elseif {"$mt" == "once"} {
return "I will send you one informational message when I see you."
} else {
} elseif {"$mt" == "once"} {
return "I will send you one informational message when I see you."
} else {
- return "I'll send you a message every [showintervalsecs $mt]."
+ return "I'll send you a message every [showintervalsecs $mt
0
]."
}
}
}
}
@@
-1530,7
+1534,7
@@
def_ucmd summon {
set idletime [expr {$now - $idlesince}]
set ls $now
ucmdr {} {} {} "invites $target ($tty[expr {
set idletime [expr {$now - $idlesince}]
set ls $now
ucmdr {} {} {} "invites $target ($tty[expr {
- $idletime > 10 ? ", idle for [showintervalsecs $idletime]" : ""
+ $idletime > 10 ? ", idle for [showintervalsecs $idletime
0
]" : ""
}]) to [expr {
[ischan $dest] ? "join us here" : "talk to you"
}]."
}]) to [expr {
[ischan $dest] ? "join us here" : "talk to you"
}]."
@@
-1628,7
+1632,8
@@
proc lnick_pingstring {why oc apstring} {
upvar #0 chan_lastactivity($ch) la
if {![info exists la]} continue
if {$la <= $best_la} continue
upvar #0 chan_lastactivity($ch) la
if {![info exists la]} continue
if {$la <= $best_la} continue
- set activity "$ch [showintervalsecs [expr {[clock seconds]-$la}]]"
+ set since [showintervalsecs [expr {[clock seconds]-$la}] 1]
+ set activity "$ch $since"
set best_la $la
}
} else {
set best_la $la
}
} else {