chiark / gitweb /
Actually cope with nick changes.
[ircbot] / bot.tcl
diff --git a/bot.tcl b/bot.tcl
index e313f5b3cf702d0b511b537a5585c0bd15342f17..876a2383a2e4136827604181ce78a4d5fc5c2039 100755 (executable)
--- a/bot.tcl
+++ b/bot.tcl
@@ -90,7 +90,7 @@ proc out_runqueue {now} {
        set out_queue [lrange $out_queue 1 end]
        if {[llength $out_queue]} {
            append orgwhen "+[expr {$now - $orgwhen}]"
-           append orgwhen ([llength $out_queue])"
+           append orgwhen "([llength $out_queue])"
        }
        puts "$orgwhen -> $msg"
        puts $sock $msg
@@ -415,11 +415,7 @@ proc recordlastseen_n {n how here} {
 }
 
 proc note_topic {showoff whoby topic} {
-    if {[string length $whoby]} {
-       set msg "FYI, $whoby has changed the topic on $showoff"
-    } else {
-       set msg "FYI, I have reset the topic on $showoff"
-    }
+    set msg "FYI, $whoby has changed the topic on $showoff"
     if {[string length $topic] < 160} {
        append msg " to $topic"
     } else {
@@ -526,7 +522,7 @@ proc check_justme {lchan} {
     global nick
     upvar #0 chan_nicks($lchan) nlist
     if {[llength $nlist] != 1} return
-    if {"[lindex $nlist 0]" != "$nick"} return
+    if {"[lindex $nlist 0]" != "[irctolower $nick]"} return
     if {[chandb_exists $lchan]} {
        set mode [chandb_get $lchan mode]
        if {"$mode" != "*"} {
@@ -535,7 +531,6 @@ proc check_justme {lchan} {
        set topic [chandb_get $lchan topicset]
        if {[string length $topic]} {
            sendout TOPIC $lchan $topic
-           note_topic $lchan {} $topic
        }
     } else {
        sendout PART $lchan
@@ -624,15 +619,15 @@ proc msg_NICK {p c newnick} {
     prefix_nick
     recordlastseen_n $n "changing nicks to $newnick" 0
     recordlastseen_n $newnick "changing nicks from $n" 1
+    set luser [irctolower $n]
+    set lusernew [irctolower $newnick]
     foreach ary $nick_arys {
-       upvar #0 nick_${ary}($n) old
-       upvar #0 nick_${ary}($newnick) new
+       upvar #0 nick_${ary}($luser) old
+       upvar #0 nick_${ary}($lusernew) new
        if {[info exists new]} { error "nick collision ?! $ary $n $newnick" }
        if {[info exists old]} { set new $old; unset old }
     }
-    upvar #0 nick_onchans($new)
-    set luser [irctolower $n]
-    set lusernew [irctolower $newnick]
+    upvar #0 nick_onchans($lusernew) oc
     foreach ch $oc {
        upvar #0 chan_nicks($ch) nlist
        set nlist [grep tn {"$tn" != "$luser"} $nlist]