chiark / gitweb /
Attempts at fixing nick-changing.
[ircbot] / bot.tcl
diff --git a/bot.tcl b/bot.tcl
index 15be233ebc8038ecbd18aa3e6560a3df6c2bbc09..bcbc1bc92bf60a304d43621539c1057709968477 100755 (executable)
--- a/bot.tcl
+++ b/bot.tcl
@@ -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 {
@@ -432,10 +428,8 @@ proc note_topic {showoff whoby topic} {
     } else {
        set tryspies $tell
     }
-puts "NT>showoff $showoff|whoby $whoby|topic $topic|tell $tell|tryspies $tryspies|msg $msg<"
     foreach spy $tryspies {
        set see [chandb_get $spy topicsee]
-puts "NT>spy $spy|see $see<"
        if {[lsearch -exact $see $showoff] >= 0 || \
                ([lsearch -exact $see *] >= 0 && \
                [lsearch -exact $tell $spy] >= 0)} {
@@ -528,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" != "*"} {
@@ -537,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
@@ -632,7 +625,7 @@ proc msg_NICK {p c newnick} {
        if {[info exists new]} { error "nick collision ?! $ary $n $newnick" }
        if {[info exists old]} { set new $old; unset old }
     }
-    upvar #0 nick_onchans($new)
+    upvar #0 nick_onchans($new) oc
     set luser [irctolower $n]
     set lusernew [irctolower $newnick]
     foreach ch $oc {
@@ -1127,13 +1120,7 @@ def_chancmd show {
        append l ", mode " [chandb_get $chan mode]
        append l ", userinvite " [chandb_get $chan userinvite] "."
        append l "\nManagers: "
-       append l [join [chandb_get $chan managers] " "] "\n"
-       set t [chandb_get $chan topicset]
-       if {[string length $t]} {
-           append l "Topic to set: $t"
-       } else {
-           append l "I will not change the topic."
-       }
+       append l [join [chandb_get $chan managers] " "]
        foreach {ts sep} {see "\n" tell "  "} {
            set t [chandb_get $chan topic$ts]
            append l $sep
@@ -1143,6 +1130,13 @@ def_chancmd show {
                append l "Topic $ts list is empty."
            }
        }
+       append l "\n"
+       set t [chandb_get $chan topicset]
+       if {[string length $t]} {
+           append l "Topic to set: $t"
+       } else {
+           append l "I will not change the topic."
+       }
        ucmdr {} $l
     } else {
        ucmdr {} "The channel $chan is not managed."