chiark / gitweb /
Set calling_nick to new nick on nick changes.
[ircbot] / irccore.tcl
index 7a6f1574edac633aefb6023909430408911efd9c..5d28cef85d21aff387c5b74d2bfd91dd985a9168 100644 (file)
@@ -7,10 +7,11 @@ proc defset {varname val} {
 defset port 6667
 
 defset nick testbot
+defset ident blight
 defset ownfullname "testing bot"
 defset ownmailaddr test-irc-bot@example.com
 
-defset musthaveping_ms 10000
+defset muststartby_ms 10000
 defset out_maxburst 6
 defset out_interval 2100
 defset out_lag_lag 5000
@@ -162,10 +163,10 @@ proc bgerror {msg} {
 }
 
 proc onread {args} {
-    global sock nick calling_nick errorInfo errorCode line_org_1char
+    global sock nick calling_nick errorInfo errorCode line_org_endchar
 
     if {[gets $sock line] == -1} { fail "EOF/error on input" }
-    set line_org_1char [string range $line 0 0]
+    set line_org_endchar [string range $line end end]
     regsub -all "\[^ -\176\240-\376\]" $line ? line
     set org $line
     
@@ -258,12 +259,15 @@ proc prefix_nick {} {
 }
 
 proc msg_PING {p c s1} {
-    global musthaveping_after
     prefix_none
     sendout PONG $s1
-    if {[info exists musthaveping_after]} {
-       after cancel $musthaveping_after
-       unset musthaveping_after
+}
+
+proc msg_001 {args} {
+    global muststartby_after
+    if {[info exists muststartby_after]} {
+       after cancel $muststartby_after
+       unset muststartby_after
        connected
     }
 }
@@ -284,8 +288,8 @@ proc fail {msg} {
 }
 
 proc ensure_connecting {} {
-    global sock ownfullname host port nick socketargs
-    global musthaveping_ms musthaveping_after
+    global sock ownfullname host port nick ident socketargs
+    global muststartby_ms muststartby_after
 
     ensure_outqueue
     
@@ -294,10 +298,10 @@ proc ensure_connecting {} {
     fconfigure $sock -buffering line
     fconfigure $sock -translation crlf
 
-    sendout USER blight 0 * $ownfullname
+    sendout USER $ident 0 * $ownfullname
     sendout NICK $nick
     fileevent $sock readable onread
 
-    set musthaveping_after [after $musthaveping_ms \
-           {fail "no ping within timeout"}]
+    set muststartby_after [after $muststartby_ms \
+           {fail "no successfuly connect within timeout"}]
 }