chiark / gitweb /
Merge up from trunk. cvs up -j branchpoint-2001-10-09-tell -j mergeup-1-2001-10...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 14 Feb 2002 18:14:29 +0000 (18:14 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 14 Feb 2002 18:14:29 +0000 (18:14 +0000)
blight.tcl
bot.tcl
bridge.tcl
helpinfos
parsecmd.tcl
repeatedly.sh
test.tcl

index 6092f9be9177ced04936f02319e8dfdf45ec2bba..a5b4de7b29315f886839178c4a30644767a39089 100644 (file)
@@ -8,3 +8,4 @@ set ownmailaddr blight@chiark.greenend.org.uk
 set socketargs {}
 
 source bot.tcl
+source botpass.tcl
diff --git a/bot.tcl b/bot.tcl
index ac5714b3d4de991892eaad3b7e343aa2d7056008..b5abdda4a8798fda7988c81127fb120934c50abd 100755 (executable)
--- a/bot.tcl
+++ b/bot.tcl
@@ -26,22 +26,47 @@ proc showintervalsecs {howlong abbrev} {
     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]
     }
 }
 
@@ -95,10 +120,13 @@ proc parse_interval {specified min} {
        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 "interval too large" }
-    set result [expr {$value*$u}]
+    set result [expr {round($value*$u)}]
     if {$result < $min} { error "interval too small (<${min}s)" }
     return $result
 }
@@ -1539,6 +1567,7 @@ proc timeformat_desc {tf} {
     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" }
     }
 }
@@ -1831,9 +1860,27 @@ def_ucmd identpass {
     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
 
@@ -2005,6 +2052,10 @@ proc ensure_globalsecret {} {
 }
 
 proc connected {} {
+    global operuserpass
+    if {[info exists operuserpass]} {
+       eval sendout OPER $operuserpass
+    }
     foreach chan [chandb_list] {
        if {[chandb_get $chan autojoin]} { dojoin $chan }
     }
index 1282aed7e918eda4bb172e622fdae4c067373f33..64d2d5ed66de0ed3daf10740dd958bf0d3d909f0 100755 (executable)
@@ -152,6 +152,10 @@ def_ucmd who {
     return [list $o]
 }
 
-loadhelp
-ensure_connecting
-foreach botid $bots { bnbot_ensure_connecting $botid }
+if {[catch {
+    loadhelp
+    ensure_connecting
+    foreach botid $bots { bnbot_ensure_connecting $botid }
+} emsg]} {
+    fail "startup: $emsg"
+}
index 2359e88b55ed7ab20756dfa7690529435af542c8..9d920d2d114c2033d4811a139dec1f35cd58d2a7 100644 (file)
--- a/helpinfos
+++ b/helpinfos
@@ -10,11 +10,11 @@ General commands:           Registration and user settings:
  !help [<cmd>|<opt>|<topic>]  !register [insecure|delete]
  !seen <nick>                 !set [<opt> [<value>]]      who [<nick>]
  !summon <username>           (See `help !identify', `help !blight-id')
- !invite [<chan>] <nick>...  Channel settings (see `help channel'):
- !op [<chan>]                 !channel [<chan>] <setting> [....]
- !leave [<chan>]             Additional help topics:
- !ping [<stuff ...>]          !identify !identpass !invite !blight-id
- !tell <nick> <message ...>
+ !invite [<chan>] <nick>...  For channel managers (see `help channel'):
+ !leave [<chan>]              !channel [<chan>] <setting> [....]
+ !ping [<stuff ...>]          !op [<chan>]                          
+ !tell <nick> <message ...>  Additional help topics:                 
+ !kill <nick> [<reason>]      !identify !identpass !invite !blight-id
 Send commands to me by /msg, or say them in channel with \! in front.
 To get me on a channel, invite me.  To become channel manager, op me.
 
@@ -190,6 +190,12 @@ invite <channel> <nick> ...   privately
  This can be disabled for managed channels - see `help !userinvite'.
 To get me to join a channel, just invite me to it.
 
+:kill
+kill <nick> [<reason>]
+ Asks me to throw that client off IRC completely, using my IRC
+ Operator privilege.  You must have identified yourself as the user
+ to whom the nick is registered.  (See `help !register'.)
+
 :register
 register            register your nick (or make it secure)
 register delete     delete your nick registration
@@ -204,13 +210,15 @@ register insecure   register your nick insecurely
 set                  show your current settings
 set <option>         show the current setting of <option>
 set <option> <value> set <option> to <value>
- Options:   !timeformat ks|hms   !marktime off|once|<!interval>
-            !tellme ...
+ Options:  !timeformat ks|hms|beat
+           !marktime off|once|<n>[k]s|<n>m|<n>h
+           !tellme ...
  See also `help <option>', `help !register' and `help !identify'
 
 :timeformat
-!set timeformat ks   show times in seconds, kiloseconds, etc.
-set timeformat hms  use days, hours, minutes, seconds
+!set timeformat ks    show times in seconds, kiloseconds, etc.
+set timeformat hms   use days, hours, minutes, seconds
+set timeformat beat  use beats (1000 B = 1 day)
 
 :ping
 ping [<string>]
index d7fba69bf8cc95a99d0eba836e8ada29c39d07b0..6c6f81d0c26314d8b67d5da7e2b172d425acafdb 100644 (file)
@@ -39,7 +39,7 @@ proc go_usercommand {p c n dest text} {
     set ucmd [ta_word]
     set procname ucmd/[string tolower $ucmd]
     if {[catch { info body $procname }]} {
-       usererror "Unknown command; try help for help."
+       usererror "Unknown command; try help for Help."
     }
     $procname $p $dest
 }
index db6e3bafe2918b5cccc27b08f80ad46137b18fed..4a44447d2b1c7844c8feb2581ee093577dbdb34a 100755 (executable)
@@ -4,7 +4,11 @@ cd "`dirname $0`"
 
 while true; do
        date
-       HOME=. tclsh8.2 || true
+       set +e
+       HOME=. alarm 50000 tclsh8.2
+       rc=$?
+       set -e
        date
-       sleep 600
+       test $rc = 142 || sleep 590
+       sleep 10
 done
index 993a1aa0ed50105cba300a30a8f33cd65e02c4a5..9ba46a7d569f5e62592b62c43ddc915170400fe1 100644 (file)
--- a/test.tcl
+++ b/test.tcl
@@ -8,3 +8,4 @@ set marktime_min 10
 set ownmailaddr ijackson@chiark.greenend.org.uk
 
 source bot.tcl
+source botpass.tcl