Commit | Line | Data |
---|---|---|
9bc33297 IJ |
1 | #!/usr/bin/tclsh8.2 |
2 | ||
3 | set host chiark | |
4 | set port 6667 | |
7ce72032 | 5 | if {![info exists nick]} { set nick Blight } |
a69f7d2c | 6 | if {![info exists ownfullname]} { set ownfullname "here to Help" } |
e1ba63be | 7 | set ownmailaddr blight@chiark.greenend.org.uk |
e1ba63be IJ |
8 | |
9 | if {![info exists globalsecret]} { | |
10 | set gsfile [open /dev/urandom r] | |
11 | fconfigure $gsfile -translation binary | |
12 | set globalsecret [read $gsfile 32] | |
13 | binary scan $globalsecret H* globalsecret | |
14 | close $gsfile | |
15 | unset gsfile | |
16 | } | |
9bc33297 | 17 | |
cc2d31de IJ |
18 | proc sendout {command args} { |
19 | global sock | |
9bc33297 IJ |
20 | if {[llength $args]} { |
21 | set la [lindex $args end] | |
22 | set args [lreplace $args end end] | |
23 | foreach i $args { | |
24 | if {[regexp {[: ]} $i]} { | |
cc2d31de | 25 | error "bad argument in output $i ($command $args)" |
9bc33297 IJ |
26 | } |
27 | } | |
cc2d31de | 28 | lappend args :$la |
9bc33297 IJ |
29 | } |
30 | set args [lreplace $args 0 -1 $command] | |
cc2d31de | 31 | set string [join $args { }] |
83dd1224 | 32 | puts "[clock seconds] -> $string" |
9bc33297 IJ |
33 | puts $sock $string |
34 | } | |
9bc33297 IJ |
35 | |
36 | proc log {data} { | |
37 | puts $data | |
38 | } | |
39 | ||
40 | proc logerror {data} { | |
41 | log $data | |
cc2d31de IJ |
42 | } |
43 | ||
44 | proc saveeic {} { | |
45 | global saveei saveec errorInfo errorCode | |
46 | ||
47 | set saveei $errorInfo | |
48 | set saveec $errorCode | |
49 | ||
50 | puts ">$saveec|$saveei<" | |
51 | } | |
52 | ||
53 | proc bgerror {msg} { | |
54 | global save | |
55 | logerror $msg | |
56 | saveeic | |
57 | } | |
9bc33297 IJ |
58 | |
59 | proc onread {args} { | |
a056c4bd | 60 | global sock nick |
9bc33297 | 61 | |
cc2d31de IJ |
62 | if {[gets $sock line] == -1} { set terminate 1; return } |
63 | regsub -all "\[^ -\176\240-\376\]" $line ? line | |
9bc33297 IJ |
64 | set org $line |
65 | if {[regexp -nocase {^:([^ ]+) (.*)} $line dummy prefix remain]} { | |
66 | set line $remain | |
a056c4bd IJ |
67 | if {[regexp {^([^!]+)!} $prefix dummy maybenick] && |
68 | "[irctolower $maybenick]" == "[irctolower $nick]"} return | |
9bc33297 IJ |
69 | } else { |
70 | set prefix {} | |
71 | } | |
cc2d31de | 72 | if {![string length $line]} { return } |
9bc33297 IJ |
73 | if {![regexp -nocase {^([0-9a-z]+) *(.*)} $line dummy command line]} { |
74 | log "bad command: $org" | |
75 | return | |
76 | } | |
cc2d31de | 77 | set command [string toupper $command] |
9bc33297 | 78 | set params {} |
cc2d31de | 79 | while {[regexp {^([^ :]+) *(.*)} $line dummy thisword line]} { |
9bc33297 IJ |
80 | lappend params $thisword |
81 | } | |
82 | if {[regexp {^:(.*)} $line dummy thisword]} { | |
83 | lappend params $thisword | |
84 | } elseif {[string length $line]} { | |
85 | log "junk at end: $org" | |
86 | return | |
87 | } | |
cc2d31de IJ |
88 | if {"$command" == "PRIVMSG" && |
89 | [regexp {^[&#+!]} [lindex $params 0]] && | |
90 | ![regexp {^!} [lindex $params 1]]} { | |
91 | # on-channel message, ignore | |
422f52e4 | 92 | catch { |
83dd1224 | 93 | recordlastseen_p $prefix "talking on [lindex $params 0]" 1 |
422f52e4 | 94 | } |
cc2d31de IJ |
95 | return |
96 | } | |
83dd1224 | 97 | log "[clock seconds] <- $org" |
9bc33297 | 98 | set procname msg_$command |
cc2d31de | 99 | if {[catch { info body $procname }]} { return } |
9bc33297 IJ |
100 | if {[catch { |
101 | eval [list $procname $prefix $command] $params | |
102 | } emsg]} { | |
103 | logerror "error: $emsg ($prefix $command $params)" | |
cc2d31de | 104 | saveeic |
9bc33297 IJ |
105 | } |
106 | } | |
107 | ||
7ce72032 IJ |
108 | proc sendprivmsg {dest l} { |
109 | sendout [expr {[ischan $dest] ? "PRIVMSG" : "NOTICE"}] $dest $l | |
83dd1224 | 110 | } |
7ce72032 IJ |
111 | proc sendaction {dest what} { sendout PRIVMSG $dest "\001ACTION $what\001" } |
112 | proc msendprivmsg {dest ll} { foreach l $ll { sendprivmsg $dest $l } } | |
113 | proc msendprivmsg_delayed {delay dest ll} { after $delay [list msendprivmsg $dest $ll] } | |
83dd1224 | 114 | |
cc2d31de IJ |
115 | proc prefix_none {} { |
116 | upvar 1 p p | |
9bc33297 | 117 | if {[string length $p]} { error "prefix specified" } |
cc2d31de | 118 | } |
9bc33297 | 119 | |
cc2d31de IJ |
120 | proc msg_PING {p c s1} { |
121 | prefix_none | |
122 | sendout PONG $s1 | |
9bc33297 IJ |
123 | } |
124 | ||
cc2d31de IJ |
125 | proc check_nick {n} { |
126 | if {[regexp -nocase {[^][\\`_^{|}a-z0-9-]} $n]} { error "bad char in nick" } | |
127 | if {[regexp {^[-0-9]} $n]} { error "bad nick start" } | |
128 | } | |
129 | ||
422f52e4 IJ |
130 | proc ischan {dest} { |
131 | return [regexp {^[&#+!]} $dest] | |
132 | } | |
133 | ||
134 | proc irctolower {v} { | |
135 | foreach {from to} [list "\\\[" "{" \ | |
136 | "\\\]" "}" \ | |
137 | "\\\\" "|" \ | |
138 | "~" "^"] { | |
139 | regsub -all $from $v $to v | |
140 | } | |
141 | return [string tolower $v] | |
142 | } | |
143 | ||
cc2d31de IJ |
144 | proc prefix_nick {} { |
145 | global nick | |
146 | upvar 1 p p | |
147 | upvar 1 n n | |
148 | if {![regexp {^([^!]+)!} $p dummy n]} { error "not from nick" } | |
149 | check_nick $n | |
a056c4bd IJ |
150 | if {"[irctolower $n]" == "[irctolower $nick]"} { |
151 | error "from myself" {} {} | |
152 | } | |
422f52e4 IJ |
153 | } |
154 | ||
7ce72032 IJ |
155 | proc showintervalsecs {howlong} { |
156 | if {$howlong < 1000} { | |
157 | return "${howlong}s" | |
83dd1224 IJ |
158 | } else { |
159 | if {$howlong < 1000000} { | |
160 | set pfx k | |
161 | set scale 1000 | |
162 | } else { | |
163 | set pfx M | |
164 | set scale 1000000 | |
165 | } | |
166 | set value [expr "$howlong.0 / $scale"] | |
167 | foreach {min format} {100 %.0f 10 %.1f 1 %.2f} { | |
168 | if {$value < $min} continue | |
7ce72032 | 169 | return [format "$format${pfx}s" $value] |
83dd1224 IJ |
170 | } |
171 | } | |
172 | } | |
173 | ||
7ce72032 IJ |
174 | proc showinterval {howlong} { |
175 | if {$howlong <= 0} { | |
176 | return {just now} | |
177 | } else { | |
178 | return "[showintervalsecs $howlong] ago" | |
179 | } | |
180 | } | |
181 | ||
83dd1224 IJ |
182 | proc showtime {when} { |
183 | return [showinterval [expr {[clock seconds] - $when}]] | |
184 | } | |
185 | ||
186 | proc def_msgproc {name argl body} { | |
187 | proc msg_$name "varbase $argl" "\ | |
188 | upvar #0 msg/\$varbase/dest d\n\ | |
189 | upvar #0 msg/\$varbase/str s\n\ | |
190 | upvar #0 msg/\$varbase/accum a\n\ | |
191 | $body" | |
192 | } | |
193 | ||
194 | def_msgproc begin {dest str} { | |
195 | set d $dest | |
196 | set s $str | |
197 | set a {} | |
198 | } | |
199 | ||
200 | def_msgproc append {str} { | |
201 | set ns "$s$str" | |
202 | if {[string length $s] && [string length $ns] > 65} { | |
203 | msg__sendout $varbase | |
204 | set s " [string trimleft $str]" | |
205 | } else { | |
206 | set s $ns | |
207 | } | |
208 | } | |
209 | ||
210 | def_msgproc finish {} { | |
211 | msg__sendout $varbase | |
212 | unset s | |
213 | unset d | |
214 | return $a | |
215 | } | |
216 | ||
217 | def_msgproc _sendout {} { | |
218 | lappend a [string trimright $s] | |
219 | set s {} | |
220 | } | |
221 | ||
222 | proc looking_whenwhere {when where} { | |
223 | set str [showtime [expr {$when-1}]] | |
224 | if {[string length $where]} { append str " on $where" } | |
225 | return $str | |
226 | } | |
227 | ||
228 | proc recordlastseen_n {n how here} { | |
229 | global lastseen lookedfor | |
422f52e4 | 230 | set lastseen([irctolower $n]) [list $n [clock seconds] $how] |
83dd1224 IJ |
231 | if {!$here} return |
232 | upvar #0 lookedfor([irctolower $n]) lf | |
233 | if {[info exists lf]} { | |
234 | switch -exact [llength $lf] { | |
235 | 0 { | |
236 | set ml {} | |
237 | } | |
238 | 1 { | |
239 | manyset [lindex $lf 0] when who where | |
240 | set ml [list \ | |
241 | "FYI, $who was looking for you [looking_whenwhere $when $where]."] | |
242 | } | |
243 | default { | |
244 | msg_begin tosend $n "FYI, people have been looking for you:" | |
245 | set i 0 | |
246 | set fin "" | |
247 | foreach e $lf { | |
248 | incr i | |
249 | if {$i == 1} { | |
250 | msg_append tosend " " | |
251 | } elseif {$i == [llength $lf]} { | |
252 | msg_append tosend " and " | |
253 | set fin . | |
254 | } else { | |
255 | msg_append tosend ", " | |
256 | } | |
257 | manyset $e when who where | |
258 | msg_append tosend \ | |
259 | "$who ([looking_whenwhere $when $where])$fin" | |
260 | } | |
261 | set ml [msg_finish tosend] | |
262 | } | |
263 | } | |
264 | unset lf | |
265 | msendprivmsg_delayed 1000 $n $ml | |
266 | } | |
422f52e4 IJ |
267 | } |
268 | ||
83dd1224 | 269 | proc recordlastseen_p {p how here} { |
422f52e4 | 270 | prefix_nick |
83dd1224 | 271 | recordlastseen_n $n $how $here |
422f52e4 IJ |
272 | } |
273 | ||
274 | proc chanmode_arg {} { | |
275 | upvar 2 args cm_args | |
276 | set rv [lindex $cm_args 0] | |
277 | set cm_args [lreplace cm_args 0 0] | |
278 | return $rv | |
279 | } | |
280 | ||
83dd1224 IJ |
281 | proc chanmode_o1 {m g p chan} { |
282 | global nick | |
283 | prefix_nick | |
284 | set who [chanmode_arg] | |
285 | recordlastseen_n $n "being nice to $who" 1 | |
286 | if {"[irctolower $who]" == "[irctolower $nick]"} { | |
7ce72032 | 287 | sendprivmsg $n Thanks. |
83dd1224 IJ |
288 | } |
289 | } | |
290 | ||
422f52e4 IJ |
291 | proc chanmode_o0 {m g p chan} { |
292 | global nick chandeop | |
293 | prefix_nick | |
294 | set who [chanmode_arg] | |
83dd1224 | 295 | recordlastseen_p $p "being mean to $who" 1 |
422f52e4 IJ |
296 | if {"[irctolower $who]" == "[irctolower $nick]"} { |
297 | set chandeop($chan) [list [clock seconds] $p] | |
298 | } | |
cc2d31de | 299 | } |
9bc33297 | 300 | |
422f52e4 IJ |
301 | proc msg_MODE {p c dest modelist args} { |
302 | if {![ischan $dest]} return | |
303 | if {[regexp {^\-(.+)$} $modelist dummy modelist]} { | |
304 | set give 0 | |
305 | } elseif {[regexp {^\+(.+)$} $modelist dummy modelist]} { | |
306 | set give 1 | |
307 | } else { | |
308 | error "invalid modelist" | |
309 | } | |
310 | foreach m [split $modelist] { | |
311 | set procname chanmode_$m$give | |
312 | if {[catch { info body $procname }]} { | |
83dd1224 | 313 | recordlastseen_p $p "fiddling with $dest" 1 |
422f52e4 IJ |
314 | } else { |
315 | $procname $m $give $p $dest | |
316 | } | |
317 | } | |
318 | } | |
319 | ||
a056c4bd IJ |
320 | proc process_kickpart {chan user} { |
321 | check_nick $user | |
322 | if {![ischan $chan]} { error "not a channel" } | |
323 | ||
324 | upvar #0 nick_onchans($user) oc | |
325 | set lc [irctolower $chan] | |
326 | set oc [grep tc {"$tc" != "$lc"} $oc] | |
327 | } | |
328 | ||
329 | proc msg_KICK {p c chans users comment} { | |
330 | set chans [split $chans ,] | |
331 | set users [split $users ,] | |
332 | if {[llength $chans] > 1} { | |
333 | foreach chan $chans user $users { process_kickpart $chan $user } | |
334 | } else { | |
335 | foreach user $users { process_kickpart [lindex $chans 0] $user } | |
336 | } | |
337 | } | |
338 | ||
339 | proc msg_KILL {p c user why} { | |
340 | nick_forget $user | |
341 | } | |
342 | ||
343 | set nick_arys {onchans username} | |
344 | ||
345 | proc nick_forget {n} { | |
346 | global nick_arys | |
347 | foreach ary $nick_arys { | |
348 | upvar #0 nick_${ary}($n) av | |
349 | catch { unset av } | |
350 | } | |
351 | } | |
352 | ||
83dd1224 | 353 | proc msg_NICK {p c newnick} { |
a056c4bd | 354 | global nick_arys |
83dd1224 IJ |
355 | prefix_nick |
356 | recordlastseen_n $n "changing nicks to $newnick" 0 | |
357 | recordlastseen_n $newnick "changing nicks from $n" 1 | |
a056c4bd IJ |
358 | foreach ary $nick_arys { |
359 | upvar #0 nick_${ary}($n) old | |
360 | upvar #0 nick_${ary}($newnick) new | |
361 | if {[info exists new]} { error "nick collision ?! $ary $n $newnick" } | |
362 | if {[info exists old]} { set new $old; unset old } | |
363 | } | |
83dd1224 IJ |
364 | } |
365 | ||
a056c4bd IJ |
366 | proc msg_JOIN {p c chan} { |
367 | prefix_nick | |
368 | recordlastseen_n $n "joining $chan" 1 | |
369 | upvar #0 nick_onchans($n) oc | |
370 | lappend oc [irctolower $chan] | |
371 | } | |
372 | proc msg_PART {p c chan} { | |
373 | prefix_nick | |
374 | recordlastseen_n $n "leaving $chan" 1 | |
375 | process_kickpart $chan $n | |
376 | } | |
377 | proc msg_QUIT {p c why} { | |
378 | prefix_nick | |
379 | recordlastseen_n $n "leaving ($why)" 0 | |
380 | nick_forget $n | |
381 | } | |
422f52e4 | 382 | |
cc2d31de IJ |
383 | proc msg_PRIVMSG {p c dest text} { |
384 | prefix_nick | |
422f52e4 | 385 | if {[ischan $dest]} { |
83dd1224 | 386 | recordlastseen_n $n "invoking me in $dest" 1 |
422f52e4 | 387 | set output $dest |
cc2d31de | 388 | } else { |
83dd1224 | 389 | recordlastseen_n $n "talking to me" 1 |
422f52e4 IJ |
390 | set output $n |
391 | } | |
392 | ||
393 | if {[catch { | |
394 | regsub {^! *} $text {} text | |
395 | set ucmd [ta_word] | |
83dd1224 | 396 | set procname ucmd/[string tolower $ucmd] |
422f52e4 IJ |
397 | if {[catch { info body $procname }]} { |
398 | error "unknown command; try help for help" | |
399 | } | |
83dd1224 | 400 | $procname $p $dest |
422f52e4 | 401 | } rv]} { |
7ce72032 | 402 | sendprivmsg $n "error: $rv" |
422f52e4 | 403 | } else { |
7ce72032 IJ |
404 | manyset $rv priv_msgs pub_msgs priv_acts pub_acts |
405 | foreach {td val} [list $n $priv_msgs $output $pub_msgs] { | |
406 | foreach l [split $val "\n"] { | |
407 | sendprivmsg $td $l | |
408 | } | |
409 | } | |
410 | foreach {td val} [list $n $priv_acts $output $pub_acts] { | |
422f52e4 | 411 | foreach l [split $val "\n"] { |
7ce72032 | 412 | sendaction $td $l |
422f52e4 IJ |
413 | } |
414 | } | |
415 | } | |
416 | } | |
417 | ||
a056c4bd IJ |
418 | proc msg_INVITE {p c n chan} { |
419 | after 1000 [list sendout JOIN $chan] | |
420 | } | |
421 | ||
422 | proc grep {var predicate list} { | |
423 | set o {} | |
424 | upvar 1 $var v | |
425 | foreach v $list { | |
426 | if {[uplevel 1 [list expr $predicate]]} { lappend o $v } | |
427 | } | |
428 | return $o | |
429 | } | |
430 | ||
431 | proc msg_353 {p c dest type chan nicklist} { | |
432 | global names_chans nick_onchans | |
433 | if {![info exists names_chans]} { set names_chans {} } | |
434 | set chan [irctolower $chan] | |
435 | lappend names_chans $chan | |
436 | foreach n [array names nick_onchans] { | |
437 | upvar #0 nick_onchans($n) oc | |
438 | set oc [grep tc {"$tc" != "$chan"} $oc] | |
439 | } | |
440 | foreach n [split $nicklist { }] { | |
441 | regsub {^[@+]} $n {} n | |
442 | check_nick $n | |
443 | if {![string length $n]} continue | |
444 | upvar #0 nick_onchans($n) oc | |
445 | lappend oc $chan | |
446 | } | |
447 | } | |
448 | ||
449 | proc msg_366 {p c args} { | |
450 | global names_chans nick_onchans | |
451 | if {[llength names_chans] > 1} { | |
452 | foreach n [array names nick_onchans] { | |
453 | upvar #0 nick_onchans($n) oc | |
454 | set oc [grep tc {[lsearch -exact $tc $names_chans] >= 0} $oc] | |
455 | if {![llength $oc]} { nick_forget $n } | |
456 | } | |
457 | } | |
458 | unset names_chans | |
459 | } | |
460 | ||
422f52e4 IJ |
461 | proc ta_nomore {} { |
462 | upvar 1 text text | |
463 | if {[string length $text]} { error "too many parameters" } | |
464 | } | |
465 | ||
466 | proc ta_word {} { | |
467 | upvar 1 text text | |
468 | if {![regexp {^([^ ]+) *(.*)} $text dummy firstword text]} { | |
469 | error "too few parameters" | |
470 | } | |
471 | return $firstword | |
472 | } | |
473 | ||
474 | proc ta_nick {} { | |
475 | upvar 1 text text | |
476 | set v [ta_word] | |
477 | check_nick $v | |
478 | return $v | |
479 | } | |
480 | ||
83dd1224 IJ |
481 | proc def_ucmd {cmdname body} { |
482 | proc ucmd/$cmdname {p dest} " upvar 1 text text\n$body" | |
483 | } | |
484 | ||
7ce72032 IJ |
485 | proc ucmdr {priv pub args} { |
486 | return -code return [concat [list $priv $pub] $args] | |
422f52e4 | 487 | } |
e1ba63be IJ |
488 | |
489 | proc ucmd_sendhelp {} { | |
422f52e4 IJ |
490 | ucmdr \ |
491 | {Commands currently understood: | |
e1ba63be IJ |
492 | help get this list of commands |
493 | seen <nick> ask after someone (I'll tell them you asked) | |
494 | summon <username> invite a logged-on user onto IRC | |
a056c4bd IJ |
495 | Send commands to me by /msg, or say them in channel with ! in front.} {} |
496 | # | |
497 | # register register your nick (you must auth[*] first) | |
498 | #[*]auth: /blight in ircII, or /msg blight authuser <username> <pass> | |
422f52e4 IJ |
499 | } |
500 | ||
e1ba63be IJ |
501 | def_ucmd help { ta_nomore; ucmd_sendhelp } |
502 | ||
503 | def_ucmd ? { ta_nomore; ucmd_sendhelp } | |
504 | ||
422f52e4 IJ |
505 | proc manyset {list args} { |
506 | foreach val $list var $args { | |
507 | upvar 1 $var my | |
508 | set my $val | |
509 | } | |
510 | } | |
511 | ||
7ce72032 IJ |
512 | def_ucmd summon { |
513 | set target [ta_word] | |
514 | ta_nomore | |
515 | if { | |
516 | [string length $target] > 8 || | |
517 | [regexp {[^-0-9a-z]} $target] || | |
518 | ![regexp {^[a-z]} $target] | |
519 | } { error "invalid username" } | |
520 | prefix_nick | |
521 | ||
522 | upvar #0 lastsummon($target) ls | |
523 | set now [clock seconds] | |
524 | if {[info exists ls]} { | |
525 | set interval [expr {$now - $ls}] | |
526 | if {$interval < 30} { | |
527 | ucmdr {} \ | |
528 | "Please be patient; $target was summoned only [showinterval $interval]." | |
529 | } | |
530 | } | |
531 | regsub {^[^!]*!} $p {} path | |
532 | if {[catch { | |
533 | exec userv --timeout 3 $target irc-summon $n $path \ | |
534 | [expr {[ischan $dest] ? "$dest" : ""}] \ | |
535 | < /dev/null | |
536 | } rv]} { | |
537 | regsub -all "\n" $rv { / } rv | |
538 | error $rv | |
539 | } | |
540 | if {[regexp {^problem (.*)} $rv dummy problem]} { | |
8a8d337d | 541 | ucmdr {} "The user `$target' $problem." |
7ce72032 IJ |
542 | } elseif {[regexp {^ok ([^ ]+) ([0-9]+)$} $rv dummy tty idlesince]} { |
543 | set idletime [expr {$now - $idlesince}] | |
544 | set ls $now | |
545 | ucmdr {} {} {} "invites $target ($tty[expr { | |
546 | $idletime > 10 ? ", idle for [showintervalsecs $idletime]" : "" | |
547 | }]) to [expr { | |
548 | [ischan $dest] ? "join us here" : "talk to you" | |
549 | }]." | |
550 | } else { | |
551 | error "unexpected response from userv service: $rv" | |
552 | } | |
553 | } | |
554 | ||
a69f7d2c IJ |
555 | proc md5sum {value} { exec md5sum << $value } |
556 | ||
83dd1224 | 557 | def_ucmd seen { |
422f52e4 | 558 | global lastseen nick |
83dd1224 IJ |
559 | prefix_nick |
560 | set ncase [ta_nick] | |
561 | set nlower [irctolower $ncase] | |
422f52e4 | 562 | ta_nomore |
83dd1224 IJ |
563 | set now [clock seconds] |
564 | if {"$nlower" == "[irctolower $nick]"} { | |
422f52e4 | 565 | error "I am not self-aware." |
83dd1224 IJ |
566 | } elseif {![info exists lastseen($nlower)]} { |
567 | set rstr "I've never seen $ncase." | |
422f52e4 | 568 | } else { |
83dd1224 IJ |
569 | manyset $lastseen($nlower) realnick time what |
570 | set howlong [expr {$now - $time}] | |
571 | set string [showinterval $howlong] | |
572 | set rstr "I last saw $realnick $string, $what." | |
573 | } | |
574 | if {[ischan $dest]} { | |
575 | set where $dest | |
576 | } else { | |
577 | set where {} | |
578 | } | |
579 | upvar #0 lookedfor($nlower) lf | |
580 | if {[info exists lf]} { set oldvalue $lf } else { set oldvalue {} } | |
581 | set lf [list [list $now $n $where]] | |
582 | foreach v $oldvalue { | |
583 | if {"[irctolower [lindex $v 1]]" == "[irctolower $n]"} continue | |
584 | lappend lf $v | |
cc2d31de | 585 | } |
83dd1224 | 586 | ucmdr {} $rstr |
cc2d31de IJ |
587 | } |
588 | ||
589 | if {![info exists sock]} { | |
590 | set sock [socket $host $port] | |
591 | fconfigure $sock -buffering line | |
592 | #fconfigure $sock -translation binary | |
593 | fconfigure $sock -translation crlf | |
594 | ||
b3d361ab | 595 | sendout USER blight 0 * $ownfullname |
cc2d31de IJ |
596 | sendout NICK $nick |
597 | fileevent $sock readable onread | |
598 | } | |
599 | ||
8979e0d6 IJ |
600 | #if {![regexp {tclsh} $argv0]} { |
601 | # vwait terminate | |
602 | #} |