Commit | Line | Data |
---|---|---|
281f2c0e IJ |
1 | # Actual IRC bot code |
2 | ||
3 | set helpfile helpinfos | |
9bc33297 | 4 | |
574abac6 | 5 | source irccore.tcl |
281f2c0e IJ |
6 | source parsecmd.tcl |
7 | source stdhelp.tcl | |
7818b6af | 8 | |
34c25cd7 IJ |
9 | defset marktime_min 300 |
10 | defset marktime_join_startdelay 5000 | |
11 | ||
281f2c0e IJ |
12 | proc privmsg_unlogged {prefix ischan params} { |
13 | if {!$ischan || | |
574abac6 | 14 | [regexp {^![a-z][-a-z]*[a-z]( .*)?$} [lindex $params 1]]} { |
281f2c0e | 15 | return 0 |
7818b6af | 16 | } |
574abac6 IJ |
17 | # on-channel message, ignore |
18 | set chan [lindex $params 0] | |
19 | upvar #0 chan_lastactivity([irctolower $chan]) la | |
20 | set la [clock seconds] | |
37a9f1ad | 21 | catch_logged { recordlastseen_p $prefix "talking on $chan" 2 } |
281f2c0e | 22 | return 1 |
422f52e4 IJ |
23 | } |
24 | ||
ef177383 IJ |
25 | proc showintervalsecs {howlong abbrev} { |
26 | return [showintervalsecs/[opt timeformat] $howlong $abbrev] | |
d83fb8db IJ |
27 | } |
28 | ||
49a4dc8f IJ |
29 | proc formatsf {pfx value} { |
30 | foreach {min format} { 100 %.0f 10 %.1f 0 %.2f} { | |
31 | set fval [format $format $value] | |
32 | if {$fval < $min} continue | |
33 | return [format "$fval${pfx}" $value] | |
34 | } | |
35 | } | |
36 | ||
37 | proc showintervalsecs/beat {howlong abbrev} { | |
38 | # We split in two to avoid overflow problems. | |
39 | if {$howlong < 86 } { | |
40 | # mB's | |
41 | set pfx mB | |
42 | return [format "%.0fmB" [expr {round($howlong * 1.157)*10} ]] | |
43 | } else { | |
44 | if {$howlong < 86400 } { | |
45 | # B's | |
46 | set pfx B | |
47 | set value [expr {$howlong / 86.4}] | |
48 | } else { | |
49 | # kB's | |
50 | set pfx kB | |
51 | set value [expr {$howlong / 86400.0}] | |
52 | } | |
53 | } | |
54 | return [formatsf $pfx $value] | |
55 | } | |
56 | ||
ef177383 | 57 | proc showintervalsecs/ks {howlong abbrev} { |
7ce72032 IJ |
58 | if {$howlong < 1000} { |
59 | return "${howlong}s" | |
83dd1224 IJ |
60 | } else { |
61 | if {$howlong < 1000000} { | |
49a4dc8f | 62 | set pfx ks |
83dd1224 IJ |
63 | set scale 1000 |
64 | } else { | |
49a4dc8f | 65 | set pfx Ms |
83dd1224 IJ |
66 | set scale 1000000 |
67 | } | |
68 | set value [expr "$howlong.0 / $scale"] | |
49a4dc8f | 69 | return [formatsf $pfx $value] |
83dd1224 IJ |
70 | } |
71 | } | |
72 | ||
ef177383 | 73 | proc format_qty {qty unit abbrev} { |
d83fb8db | 74 | set o $qty |
ef177383 IJ |
75 | if {$abbrev} { |
76 | append o [string range $unit 0 0] | |
77 | } else { | |
78 | append o " " | |
79 | append o $unit | |
80 | if {$qty != 1} { append o s } | |
81 | } | |
d83fb8db IJ |
82 | return $o |
83 | } | |
84 | ||
ef177383 | 85 | proc showintervalsecs/hms {qty abbrev} { |
d83fb8db IJ |
86 | set ul {second 60 minute 60 hour 24 day 7 week} |
87 | set remainv 0 | |
88 | while {[llength $ul] > 1 && $qty >= [set uv [lindex $ul 1]]} { | |
89 | set remainu [lindex $ul 0] | |
90 | set remainv [expr {$qty % $uv}] | |
91 | set qty [expr {($qty-$remainv)/$uv}] | |
92 | set ul [lreplace $ul 0 1] | |
93 | } | |
ef177383 | 94 | set o [format_qty $qty [lindex $ul 0] $abbrev] |
d83fb8db | 95 | if {$remainv} { |
ef177383 IJ |
96 | if {!$abbrev} { append o " " } |
97 | append o [format_qty $remainv $remainu $abbrev] | |
d83fb8db IJ |
98 | } |
99 | return $o | |
100 | } | |
101 | ||
7ce72032 IJ |
102 | proc showinterval {howlong} { |
103 | if {$howlong <= 0} { | |
104 | return {just now} | |
105 | } else { | |
ef177383 | 106 | return "[showintervalsecs $howlong 0] ago" |
7ce72032 IJ |
107 | } |
108 | } | |
109 | ||
83dd1224 IJ |
110 | proc showtime {when} { |
111 | return [showinterval [expr {[clock seconds] - $when}]] | |
112 | } | |
113 | ||
d7eda3bc IJ |
114 | proc parse_interval {specified min} { |
115 | if {![regexp {^([0-9]+)([a-z]+)$} $specified dummy value unit]} { | |
116 | error "invalid syntax for interval" | |
117 | } | |
118 | switch -exact $unit { | |
119 | s { set u 1 } | |
120 | ks { set u 1000 } | |
121 | m { set u 60 } | |
122 | h { set u 3600 } | |
49a4dc8f IJ |
123 | mb { set u 0.0864 } |
124 | b { set u 86.4 } | |
125 | kb { set u 86400 } | |
d7eda3bc IJ |
126 | default { error "unknown unit of time $unit" } |
127 | } | |
128 | if {$value > 86400*21/$u} { error "interval too large" } | |
49a4dc8f | 129 | set result [expr {round($value*$u)}] |
d7eda3bc IJ |
130 | if {$result < $min} { error "interval too small (<${min}s)" } |
131 | return $result | |
132 | } | |
133 | ||
83dd1224 IJ |
134 | proc def_msgproc {name argl body} { |
135 | proc msg_$name "varbase $argl" "\ | |
136 | upvar #0 msg/\$varbase/dest d\n\ | |
137 | upvar #0 msg/\$varbase/str s\n\ | |
138 | upvar #0 msg/\$varbase/accum a\n\ | |
139 | $body" | |
140 | } | |
141 | ||
142 | def_msgproc begin {dest str} { | |
143 | set d $dest | |
144 | set s $str | |
145 | set a {} | |
146 | } | |
147 | ||
148 | def_msgproc append {str} { | |
149 | set ns "$s$str" | |
150 | if {[string length $s] && [string length $ns] > 65} { | |
151 | msg__sendout $varbase | |
152 | set s " [string trimleft $str]" | |
153 | } else { | |
154 | set s $ns | |
155 | } | |
156 | } | |
157 | ||
158 | def_msgproc finish {} { | |
159 | msg__sendout $varbase | |
160 | unset s | |
161 | unset d | |
162 | return $a | |
163 | } | |
164 | ||
165 | def_msgproc _sendout {} { | |
166 | lappend a [string trimright $s] | |
167 | set s {} | |
168 | } | |
169 | ||
170 | proc looking_whenwhere {when where} { | |
171 | set str [showtime [expr {$when-1}]] | |
172 | if {[string length $where]} { append str " on $where" } | |
173 | return $str | |
174 | } | |
175 | ||
5d6d1db7 IJ |
176 | proc tell_getcstate {} { |
177 | # uses nl from caller's context | |
178 | # imports telling (as the nick_telling) and u | |
179 | # sets stt, telling_when | |
180 | uplevel 1 { | |
181 | upvar #0 nick_telling($nl) telling | |
182 | upvar #0 nick_unique($nl) u | |
183 | ||
184 | if {[info exists telling]} { | |
185 | manyset $telling u_last stt telling_when | |
186 | if {![info exists u] || "$u_last" != "$u"} { | |
187 | set stt undelivered | |
188 | } | |
189 | } else { | |
190 | set stt undelivered | |
191 | set telling_when 0 | |
192 | } | |
193 | } | |
194 | } | |
195 | ||
31eadeb5 | 196 | proc tell_event {nl event} { |
fdf998c1 IJ |
197 | # For `act' we *haven't* yet done the 750ms delay; we implement |
198 | # that here. Also, here we turn `talk' into `talk' now and `act' | |
199 | # later. We also support the psuedo-event `none'. The del msg | |
200 | # and new msg events are handled by the command procedures, not here. | |
268336f8 | 201 | global calling_nick |
156725c8 | 202 | if {[info exists calling_nick]} { set save $calling_nick } |
5d6d1db7 | 203 | set r DELAYED |
b0a2d58f | 204 | switch -exact $event { |
fdf998c1 | 205 | none { } |
b0a2d58f | 206 | talk { |
31eadeb5 IJ |
207 | tell_event_core $nl talk |
208 | tell_event $nl act | |
b0a2d58f | 209 | } |
09c94f5b | 210 | act { |
31eadeb5 | 211 | after 750 [list tell_event_core $nl $event] |
fdf998c1 | 212 | } |
52c775e8 | 213 | ident - msgsarrive { |
31eadeb5 | 214 | tell_event_core $nl $event |
b0a2d58f | 215 | } |
5d6d1db7 IJ |
216 | tellme { |
217 | set r [tell_event_core $nl TELLME] | |
218 | } | |
b0a2d58f | 219 | default { |
31eadeb5 | 220 | error "tell_event $nl $event" |
b0a2d58f IJ |
221 | } |
222 | } | |
268336f8 | 223 | if {[info exists save]} { set calling_nick $save } |
5d6d1db7 | 224 | return $r |
52c775e8 IJ |
225 | } |
226 | ||
31eadeb5 | 227 | proc tell_event_core {nl event} { |
5d6d1db7 IJ |
228 | global tell_event_teventi errorInfo |
229 | set tell_event_teventi "*$event* $nl" | |
230 | if {[catch { | |
231 | tell_event_core1 $nl $event | |
232 | } emsg]} { | |
233 | log_intern "tell event error" "$emsg >$errorInfo<" | |
234 | set emsg ERROR | |
235 | } else { | |
df376445 IJ |
236 | if {"$emsg" != "nomsgs"} { |
237 | log_intern "tell event" "done $tell_event_teventi $emsg" | |
238 | } | |
5d6d1db7 IJ |
239 | } |
240 | return $emsg | |
ed982e50 IJ |
241 | } |
242 | ||
243 | proc tell_event_core1 {nl event} { | |
5d6d1db7 | 244 | # event is `talk', `act', `ident', `msgsarrive' or `TELLME' |
b0a2d58f | 245 | # When user talks we actually get talk now and act later |
268336f8 IJ |
246 | global calling_nick |
247 | set calling_nick $nl | |
156725c8 | 248 | set iml [msgsdb_get $nl inbound] |
5d6d1db7 | 249 | if {![llength $iml]} { return nomsgs } |
37a9f1ad | 250 | |
ed982e50 IJ |
251 | set now [clock seconds] |
252 | tell_getcstate | |
37a9f1ad IJ |
253 | set ago [expr {$now - $telling_when}] |
254 | ||
fdf998c1 | 255 | # Now we have the components of a telling state |
c7430bf9 | 256 | # u - nick_unique (unset if not visible) |
5d6d1db7 | 257 | # stt - state: undelivered, mentioned, passede |
fdf998c1 IJ |
258 | # ago - how long ago since we did anything |
259 | ||
260 | # We compute an evstate to dispatch on as follows: | |
261 | ||
37a9f1ad | 262 | # evstate is string of letters |
fdf998c1 | 263 | # current state |
5d6d1db7 | 264 | # u UNDELIVERED (MESSAGES) |
fdf998c1 IJ |
265 | # m MENTIONED |
266 | # p PASSED | |
37a9f1ad IJ |
267 | # event |
268 | # t talk | |
269 | # a act | |
fdf998c1 | 270 | # i ident |
52c775e8 | 271 | # m msgsarrive |
5d6d1db7 | 272 | # T tellme (user command) |
37a9f1ad IJ |
273 | # security level and timing |
274 | # ii Insecure | |
275 | # ss Secure and soon (before interval) | |
276 | # sl Secure and late (after interval) | |
fdf998c1 IJ |
277 | # current identification |
278 | # i Identified | |
279 | # u Unidentified | |
37a9f1ad IJ |
280 | # reliability and timing |
281 | # uu Unreliable | |
282 | # rv Remind, very soon (before within-interval) | |
283 | # rs Remind, soon (between) | |
fdf998c1 | 284 | # rl Remind, late (after every-interval) |
37a9f1ad IJ |
285 | # ps Pester, soon (before interval) |
286 | # pl Pester, late (after interval) | |
fdf998c1 IJ |
287 | |
288 | set evstate {} | |
289 | ||
290 | append evstate [string range $stt 0 0] | |
291 | append evstate [string range $event 0 0] | |
37a9f1ad | 292 | |
6cc2e28a | 293 | manyset [nickdb_get_sec_effective $nl] sec secwhen |
37a9f1ad | 294 | switch -exact $sec { |
fdf998c1 | 295 | insecure { append evstate ii } |
5d6d1db7 | 296 | secure { append evstate [expr {$ago<$secwhen ? "ss" : "sl"}] } |
fdf998c1 | 297 | default { append evstate "#$sec#" } |
37a9f1ad IJ |
298 | } |
299 | ||
fdf998c1 | 300 | upvar #0 nick_username($nl) nu |
6cc2e28a | 301 | if {[info exists nu] && "$nu" == "[nickdb_get_username $nl]"} { |
fdf998c1 IJ |
302 | append evstate i |
303 | } else { | |
304 | append evstate u | |
305 | } | |
e06683f2 | 306 | |
ed982e50 | 307 | manyset [nickdb_get $nl tellrel] rel relint relwithin |
37a9f1ad IJ |
308 | switch -exact $rel { |
309 | unreliable { append evstate uu } | |
310 | remind { append evstate [expr { | |
311 | $ago<$relwithin ? "rv" : $ago<$relint ? "rs" : "rl" | |
312 | }]} | |
313 | pester { append evstate [expr {$ago<$relint ? "ps" : "pl"}] } | |
314 | default { append evstate "#$rel#" } | |
315 | } | |
316 | ||
5d6d1db7 IJ |
317 | global tell_event_teventi |
318 | set tell_event_teventi "$evstate $ago $nl" | |
37a9f1ad | 319 | switch -glob $evstate { |
fdf998c1 | 320 | pt???rv { |
e06683f2 IJ |
321 | # consider delivered: |
322 | # (very recently passed, and the user talks) | |
0abaa3a9 IJ |
323 | set ndel [tell_delete_msgs {} $nl] |
324 | sendprivmsg $nl \ | |
325 | "I'm assuming you got the $ndel message(s) I just passed on." | |
5d6d1db7 | 326 | return delivered |
e06683f2 | 327 | } |
52c775e8 IJ |
328 | pm????? { |
329 | # oops, messages passed are now out of date | |
ed982e50 | 330 | catch_restoreei { unset telling } |
5d6d1db7 | 331 | return reset |
52c775e8 IJ |
332 | } |
333 | ?m????? { | |
334 | # ignore new msgs if we haven't passed yet | |
5d6d1db7 | 335 | return ignorenew |
52c775e8 | 336 | } |
5d6d1db7 | 337 | ut????? - mt????? - |
c7430bf9 | 338 | pt???uu - pt???rs - pt???rl - pt???p? { |
fdf998c1 | 339 | # ignore (any other `talk's) - act handles these |
5d6d1db7 | 340 | return ignoretalk |
fdf998c1 | 341 | } |
5d6d1db7 | 342 | ui????? - |
0abaa3a9 | 343 | uaii?uu - uaii??l - uas?iuu - uas?i?l - |
5d6d1db7 IJ |
344 | mi????? - pa????l - |
345 | ?Tii??? - ?Ts?i?? { | |
c7430bf9 | 346 | # pass and then stuff |
6cc2e28a | 347 | if {[llength $iml] == 3} { |
268336f8 IJ |
348 | manyset $iml sender sentwhen msg |
349 | sendprivmsg $nl \ | |
c99281b8 | 350 | "$sender asked me, [showinterval [expr {$now-$sentwhen}]],\ |
268336f8 IJ |
351 | to tell you: $msg" |
352 | } else { | |
353 | sendprivmsg $nl \ | |
5d6d1db7 | 354 | "I have [expr {[llength $iml]/3}] messages for you:" |
268336f8 IJ |
355 | while {[llength $iml] >= 3} { |
356 | manyset [lrange $iml 0 2] sender sentwhen msg | |
357 | set iml [lrange $iml 3 end] | |
358 | sendprivmsg $nl \ | |
359 | " [showintervalsecs [expr {$now-$sentwhen}] 1] <$sender> $msg" | |
360 | } | |
361 | } | |
362 | if {"$rel" == "unreliable"} { | |
363 | tell_delete_msgs {} $nl | |
5d6d1db7 | 364 | return toldunreliable |
268336f8 IJ |
365 | } |
366 | set stt passed | |
5d6d1db7 | 367 | set re passed |
e06683f2 | 368 | } |
5d6d1db7 | 369 | uaslu?? { |
ed982e50 | 370 | sendprivmsg $nl {You have messages (so identify yourself please).} |
c7430bf9 | 371 | set stt mentioned |
5d6d1db7 IJ |
372 | set re mentioned |
373 | } | |
374 | ?Ts?u?? { | |
375 | sendprivmsg $nl {You must identify yourself to see your messages.} | |
376 | return ignoreuitm | |
fdf998c1 | 377 | } |
c7430bf9 | 378 | masl??? { |
ed982e50 | 379 | sendprivmsg $nl {Don't forget about your messages.} |
5d6d1db7 | 380 | return remind |
e06683f2 | 381 | } |
c7430bf9 | 382 | pi????? { |
5d6d1db7 | 383 | return ignorepi |
e06683f2 | 384 | } |
5d6d1db7 IJ |
385 | mass??? - pa????v - pa????s - |
386 | uaii??v - uaii??s - | |
387 | uas?i?v - uas?i?s - | |
388 | uassu?? { | |
c7430bf9 | 389 | # too soon |
5d6d1db7 | 390 | return ignoresoon |
e06683f2 IJ |
391 | } |
392 | * { | |
31eadeb5 | 393 | error "tell_event_core nl=$nl evstate=$evstate ?" |
e06683f2 IJ |
394 | } |
395 | } | |
c7430bf9 | 396 | if {![info exists u]} { |
5d6d1db7 | 397 | set telling [list {} undelivered $now] |
c7430bf9 IJ |
398 | } else { |
399 | set telling [list $u $stt $now] | |
400 | } | |
5d6d1db7 | 401 | return $re |
e06683f2 IJ |
402 | } |
403 | ||
83dd1224 | 404 | proc recordlastseen_n {n how here} { |
52c775e8 IJ |
405 | # here is: |
406 | # 0 - nick was seen leaving (or changing to another nicks or some such) | |
407 | # 1 - nick was seen doing something else | |
408 | # 2 - nick was seen talking on channel | |
83dd1224 | 409 | global lastseen lookedfor |
37a9f1ad IJ |
410 | set nl [irctolower $n] |
411 | set now [clock seconds] | |
412 | set lastseen($nl) [list $n $now $how] | |
413 | ||
83dd1224 | 414 | if {!$here} return |
37a9f1ad | 415 | |
31eadeb5 | 416 | tell_event $nl [lindex {none act talk} $here] |
37a9f1ad IJ |
417 | |
418 | upvar #0 lookedfor($nl) lf | |
83dd1224 IJ |
419 | if {[info exists lf]} { |
420 | switch -exact [llength $lf] { | |
421 | 0 { | |
422 | set ml {} | |
423 | } | |
424 | 1 { | |
425 | manyset [lindex $lf 0] when who where | |
426 | set ml [list \ | |
427 | "FYI, $who was looking for you [looking_whenwhere $when $where]."] | |
428 | } | |
429 | default { | |
430 | msg_begin tosend $n "FYI, people have been looking for you:" | |
431 | set i 0 | |
432 | set fin "" | |
433 | foreach e $lf { | |
434 | incr i | |
435 | if {$i == 1} { | |
436 | msg_append tosend " " | |
437 | } elseif {$i == [llength $lf]} { | |
438 | msg_append tosend " and " | |
439 | set fin . | |
440 | } else { | |
441 | msg_append tosend ", " | |
442 | } | |
443 | manyset $e when who where | |
444 | msg_append tosend \ | |
445 | "$who ([looking_whenwhere $when $where])$fin" | |
446 | } | |
447 | set ml [msg_finish tosend] | |
448 | } | |
449 | } | |
450 | unset lf | |
451 | msendprivmsg_delayed 1000 $n $ml | |
452 | } | |
422f52e4 | 453 | } |
281b5f05 IJ |
454 | |
455 | proc note_topic {showoff whoby topic} { | |
35e19219 | 456 | set msg "FYI, $whoby has changed the topic on $showoff" |
281b5f05 IJ |
457 | if {[string length $topic] < 160} { |
458 | append msg " to $topic" | |
459 | } else { | |
460 | append msg " but it is too long to reproduce here !" | |
461 | } | |
462 | set showoff [irctolower $showoff] | |
463 | set tell [chandb_get $showoff topictell] | |
464 | if {[lsearch -exact $tell *] >= 0} { | |
465 | set tryspies [chandb_list] | |
466 | } else { | |
467 | set tryspies $tell | |
468 | } | |
281b5f05 IJ |
469 | foreach spy $tryspies { |
470 | set see [chandb_get $spy topicsee] | |
281b5f05 IJ |
471 | if {[lsearch -exact $see $showoff] >= 0 || \ |
472 | ([lsearch -exact $see *] >= 0 && \ | |
473 | [lsearch -exact $tell $spy] >= 0)} { | |
474 | sendprivmsg $spy $msg | |
475 | } | |
476 | } | |
477 | } | |
478 | ||
83dd1224 | 479 | proc recordlastseen_p {p how here} { |
422f52e4 | 480 | prefix_nick |
83dd1224 | 481 | recordlastseen_n $n $how $here |
422f52e4 IJ |
482 | } |
483 | ||
484 | proc chanmode_arg {} { | |
485 | upvar 2 args cm_args | |
486 | set rv [lindex $cm_args 0] | |
487 | set cm_args [lreplace cm_args 0 0] | |
488 | return $rv | |
489 | } | |
490 | ||
83dd1224 | 491 | proc chanmode_o1 {m g p chan} { |
20087363 | 492 | global nick chan_initialop |
83dd1224 IJ |
493 | prefix_nick |
494 | set who [chanmode_arg] | |
495 | recordlastseen_n $n "being nice to $who" 1 | |
496 | if {"[irctolower $who]" == "[irctolower $nick]"} { | |
534e26a9 IJ |
497 | set nlower [irctolower $n] |
498 | upvar #0 nick_unique($nlower) u | |
20087363 IJ |
499 | if {[chandb_exists $chan]} { |
500 | sendprivmsg $n Thanks. | |
501 | } elseif {![info exists u]} { | |
502 | sendprivmsg $n {Op me while not on the channel, why don't you ?} | |
503 | } else { | |
504 | set chan_initialop([irctolower $chan]) $u | |
505 | sendprivmsg $n \ | |
26477e22 | 506 | "Thanks. You can use `channel manager ...' to register this channel." |
6cc2e28a | 507 | if {![string length [nickdb_get_username $n username]]} { |
20087363 IJ |
508 | sendprivmsg $n \ |
509 | "(But to do that you must register your nick securely first.)" | |
510 | } | |
511 | } | |
83dd1224 IJ |
512 | } |
513 | } | |
514 | ||
422f52e4 IJ |
515 | proc chanmode_o0 {m g p chan} { |
516 | global nick chandeop | |
517 | prefix_nick | |
518 | set who [chanmode_arg] | |
83dd1224 | 519 | recordlastseen_p $p "being mean to $who" 1 |
422f52e4 IJ |
520 | if {"[irctolower $who]" == "[irctolower $nick]"} { |
521 | set chandeop($chan) [list [clock seconds] $p] | |
522 | } | |
cc2d31de | 523 | } |
9bc33297 | 524 | |
422f52e4 IJ |
525 | proc msg_MODE {p c dest modelist args} { |
526 | if {![ischan $dest]} return | |
527 | if {[regexp {^\-(.+)$} $modelist dummy modelist]} { | |
528 | set give 0 | |
529 | } elseif {[regexp {^\+(.+)$} $modelist dummy modelist]} { | |
530 | set give 1 | |
531 | } else { | |
532 | error "invalid modelist" | |
533 | } | |
534 | foreach m [split $modelist] { | |
535 | set procname chanmode_$m$give | |
536 | if {[catch { info body $procname }]} { | |
83dd1224 | 537 | recordlastseen_p $p "fiddling with $dest" 1 |
422f52e4 IJ |
538 | } else { |
539 | $procname $m $give $p $dest | |
540 | } | |
541 | } | |
542 | } | |
543 | ||
534e26a9 IJ |
544 | proc leaving {lchan} { |
545 | foreach luser [array names nick_onchans] { | |
546 | upvar #0 nick_onchans($luser) oc | |
547 | set oc [grep tc {"$tc" != "$lchan"} $oc] | |
548 | } | |
549 | upvar #0 chan_nicks($lchan) nlist | |
550 | unset nlist | |
ebbae0a9 IJ |
551 | upvar #0 chan_lastactivity($lchan) la |
552 | catch { unset la } | |
534e26a9 IJ |
553 | } |
554 | ||
cf6ea4de IJ |
555 | proc doleave {lchan} { |
556 | sendout PART $lchan | |
557 | leaving $lchan | |
558 | } | |
559 | ||
534e26a9 IJ |
560 | proc dojoin {lchan} { |
561 | global chan_nicks | |
562 | sendout JOIN $lchan | |
563 | set chan_nicks($lchan) {} | |
564 | } | |
565 | ||
566 | proc check_justme {lchan} { | |
567 | global nick | |
568 | upvar #0 chan_nicks($lchan) nlist | |
569 | if {[llength $nlist] != 1} return | |
e2af9bcb | 570 | if {"[lindex $nlist 0]" != "[irctolower $nick]"} return |
534e26a9 IJ |
571 | if {[chandb_exists $lchan]} { |
572 | set mode [chandb_get $lchan mode] | |
573 | if {"$mode" != "*"} { | |
574 | sendout MODE $lchan $mode | |
575 | } | |
281b5f05 IJ |
576 | set topic [chandb_get $lchan topicset] |
577 | if {[string length $topic]} { | |
578 | sendout TOPIC $lchan $topic | |
281b5f05 | 579 | } |
534e26a9 | 580 | } else { |
cf6ea4de | 581 | doleave $lchan |
a4a1f396 IJ |
582 | } |
583 | } | |
584 | ||
a056c4bd | 585 | proc process_kickpart {chan user} { |
a4a1f396 | 586 | global nick |
a056c4bd | 587 | check_nick $user |
534e26a9 IJ |
588 | set luser [irctolower $user] |
589 | set lchan [irctolower $chan] | |
a056c4bd | 590 | if {![ischan $chan]} { error "not a channel" } |
534e26a9 IJ |
591 | if {"$luser" == "[irctolower $nick]"} { |
592 | leaving $lchan | |
593 | } else { | |
594 | upvar #0 nick_onchans($luser) oc | |
595 | upvar #0 chan_nicks($lchan) nlist | |
596 | set oc [grep tc {"$tc" != "$lchan"} $oc] | |
597 | set nlist [grep tn {"$tn" != "$luser"} $nlist] | |
598 | nick_case $user | |
599 | if {![llength $oc]} { | |
600 | nick_forget $luser | |
601 | } else { | |
602 | check_justme $lchan | |
603 | } | |
a4a1f396 | 604 | } |
534e26a9 | 605 | } |
a056c4bd | 606 | |
281b5f05 IJ |
607 | proc msg_TOPIC {p c dest topic} { |
608 | prefix_nick | |
609 | if {![ischan $dest]} return | |
610 | recordlastseen_n $n "changing the topic on $dest" 1 | |
611 | note_topic [irctolower $dest] $n $topic | |
612 | } | |
613 | ||
a056c4bd IJ |
614 | proc msg_KICK {p c chans users comment} { |
615 | set chans [split $chans ,] | |
616 | set users [split $users ,] | |
617 | if {[llength $chans] > 1} { | |
618 | foreach chan $chans user $users { process_kickpart $chan $user } | |
619 | } else { | |
620 | foreach user $users { process_kickpart [lindex $chans 0] $user } | |
621 | } | |
622 | } | |
623 | ||
624 | proc msg_KILL {p c user why} { | |
625 | nick_forget $user | |
626 | } | |
627 | ||
20087363 IJ |
628 | set nick_counter 0 |
629 | set nick_arys {onchans username unique} | |
534e26a9 IJ |
630 | # nick_onchans($luser) -> [list ... $lchan ...] |
631 | # nick_username($luser) -> <securely known local username> | |
37a9f1ad | 632 | # nick_unique($luser) -> <includes-counter> |
534e26a9 | 633 | # nick_case($luser) -> $user (valid even if no longer visible) |
ebbae0a9 | 634 | # nick_markid($luser) -> <after id for marktime> |
37a9f1ad | 635 | # nick_telling($luser) -> <unique> mentioned|passed <when> |
534e26a9 IJ |
636 | |
637 | # chan_nicks($lchan) -> [list ... $luser ...] | |
ebbae0a9 | 638 | # chan_lastactivity($lchan) -> [clock seconds] |
a056c4bd | 639 | |
534e26a9 IJ |
640 | proc lnick_forget {luser} { |
641 | global nick_arys chan_nicks | |
ebbae0a9 | 642 | lnick_marktime_cancel $luser |
a056c4bd | 643 | foreach ary $nick_arys { |
534e26a9 | 644 | upvar #0 nick_${ary}($luser) av |
a056c4bd IJ |
645 | catch { unset av } |
646 | } | |
534e26a9 IJ |
647 | foreach lch [array names chan_nicks] { |
648 | upvar #0 chan_nicks($lch) nlist | |
649 | set nlist [grep tn {"$tn" != "$luser"} $nlist] | |
650 | check_justme $lch | |
651 | } | |
652 | } | |
653 | ||
654 | proc nick_forget {user} { | |
655 | global nick_arys chan_nicks | |
656 | lnick_forget [irctolower $user] | |
657 | nick_case $user | |
a4a1f396 IJ |
658 | } |
659 | ||
534e26a9 | 660 | proc nick_case {user} { |
a4a1f396 | 661 | global nick_case |
534e26a9 | 662 | set nick_case([irctolower $user]) $user |
a056c4bd IJ |
663 | } |
664 | ||
83dd1224 | 665 | proc msg_NICK {p c newnick} { |
a44d4982 | 666 | global nick_arys nick_case calling_nick |
83dd1224 IJ |
667 | prefix_nick |
668 | recordlastseen_n $n "changing nicks to $newnick" 0 | |
a44d4982 | 669 | set calling_nick $newnick |
83dd1224 | 670 | recordlastseen_n $newnick "changing nicks from $n" 1 |
6425c2d6 | 671 | set luser [irctolower $n] |
ebbae0a9 | 672 | lnick_marktime_cancel $luser |
6425c2d6 | 673 | set lusernew [irctolower $newnick] |
a056c4bd | 674 | foreach ary $nick_arys { |
6425c2d6 IJ |
675 | upvar #0 nick_${ary}($luser) old |
676 | upvar #0 nick_${ary}($lusernew) new | |
a056c4bd IJ |
677 | if {[info exists new]} { error "nick collision ?! $ary $n $newnick" } |
678 | if {[info exists old]} { set new $old; unset old } | |
679 | } | |
6425c2d6 | 680 | upvar #0 nick_onchans($lusernew) oc |
534e26a9 IJ |
681 | foreach ch $oc { |
682 | upvar #0 chan_nicks($ch) nlist | |
683 | set nlist [grep tn {"$tn" != "$luser"} $nlist] | |
684 | lappend nlist $lusernew | |
685 | } | |
34c25cd7 | 686 | lnick_marktime_start $lusernew "Hi." 500 1 |
a4a1f396 | 687 | nick_case $newnick |
83dd1224 IJ |
688 | } |
689 | ||
20087363 IJ |
690 | proc nick_ishere {n} { |
691 | global nick_counter | |
534e26a9 | 692 | upvar #0 nick_unique([irctolower $n]) u |
20087363 IJ |
693 | if {![info exists u]} { set u [incr nick_counter].$n.[clock seconds] } |
694 | nick_case $n | |
695 | } | |
696 | ||
a056c4bd IJ |
697 | proc msg_JOIN {p c chan} { |
698 | prefix_nick | |
37a9f1ad | 699 | nick_ishere $n |
a056c4bd | 700 | recordlastseen_n $n "joining $chan" 1 |
cf6ea4de IJ |
701 | set nl [irctolower $n] |
702 | set lchan [irctolower $chan] | |
703 | upvar #0 nick_onchans($nl) oc | |
704 | upvar #0 chan_nicks($lchan) nlist | |
ebbae0a9 IJ |
705 | if {![info exists oc]} { |
706 | global marktime_join_startdelay | |
34c25cd7 | 707 | lnick_marktime_start $nl "Welcome." $marktime_join_startdelay 1 |
ebbae0a9 | 708 | } |
cf6ea4de IJ |
709 | lappend oc $lchan |
710 | lappend nlist $nl | |
a056c4bd | 711 | } |
ea8a1bfe | 712 | proc msg_PART {p c chan args} { |
a056c4bd | 713 | prefix_nick |
ea8a1bfe IJ |
714 | set msg "leaving $chan" |
715 | if {[llength $args]} { | |
716 | set why [lindex $args 0] | |
717 | if {"[irctolower $why]" != "[irctolower $n]"} { append msg " ($why)" } | |
718 | } | |
719 | recordlastseen_n $n $msg 1 | |
a056c4bd IJ |
720 | process_kickpart $chan $n |
721 | } | |
722 | proc msg_QUIT {p c why} { | |
723 | prefix_nick | |
724 | recordlastseen_n $n "leaving ($why)" 0 | |
725 | nick_forget $n | |
726 | } | |
422f52e4 | 727 | |
cc2d31de | 728 | proc msg_PRIVMSG {p c dest text} { |
a01859b6 IJ |
729 | global errorCode |
730 | ||
cc2d31de | 731 | prefix_nick |
422f52e4 | 732 | if {[ischan $dest]} { |
83dd1224 | 733 | recordlastseen_n $n "invoking me in $dest" 1 |
422f52e4 | 734 | set output $dest |
cc2d31de | 735 | } else { |
83dd1224 | 736 | recordlastseen_n $n "talking to me" 1 |
422f52e4 IJ |
737 | set output $n |
738 | } | |
a4a1f396 | 739 | nick_case $n |
422f52e4 | 740 | |
281f2c0e | 741 | execute_usercommand $p $c $n $output $dest $text |
422f52e4 IJ |
742 | } |
743 | ||
a056c4bd | 744 | proc msg_INVITE {p c n chan} { |
534e26a9 | 745 | after 1000 [list dojoin [irctolower $chan]] |
a056c4bd IJ |
746 | } |
747 | ||
748 | proc grep {var predicate list} { | |
749 | set o {} | |
750 | upvar 1 $var v | |
751 | foreach v $list { | |
752 | if {[uplevel 1 [list expr $predicate]]} { lappend o $v } | |
753 | } | |
754 | return $o | |
755 | } | |
756 | ||
757 | proc msg_353 {p c dest type chan nicklist} { | |
758 | global names_chans nick_onchans | |
534e26a9 IJ |
759 | set lchan [irctolower $chan] |
760 | upvar #0 chan_nicks($lchan) nlist | |
761 | lappend names_chans $lchan | |
762 | if {![info exists nlist]} { | |
763 | # We don't think we're on this channel, so ignore it ! | |
764 | # Unfortunately, because we don't get a reply to PART, | |
765 | # we have to remember ourselves whether we're on a channel, | |
766 | # and ignore stuff if we're not, to avoid races. Feh. | |
767 | return | |
768 | } | |
769 | set nlist_new {} | |
770 | foreach user [split $nicklist { }] { | |
771 | regsub {^[@+]} $user {} user | |
772 | if {![string length $user]} continue | |
773 | check_nick $user | |
774 | set luser [irctolower $user] | |
775 | upvar #0 nick_onchans($luser) oc | |
776 | lappend oc $lchan | |
777 | lappend nlist_new $luser | |
778 | nick_ishere $user | |
a056c4bd | 779 | } |
534e26a9 | 780 | set nlist $nlist_new |
a056c4bd IJ |
781 | } |
782 | ||
783 | proc msg_366 {p c args} { | |
784 | global names_chans nick_onchans | |
534e26a9 IJ |
785 | set lchan [irctolower $c] |
786 | foreach luser [array names nick_onchans] { | |
787 | upvar #0 nick_onchans($luser) oc | |
788 | if {[llength names_chans] > 1} { | |
a056c4bd | 789 | set oc [grep tc {[lsearch -exact $tc $names_chans] >= 0} $oc] |
a056c4bd | 790 | } |
534e26a9 | 791 | if {![llength $oc]} { lnick_forget $n } |
a056c4bd IJ |
792 | } |
793 | unset names_chans | |
794 | } | |
795 | ||
4fd2739c | 796 | proc check_username {target} { |
7ce72032 IJ |
797 | if { |
798 | [string length $target] > 8 || | |
799 | [regexp {[^-0-9a-z]} $target] || | |
800 | ![regexp {^[a-z]} $target] | |
801 | } { error "invalid username" } | |
4fd2739c IJ |
802 | } |
803 | ||
20087363 | 804 | proc somedb__head {} { |
7a70431a | 805 | uplevel 1 { |
20087363 IJ |
806 | set idl [irctolower $id] |
807 | upvar #0 ${nickchan}db($idl) ndbe | |
808 | binary scan $idl H* idh | |
809 | set idfn $fprefix$idh | |
810 | if {![info exists iddbe] && [file exists $idfn]} { | |
811 | set f [open $idfn r] | |
7a70431a IJ |
812 | try_except_finally { set newval [read $f] } {} { close $f } |
813 | if {[llength $newval] % 2} { error "invalid length" } | |
20087363 | 814 | set iddbe $newval |
7a70431a IJ |
815 | } |
816 | } | |
817 | } | |
818 | ||
20087363 | 819 | proc def_somedb {name arglist body} { |
d7eda3bc IJ |
820 | foreach {nickchan fprefix} { |
821 | nick users/n | |
822 | chan chans/c | |
823 | msgs users/m | |
824 | } { | |
20087363 | 825 | proc ${nickchan}db_$name $arglist \ |
534e26a9 IJ |
826 | "set nickchan $nickchan; set fprefix $fprefix; $body" |
827 | } | |
828 | } | |
829 | ||
830 | def_somedb list {} { | |
831 | set list {} | |
832 | foreach path [glob -nocomplain -path $fprefix *] { | |
833 | binary scan $path "A[string length $fprefix]A*" afprefix thinghex | |
834 | if {"$afprefix" != "$fprefix"} { error "wrong prefix $path $afprefix" } | |
835 | lappend list [binary format H* $thinghex] | |
20087363 | 836 | } |
534e26a9 IJ |
837 | return $list |
838 | } | |
839 | ||
840 | proc def_somedb_id {name arglist body} { | |
841 | def_somedb $name [concat id $arglist] "somedb__head; $body" | |
7a70431a IJ |
842 | } |
843 | ||
534e26a9 | 844 | def_somedb_id exists {} { |
20087363 | 845 | return [info exists iddbe] |
7a70431a IJ |
846 | } |
847 | ||
534e26a9 | 848 | def_somedb_id delete {} { |
20087363 IJ |
849 | catch { unset iddbe } |
850 | file delete $idfn | |
7a70431a IJ |
851 | } |
852 | ||
d7eda3bc IJ |
853 | set default_settings_nick { |
854 | timeformat ks | |
855 | marktime off | |
26477e22 | 856 | tellsec {secure 600} |
d7eda3bc IJ |
857 | tellrel {remind 3600 30} |
858 | } | |
859 | ||
281b5f05 IJ |
860 | set default_settings_chan { |
861 | autojoin 1 | |
862 | mode * | |
863 | userinvite pub | |
864 | topicset {} | |
865 | topicsee {} | |
866 | topictell {} | |
867 | } | |
7a70431a | 868 | |
d7eda3bc IJ |
869 | set default_settings_msgs { |
870 | inbound {} | |
871 | outbound {} | |
872 | } | |
873 | # inbound -> [<nick> <time_t> <message>] ... | |
874 | # outbound -> [<nick> <time_t(earliest)> <count>] ... | |
268336f8 IJ |
875 | # neither are sorted particularly; only one entry per recipient in |
876 | # output; both sender and recipient are cased | |
d7eda3bc | 877 | |
534e26a9 | 878 | def_somedb_id set {args} { |
20087363 IJ |
879 | upvar #0 default_settings_$nickchan def |
880 | if {![info exists iddbe]} { set iddbe $def } | |
881 | foreach {key value} [concat $iddbe $args] { set a($key) $value } | |
7a70431a IJ |
882 | set newval {} |
883 | foreach {key value} [array get a] { lappend newval $key $value } | |
20087363 | 884 | set f [open $idfn.new w] |
7a70431a IJ |
885 | try_except_finally { |
886 | puts $f $newval | |
887 | close $f | |
20087363 | 888 | file rename -force $idfn.new $idfn |
7a70431a | 889 | } { |
7a70431a | 890 | } { |
d83fb8db | 891 | catch { close $f } |
7a70431a | 892 | } |
20087363 | 893 | set iddbe $newval |
7a70431a IJ |
894 | } |
895 | ||
534e26a9 | 896 | def_somedb_id get {key} { |
20087363 IJ |
897 | upvar #0 default_settings_$nickchan def |
898 | if {[info exists iddbe]} { | |
534e26a9 | 899 | set l [concat $iddbe $def] |
7a70431a | 900 | } else { |
20087363 | 901 | set l $def |
7a70431a IJ |
902 | } |
903 | foreach {tkey value} $l { | |
904 | if {"$tkey" == "$key"} { return $value } | |
905 | } | |
906 | error "unset setting $key" | |
907 | } | |
908 | ||
20087363 IJ |
909 | proc opt {key} { |
910 | global calling_nick | |
911 | if {[info exists calling_nick]} { set n $calling_nick } { set n {} } | |
912 | return [nickdb_get $n $key] | |
913 | } | |
914 | ||
7a70431a IJ |
915 | proc check_notonchan {} { |
916 | upvar 1 dest dest | |
a01859b6 | 917 | if {[ischan $dest]} { usererror "That command must be sent privately." } |
7a70431a IJ |
918 | } |
919 | ||
920 | proc nick_securitycheck {strict} { | |
921 | upvar 1 n n | |
a01859b6 IJ |
922 | if {![nickdb_exists $n]} { |
923 | usererror "You are unknown to me, use `register'." | |
924 | } | |
20087363 | 925 | set wantu [nickdb_get $n username] |
7a70431a IJ |
926 | if {![string length $wantu]} { |
927 | if {$strict} { | |
a01859b6 | 928 | usererror "That feature is only available to secure users, sorry." |
7a70431a IJ |
929 | } else { |
930 | return | |
931 | } | |
932 | } | |
534e26a9 IJ |
933 | set luser [irctolower $n] |
934 | upvar #0 nick_username($luser) nu | |
7a70431a | 935 | if {![info exists nu]} { |
a01859b6 | 936 | usererror "Nick $n is secure, you must identify yourself first." |
7a70431a IJ |
937 | } |
938 | if {"$wantu" != "$nu"} { | |
a01859b6 IJ |
939 | usererror "You are the wrong user -\ |
940 | the nick $n belongs to $wantu, not $nu." | |
7a70431a IJ |
941 | } |
942 | } | |
943 | ||
a01859b6 | 944 | proc channel_ismanager {channel n} { |
c362e172 | 945 | set mgrs [chandb_get $channel managers] |
a01859b6 IJ |
946 | return [expr {[lsearch -exact [irctolower $mgrs] [irctolower $n]] >= 0}] |
947 | } | |
948 | ||
949 | proc channel_securitycheck {channel} { | |
950 | upvar n n | |
951 | if {![channel_ismanager $channel $n]} { | |
952 | usererror "You are not a manager of $channel." | |
20087363 | 953 | } |
a01859b6 | 954 | nick_securitycheck 1 |
20087363 IJ |
955 | } |
956 | ||
957 | proc def_chancmd {name body} { | |
958 | proc channel/$name {} \ | |
959 | " upvar 1 target chan; upvar 1 n n; upvar 1 text text; $body" | |
960 | } | |
961 | ||
281b5f05 IJ |
962 | proc ta_listop {findnow procvalue} { |
963 | # findnow and procvalue are code fragments which will be executed | |
964 | # in the caller's level. findnow should set ta_listop_ev to | |
965 | # the current list, and procvalue should treat ta_listop_ev as | |
966 | # a proposed value in the list and check and possibly modify | |
967 | # (canonicalise?) it. After ta_listop, ta_listop_ev will | |
968 | # be the new value of the list. | |
969 | upvar 1 ta_listop_ev exchg | |
970 | upvar 1 text text | |
20087363 IJ |
971 | set opcode [ta_word] |
972 | switch -exact _$opcode { | |
281b5f05 | 973 | _= { } |
20087363 | 974 | _+ - _- { |
281b5f05 IJ |
975 | uplevel 1 $findnow |
976 | foreach item $exchg { set array($item) 1 } | |
20087363 IJ |
977 | } |
978 | default { | |
281b5f05 | 979 | error "list change opcode must be one of + - =" |
20087363 IJ |
980 | } |
981 | } | |
281b5f05 IJ |
982 | foreach exchg [split $text " "] { |
983 | if {![string length $exchg]} continue | |
984 | uplevel 1 $procvalue | |
20087363 | 985 | if {"$opcode" != "-"} { |
281b5f05 | 986 | set array($exchg) 1 |
20087363 | 987 | } else { |
281b5f05 | 988 | catch { unset array($exchg) } |
20087363 IJ |
989 | } |
990 | } | |
281b5f05 IJ |
991 | set exchg [lsort [array names array]] |
992 | } | |
993 | ||
994 | def_chancmd manager { | |
995 | ta_listop { | |
996 | if {[chandb_exists $chan]} { | |
997 | set ta_listop_ev [chandb_get $chan managers] | |
998 | } else { | |
999 | set ta_listop_ev [list [irctolower $n]] | |
1000 | } | |
1001 | } { | |
1002 | check_nick $ta_listop_ev | |
1003 | set ta_listop_ev [irctolower $ta_listop_ev] | |
1004 | } | |
1005 | if {[llength $ta_listop_ev]} { | |
1006 | chandb_set $chan managers $ta_listop_ev | |
1007 | ucmdr "Managers of $chan: $ta_listop_ev" {} | |
20087363 IJ |
1008 | } else { |
1009 | chandb_delete $chan | |
1010 | ucmdr {} {} "forgets about managing $chan." {} | |
1011 | } | |
1012 | } | |
1013 | ||
1014 | def_chancmd autojoin { | |
1015 | set yesno [ta_word] | |
1016 | switch -exact [string tolower $yesno] { | |
1017 | no { set nv 0 } | |
1018 | yes { set nv 1 } | |
1019 | default { error "channel autojoin must be `yes' or `no' } | |
1020 | } | |
1021 | chandb_set $chan autojoin $nv | |
a49f2997 IJ |
1022 | ucmdr [expr {$nv ? "I will join $chan when I'm restarted " : \ |
1023 | "I won't join $chan when I'm restarted "}] {} | |
534e26a9 IJ |
1024 | } |
1025 | ||
5e5be903 IJ |
1026 | def_chancmd userinvite { |
1027 | set nv [string tolower [ta_word]] | |
1028 | switch -exact $nv { | |
1029 | pub { set txt "!invite will work for $chan, but it won't work by /msg" } | |
1030 | here { set txt "!invite and /msg invite will work, but only for users who are already on $chan." } | |
1031 | all { set txt "Any user will be able to invite themselves or anyone else to $chan." } | |
1032 | none { set txt "I will not invite anyone to $chan." } | |
1033 | default { | |
1034 | error "channel userinvite must be `pub', `here', `all' or `none' | |
1035 | } | |
1036 | } | |
1037 | chandb_set $chan userinvite $nv | |
1038 | ucmdr $txt {} | |
1039 | } | |
1040 | ||
281b5f05 IJ |
1041 | def_chancmd topic { |
1042 | set what [ta_word] | |
1043 | switch -exact $what { | |
1044 | leave { | |
1045 | ta_nomore | |
1046 | chandb_set $chan topicset {} | |
1047 | ucmdr "I won't ever change the topic of $chan." {} | |
1048 | } | |
1049 | set { | |
1050 | set t [string trim $text] | |
1051 | if {![string length $t]} { | |
1052 | error "you must specific the topic to set" | |
1053 | } | |
1054 | chandb_set $chan topicset $t | |
a49f2997 | 1055 | ucmdr "Whenever I'm alone on $chan, I'll set the topic to $t." {} |
281b5f05 IJ |
1056 | } |
1057 | see - tell { | |
1058 | ta_listop { | |
1059 | set ta_listop_ev [chandb_get $chan topic$what] | |
1060 | } { | |
1061 | if {"$ta_listop_ev" != "*"} { | |
1062 | if {![ischan $ta_listop_ev]} { | |
1063 | error "bad channel \`$ta_listop_ev' in topic $what" | |
1064 | } | |
1065 | set ta_listop_ev [irctolower $ta_listop_ev] | |
1066 | } | |
1067 | } | |
1068 | chandb_set $chan topic$what $ta_listop_ev | |
1069 | ucmdr "Topic $what list for $chan: $ta_listop_ev" {} | |
1070 | } | |
1071 | default { | |
a01859b6 | 1072 | usererror "Unknown channel topic subcommand - see help channel." |
281b5f05 IJ |
1073 | } |
1074 | } | |
1075 | } | |
1076 | ||
534e26a9 IJ |
1077 | def_chancmd mode { |
1078 | set mode [ta_word] | |
1079 | if {"$mode" != "*" && ![regexp {^(([-+][imnpst]+)+)$} $mode mode]} { | |
1080 | error {channel mode must be * or match ([-+][imnpst]+)+} | |
1081 | } | |
1082 | chandb_set $chan mode $mode | |
1083 | if {"$mode" == "*"} { | |
281b5f05 | 1084 | ucmdr "I won't ever change the mode of $chan." {} |
534e26a9 | 1085 | } else { |
281b5f05 | 1086 | ucmdr "Whenever I'm alone on $chan, I'll set the mode to $mode." {} |
534e26a9 | 1087 | } |
20087363 IJ |
1088 | } |
1089 | ||
1090 | def_chancmd show { | |
1091 | if {[chandb_exists $chan]} { | |
1092 | set l "Settings for $chan: autojoin " | |
1093 | append l [lindex {no yes} [chandb_get $chan autojoin]] | |
b60b5a0f IJ |
1094 | append l ", mode " [chandb_get $chan mode] |
1095 | append l ", userinvite " [chandb_get $chan userinvite] "." | |
20087363 | 1096 | append l "\nManagers: " |
8b6ee626 | 1097 | append l [join [chandb_get $chan managers] " "] |
281b5f05 IJ |
1098 | foreach {ts sep} {see "\n" tell " "} { |
1099 | set t [chandb_get $chan topic$ts] | |
1100 | append l $sep | |
1101 | if {[llength $t]} { | |
1102 | append l "Topic $ts list: $t." | |
1103 | } else { | |
1104 | append l "Topic $ts list is empty." | |
1105 | } | |
1106 | } | |
8b6ee626 IJ |
1107 | append l "\n" |
1108 | set t [chandb_get $chan topicset] | |
1109 | if {[string length $t]} { | |
1110 | append l "Topic to set: $t" | |
1111 | } else { | |
1112 | append l "I will not change the topic." | |
1113 | } | |
20087363 IJ |
1114 | ucmdr {} $l |
1115 | } else { | |
1116 | ucmdr {} "The channel $chan is not managed." | |
1117 | } | |
1118 | } | |
1119 | ||
cf6ea4de IJ |
1120 | proc channelmgr_monoop {} { |
1121 | upvar 1 dest dest | |
1122 | upvar 1 text text | |
1123 | upvar 1 n n | |
1124 | upvar 1 p p | |
1125 | upvar 1 target target | |
1126 | global chan_nicks | |
1127 | ||
3c9af14f IJ |
1128 | prefix_nick |
1129 | ||
20087363 IJ |
1130 | if {[ischan $dest]} { set target $dest } |
1131 | if {[ta_anymore]} { set target [ta_word] } | |
1132 | ta_nomore | |
cf6ea4de | 1133 | if {![info exists target]} { |
a01859b6 | 1134 | usererror "You must specify, or invoke me on, the relevant channel." |
cf6ea4de IJ |
1135 | } |
1136 | if {![info exists chan_nicks([irctolower $target])]} { | |
a01859b6 | 1137 | usererror "I am not on $target." |
cf6ea4de | 1138 | } |
20087363 | 1139 | if {![ischan $target]} { error "not a valid channel" } |
3c9af14f | 1140 | |
a01859b6 IJ |
1141 | if {![chandb_exists $target]} { |
1142 | usererror "$target is not a managed channel." | |
1143 | } | |
1144 | channel_securitycheck $target | |
cf6ea4de IJ |
1145 | } |
1146 | ||
1147 | def_ucmd op { | |
1148 | channelmgr_monoop | |
20087363 | 1149 | sendout MODE $target +o $n |
c2f66f61 | 1150 | ucmdr {} {} |
20087363 IJ |
1151 | } |
1152 | ||
cf6ea4de IJ |
1153 | def_ucmd leave { |
1154 | channelmgr_monoop | |
1155 | doleave $target | |
c2f66f61 | 1156 | ucmdr {} {} |
cf6ea4de IJ |
1157 | } |
1158 | ||
5e5be903 | 1159 | def_ucmd invite { |
a01859b6 IJ |
1160 | global chan_nicks errorCode errorInfo |
1161 | prefix_nick | |
5e5be903 IJ |
1162 | |
1163 | if {[ischan $dest]} { | |
1164 | set target $dest | |
1165 | set onchan 1 | |
1166 | } else { | |
1167 | set target [ta_word] | |
1168 | set onchan 0 | |
1169 | } | |
1170 | set ltarget [irctolower $target] | |
a01859b6 IJ |
1171 | if {![ischan $target]} { error "$target is not a channel" } |
1172 | if {![info exists chan_nicks($ltarget)]} { | |
1173 | usererror "I am not on $target." | |
5e5be903 | 1174 | } |
a01859b6 IJ |
1175 | set ui [chandb_get $ltarget userinvite] |
1176 | if {[catch { | |
1177 | if {"$ui" == "pub" && !$onchan} { | |
1178 | usererror "Invitations to $target must be made there with !invite." | |
1179 | } | |
1180 | if {"$ui" != "all"} { | |
1181 | if {[lsearch -exact $chan_nicks($ltarget) [irctolower $n]] < 0} { | |
1182 | usererror "Invitations to $target may only be made\ | |
1183 | by a user on the channel." | |
1184 | } | |
1185 | } | |
1186 | if {"$ui" == "none"} { | |
1187 | usererror "Sorry, I've not been authorised\ | |
1188 | to invite people to $target." | |
1189 | } | |
1190 | } emsg]} { | |
1191 | if {"$errorCode" == "BLIGHT USER" && [channel_ismanager $target $n]} { | |
1192 | if {[catch { | |
1193 | nick_securitycheck 1 | |
1194 | } emsg2]} { | |
1195 | if {"$errorCode" == "BLIGHT USER"} { | |
1196 | usererror "$emsg2 Therefore you can't use your\ | |
1197 | channel manager privilege. $emsg" | |
1198 | } else { | |
1199 | error $error $errorInfo $errorCode | |
1200 | } | |
1201 | } | |
1202 | } else { | |
1203 | error $emsg $errorInfo $errorCode | |
5e5be903 | 1204 | } |
5e5be903 IJ |
1205 | } |
1206 | if {![ta_anymore]} { | |
a01859b6 | 1207 | usererror "You have to say who to invite." |
5e5be903 IJ |
1208 | } |
1209 | set invitees {} | |
1210 | while {[ta_anymore]} { | |
0abaa3a9 | 1211 | set invitee [ta_nick] |
5e5be903 IJ |
1212 | lappend invitees $invitee |
1213 | } | |
1214 | foreach invitee $invitees { | |
1215 | sendout INVITE $invitee $ltarget | |
1216 | } | |
1217 | set who [lindex $invitees 0] | |
1218 | switch -exact llength $invitees { | |
1219 | 0 { error "zero invitees" } | |
1220 | 1 { } | |
1221 | 2 { append who " and [lindex $invitees 1]" } | |
1222 | * { | |
1223 | set who [join [lreplace $invitees end end] ", "] | |
1224 | append who " and [lindex $invitees [llength $invitees]]" | |
1225 | } | |
1226 | } | |
33718ee2 | 1227 | ucmdr {} {} {} "invites $who to $target." |
5e5be903 IJ |
1228 | } |
1229 | ||
20087363 IJ |
1230 | def_ucmd channel { |
1231 | if {[ischan $dest]} { set target $dest } | |
1232 | if {![ta_anymore]} { | |
1233 | set subcmd show | |
1234 | } else { | |
1235 | set subcmd [ta_word] | |
1236 | } | |
1237 | if {[ischan $subcmd]} { | |
1238 | set target $subcmd | |
1239 | if {![ta_anymore]} { | |
1240 | set subcmd show | |
1241 | } else { | |
1242 | set subcmd [ta_word] | |
1243 | } | |
1244 | } | |
1245 | if {![info exists target]} { error "privately, you must specify a channel" } | |
1246 | set procname channel/$subcmd | |
1247 | if {"$subcmd" != "show"} { | |
a01859b6 IJ |
1248 | if {[catch { info body $procname }]} { |
1249 | usererror "unknown channel setting $subcmd." | |
1250 | } | |
20087363 | 1251 | prefix_nick |
20087363 | 1252 | if {[chandb_exists $target]} { |
a01859b6 | 1253 | channel_securitycheck $target |
20087363 | 1254 | } else { |
a01859b6 | 1255 | nick_securitycheck 1 |
20087363 | 1256 | upvar #0 chan_initialop([irctolower $target]) io |
534e26a9 | 1257 | upvar #0 nick_unique([irctolower $n]) u |
a01859b6 IJ |
1258 | if {![info exists io]} { |
1259 | usererror "$target is not a managed channel." | |
1260 | } | |
1261 | if {"$io" != "$u"} { | |
1262 | usererror "You are not the interim manager of $target." | |
1263 | } | |
1264 | if {"$subcmd" != "manager"} { | |
1265 | usererror "Please use `channel manager' first." | |
1266 | } | |
20087363 IJ |
1267 | } |
1268 | } | |
1269 | channel/$subcmd | |
1270 | } | |
1271 | ||
6cc2e28a IJ |
1272 | proc nickdb_get_username {n} { |
1273 | if {![nickdb_exists $n]} { return "" } | |
1274 | return [nickdb_get $n username] | |
1275 | } | |
1276 | ||
1277 | proc nickdb_get_sec_effective {n} { | |
26477e22 | 1278 | set l [nickdb_get $n tellsec] |
6cc2e28a | 1279 | set u [nickdb_get_username $n] |
26477e22 IJ |
1280 | if {"[lindex $l 0]" == "secure" && ![string length $u]} { set l insecure } |
1281 | return $l | |
1282 | } | |
1283 | ||
b36ab2da | 1284 | proc tell_peernicks {text} { |
0abaa3a9 | 1285 | global errorInfo errorCode |
b36ab2da IJ |
1286 | set text [irctolower [string trim $text]] |
1287 | set senders [split $text " "] | |
1288 | foreach sender $senders { | |
1289 | if {[catch { check_nick $sender } emsg]} { | |
0abaa3a9 | 1290 | error "invalid nick `$sender': $emsg" $errorInfo $errorCode |
b36ab2da IJ |
1291 | } |
1292 | } | |
1293 | return $senders | |
1294 | } | |
1295 | ||
52c775e8 IJ |
1296 | proc msgsdb_set_maydelete {n key l otherkey} { |
1297 | msgsdb_set $n $key $l | |
1298 | if {[llength $l]} return | |
1299 | if {[llength [msgsdb_get $n $otherkey]]} return | |
1300 | msgsdb_delete $n | |
1301 | } | |
1302 | ||
b36ab2da | 1303 | proc tell_delete_msgs {lsenders lrecip} { |
b36ab2da IJ |
1304 | set ninbound {} |
1305 | set ndel 0 | |
5d6d1db7 IJ |
1306 | foreach {s t m} [msgsdb_get $lrecip inbound] { |
1307 | if {[llength $lsenders]} { | |
1308 | if {[lsearch -exact $lsenders [irctolower $s]] == -1} { | |
b36ab2da IJ |
1309 | lappend ninbound $s $t $m |
1310 | continue | |
1311 | } | |
1312 | } | |
1313 | set rsenders($s) 1 | |
1314 | incr ndel | |
1315 | } | |
5d6d1db7 | 1316 | msgsdb_set_maydelete $lrecip inbound $ninbound outbound |
52c775e8 IJ |
1317 | if {![llength $ninbound]} { |
1318 | upvar #0 nick_telling($lrecip) telling | |
1319 | catch { unset telling } | |
1320 | } | |
b36ab2da IJ |
1321 | foreach s [array names rsenders] { |
1322 | set noutbound {} | |
1323 | foreach {r t c} [msgsdb_get $s outbound] { | |
1324 | if {"[irctolower $r]" == "$lrecip"} continue | |
1325 | lappend noutbound $r $t $c | |
1326 | } | |
52c775e8 | 1327 | msgsdb_set_maydelete $s outbound $noutbound inbound |
b36ab2da IJ |
1328 | } |
1329 | return $ndel | |
1330 | } | |
26477e22 IJ |
1331 | |
1332 | def_ucmd untell { | |
1333 | prefix_nick | |
1334 | check_notonchan | |
0ba5cc80 | 1335 | if {[nickdb_exists $n]} { nick_securitycheck 0 } |
b36ab2da IJ |
1336 | set recipients [tell_peernicks $text] |
1337 | if {![llength $recipients]} { | |
1338 | usererror "You must say which recipients' messages from you to forget." | |
1339 | } | |
1340 | set ndel 0 | |
1341 | foreach recip $recipients { | |
52c775e8 | 1342 | incr ndel [tell_delete_msgs [irctolower $n] $recip] |
b36ab2da IJ |
1343 | } |
1344 | ucmdr "Removed $ndel as yet undelivered message(s)." {} | |
1345 | } | |
26477e22 | 1346 | |
37ad12ba | 1347 | def_ucmd_alias delmsgs delmsg |
268336f8 | 1348 | def_ucmd delmsg { |
26477e22 | 1349 | global errorInfo errorCode |
268336f8 | 1350 | prefix_nick |
52c775e8 | 1351 | set nl [irctolower $n] |
268336f8 | 1352 | check_notonchan |
6cc2e28a | 1353 | manyset [nickdb_get_sec_effective $n] sec secwhen |
268336f8 IJ |
1354 | switch -exact $sec { |
1355 | insecure { } | |
470968c3 | 1356 | reject - mailto { |
26477e22 IJ |
1357 | usererror \ |
1358 | "There are no messages to delete\ | |
1359 | because your message disposition prevents them from being left." | |
1360 | } | |
1361 | secure { | |
1362 | nick_securitycheck 1 | |
1363 | } | |
1364 | default { | |
1365 | error "delmsg sec $sec" | |
1366 | } | |
1367 | } | |
0abaa3a9 IJ |
1368 | if {![llength [msgsdb_get $n inbound]]} { |
1369 | ucmdr "No incoming messages to delete." {} | |
1370 | } | |
52c775e8 | 1371 | tell_getcstate |
0abaa3a9 IJ |
1372 | if {![info exists u]} { |
1373 | usererror \ | |
1374 | "I can't delete your messages unless I can see you on a channel with me.\ | |
1375 | Otherwise I might delete a message I hadn't told you about yet." | |
1376 | } | |
52c775e8 | 1377 | if {"$stt" != "passed"} { |
0abaa3a9 | 1378 | set telling [list $u undelivered 0] |
52c775e8 | 1379 | usererror \ |
0abaa3a9 IJ |
1380 | "There are message(s) you may not yet have seen;\ |
1381 | I'll deliver them to you now.\ | |
52c775e8 IJ |
1382 | If you actually want to delete them, just tell me `delmsg' again." |
1383 | } | |
b36ab2da IJ |
1384 | set senders [tell_peernicks $text] |
1385 | set ndel [tell_delete_msgs [irctolower $senders] [irctolower $n]] | |
52c775e8 IJ |
1386 | if {!$ndel} { |
1387 | if {[llength $senders]} { | |
1388 | ucmdr "No relevant incoming messages to delete." {} | |
52c775e8 IJ |
1389 | } |
1390 | } | |
26477e22 | 1391 | switch -exact [llength $senders] { |
b36ab2da IJ |
1392 | 0 { ucmdr {} {} "deletes your $ndel message(s)." } |
1393 | 1 { ucmdr {} {} "deletes your $ndel message(s) from $senders." } | |
26477e22 | 1394 | default { |
b36ab2da | 1395 | ucmdr {} {} "deletes your $ndel message(s) from\ |
37ad12ba | 1396 | [lreplace $senders end end] and/or [lindex $senders end]." |
26477e22 IJ |
1397 | } |
1398 | } | |
268336f8 IJ |
1399 | } |
1400 | ||
5d6d1db7 IJ |
1401 | def_ucmd tellme { |
1402 | prefix_nick | |
1403 | ta_nomore | |
1404 | check_notonchan | |
470968c3 | 1405 | manyset [nickdb_get $n tellsec] sec |
37ad12ba | 1406 | switch -exact $sec { |
470968c3 | 1407 | reject { ucmdr "But, you asked me to reject messages for you !" {} } |
37ad12ba IJ |
1408 | mailto { ucmdr "But, you asked me to mail your messages to you !" {} } |
1409 | } | |
5d6d1db7 IJ |
1410 | switch -exact [tell_event [irctolower $n] tellme] { |
1411 | ERROR - INVALID { ucmdr {} {is ill. Help!} } | |
1412 | nomsgs { ucmdr {You have no messages.} {} } | |
1413 | default { } | |
1414 | } | |
1415 | } | |
1416 | ||
d7eda3bc IJ |
1417 | def_ucmd tell { |
1418 | global nick_case ownmailaddr ownfullname | |
1419 | ||
1420 | prefix_nick | |
0abaa3a9 | 1421 | set target [ta_nick] |
d7eda3bc | 1422 | if {![string length $text]} { error "tell them what?" } |
268336f8 | 1423 | if {[string length $text] > 400} { error "message too long" } |
d7eda3bc IJ |
1424 | |
1425 | set ltarget [irctolower $target] | |
1426 | set ctarget $target | |
1427 | if {[info exists nick_case($ltarget)]} { set ctarget $nick_case($ltarget) } | |
1428 | ||
6cc2e28a | 1429 | manyset [nickdb_get_sec_effective $target] sec mailtoint mailwhy |
34c25cd7 | 1430 | manyset [nickdb_get $target tellrel] rel relint relwithin |
d7eda3bc IJ |
1431 | switch -exact $sec { |
1432 | insecure - secure { | |
1433 | set now [clock seconds] | |
1434 | set inbound [msgsdb_get $ltarget inbound] | |
1435 | lappend inbound $n $now $text | |
1436 | msgsdb_set $ltarget inbound $inbound | |
1437 | ||
1438 | set outbound [msgsdb_get $n outbound] | |
1439 | set noutbound {} | |
1440 | set found 0 | |
1441 | foreach {recip time count} $outbound { | |
1442 | if {"[irctolower $recip]" == "$ltarget"} { | |
1443 | incr count | |
1444 | set recip $ctarget | |
1445 | set found 1 | |
1446 | } | |
1447 | lappend noutbound $recip $time $count | |
1448 | } | |
1449 | if {!$found} { | |
1450 | lappend noutbound $ctarget $now 1 | |
1451 | } | |
1452 | msgsdb_set $n outbound $noutbound | |
34c25cd7 IJ |
1453 | set msg "OK, I'll tell $ctarget" |
1454 | if {$found} { append msg " that too" } | |
1455 | append msg ", " | |
1456 | if {"$sec" != "secure"} { | |
1457 | switch -exact $rel { | |
1458 | unreliable { append msg "neither reliably nor securely" } | |
1459 | remind { append msg "pretty reliably, but not securely" } | |
1460 | pester { append msg "reliably but not securely" } | |
1461 | } | |
d7eda3bc | 1462 | } else { |
34c25cd7 IJ |
1463 | switch -exact $rel { |
1464 | unreliable { append msg "securely but not reliably" } | |
1465 | remind { append msg "securely and pretty reliably" } | |
1466 | pester { append msg "reliably and securely" } | |
1467 | } | |
d7eda3bc | 1468 | } |
34c25cd7 | 1469 | append msg . |
52c775e8 | 1470 | tell_event $ltarget msgsarrive |
34c25cd7 | 1471 | ucmdr $msg {} |
d7eda3bc IJ |
1472 | } |
1473 | mailto { | |
1474 | set fmtmsg [exec fmt << " $text"] | |
1475 | exec /usr/sbin/sendmail -odb -oi -t -oee -f $mailwhy \ | |
1476 | > /dev/null << \ | |
1477 | "From: $ownmailaddr ($ownfullname) | |
82d3b72f | 1478 | To: $mailtoint |
d7eda3bc IJ |
1479 | Subject: IRC tell from $n |
1480 | ||
1481 | $n asked me[expr {[ischan $dest] ? " on $dest" : ""}] to tell you: | |
1482 | [exec fmt << " $text"] | |
1483 | ||
1484 | (This message was for your nick $ctarget; your account $mailwhy | |
82d3b72f | 1485 | arranged for it to be forwarded to $mailtoint.) |
d7eda3bc IJ |
1486 | " |
1487 | ucmdr \ | |
82d3b72f | 1488 | "I've mailed $ctarget, which is what they prefer." \ |
d7eda3bc IJ |
1489 | {} |
1490 | } | |
470968c3 | 1491 | reject { |
d7eda3bc IJ |
1492 | usererror "Sorry, $ctarget does not want me to take messages." |
1493 | } | |
1494 | default { | |
1495 | error "bad tellsec $sec" | |
1496 | } | |
1497 | } | |
1498 | } | |
1499 | ||
a4a1f396 IJ |
1500 | def_ucmd who { |
1501 | if {[ta_anymore]} { | |
0abaa3a9 | 1502 | set target [ta_nick]; ta_nomore |
a4a1f396 IJ |
1503 | set myself 1 |
1504 | } else { | |
1505 | prefix_nick | |
1506 | set target $n | |
1507 | set myself [expr {"$target" != "$n"}] | |
1508 | } | |
534e26a9 IJ |
1509 | set ltarget [irctolower $target] |
1510 | upvar #0 nick_case($ltarget) ctarget | |
a4a1f396 | 1511 | set nshow $target |
534e26a9 IJ |
1512 | if {[info exists ctarget]} { |
1513 | upvar #0 nick_onchans($ltarget) oc | |
1514 | upvar #0 nick_username($ltarget) nu | |
1515 | if {[info exists oc]} { set nshow $ctarget } | |
a4a1f396 | 1516 | } |
534e26a9 | 1517 | if {![nickdb_exists $ltarget]} { |
a4a1f396 | 1518 | set ol "$nshow is not a registered nick." |
20087363 | 1519 | } elseif {[string length [set username [nickdb_get $target username]]]} { |
a4a1f396 IJ |
1520 | set ol "The nick $nshow belongs to the user $username." |
1521 | } else { | |
1522 | set ol "The nick $nshow is registered (but not to a username)." | |
1523 | } | |
534e26a9 | 1524 | if {![info exists ctarget] || ![info exists oc]} { |
a4a1f396 IJ |
1525 | if {$myself} { |
1526 | append ol "\nI can't see $nshow on anywhere." | |
1527 | } else { | |
1528 | append ol "\nYou aren't on any channels with me." | |
1529 | } | |
1530 | } elseif {![info exists nu]} { | |
1531 | append ol "\n$nshow has not identified themselves." | |
1532 | } elseif {![info exists username]} { | |
1533 | append ol "\n$nshow has identified themselves as the user $nu." | |
1534 | } elseif {"$nu" != "$username"} { | |
1535 | append ol "\nHowever, $nshow is being used by the user $nu." | |
1536 | } else { | |
1537 | append ol "\n$nshow has identified themselves to me." | |
1538 | } | |
1539 | ucmdr {} $ol | |
1540 | } | |
1541 | ||
7a70431a IJ |
1542 | def_ucmd register { |
1543 | prefix_nick | |
1544 | check_notonchan | |
1545 | set old [nickdb_exists $n] | |
1546 | if {$old} { nick_securitycheck 0 } | |
534e26a9 | 1547 | set luser [irctolower $n] |
7a70431a IJ |
1548 | switch -exact [string tolower [string trim $text]] { |
1549 | {} { | |
534e26a9 | 1550 | upvar #0 nick_username($luser) nu |
7a70431a IJ |
1551 | if {![info exists nu]} { |
1552 | ucmdr {} \ | |
a4a1f396 | 1553 | "You must identify yourself before using `register'. See `help identify', or use `register insecure'." |
7a70431a IJ |
1554 | } |
1555 | nickdb_set $n username $nu | |
1556 | ucmdr {} {} "makes a note of your username." {} | |
1557 | } | |
1558 | delete { | |
1559 | nickdb_delete $n | |
1560 | ucmdr {} {} "forgets your nickname." {} | |
1561 | } | |
1562 | insecure { | |
1563 | nickdb_set $n username {} | |
1564 | if {$old} { | |
1565 | ucmdr {} "Security is now disabled for your nickname !" | |
1566 | } else { | |
1567 | ucmdr {} "This is fine, but bear in mind that people will be able to mess with your settings. Channel management features need a secure registration." "makes an insecure registration for your nick." | |
1568 | } | |
1569 | } | |
0d3ea3aa IJ |
1570 | default { |
1571 | error "you mean register / register delete / register insecure" | |
1572 | } | |
7a70431a | 1573 | } |
11d9bff9 IJ |
1574 | } |
1575 | ||
1576 | proc timeformat_desc {tf} { | |
1577 | switch -exact $tf { | |
86892128 | 1578 | ks { return "Times will be displayed in seconds or kiloseconds." } |
11d9bff9 | 1579 | hms { return "Times will be displayed in hours, minutes, etc." } |
49a4dc8f | 1580 | beat { return "Times will be displayed in beats (1000B = 1d)." } |
11d9bff9 IJ |
1581 | default { error "invalid timeformat: $v" } |
1582 | } | |
1583 | } | |
1584 | ||
d7eda3bc | 1585 | set settings {} |
11d9bff9 | 1586 | proc def_setting {opt show_body set_body} { |
d7eda3bc IJ |
1587 | global settings |
1588 | lappend settings $opt | |
11d9bff9 IJ |
1589 | proc set_show/$opt {} " |
1590 | upvar 1 n n | |
1591 | set opt $opt | |
1592 | $show_body" | |
1593 | if {![string length $set_body]} return | |
1594 | proc set_set/$opt {} " | |
1595 | upvar 1 n n | |
1596 | upvar 1 text text | |
1597 | set opt $opt | |
1598 | $set_body" | |
1599 | } | |
1600 | ||
26477e22 | 1601 | proc tellme_sec_desc {v n} { |
82d3b72f | 1602 | manyset $v sec mailtoint |
d7eda3bc IJ |
1603 | switch -exact $sec { |
1604 | insecure { | |
1605 | return "I'll tell you your messages whenever I see you." | |
1606 | } | |
1607 | secure { | |
6cc2e28a | 1608 | if {[string length [nickdb_get_username $n]]} { |
26477e22 | 1609 | return \ |
82d3b72f | 1610 | "I'll keep the bodies of your messages private until you identify yourself, reminding you every [showintervalsecs $mailtoint 1]." |
26477e22 IJ |
1611 | } else { |
1612 | return \ | |
1613 | "I'll tell you your messages whenever I see you.\ | |
1614 | (Secure message delivery is enabled, but your nick is not registered\ | |
1615 | securely. See `help register'.)" | |
1616 | } | |
d7eda3bc | 1617 | } |
470968c3 | 1618 | reject { |
d7eda3bc IJ |
1619 | return "I shan't accept messages for you." |
1620 | } | |
1621 | mailto { | |
82d3b72f | 1622 | return "I'll forward your messages by email to $mailtoint." |
d7eda3bc IJ |
1623 | } |
1624 | default { | |
1625 | error "bad tellsec $sec" | |
1626 | } | |
1627 | } | |
1628 | } | |
1629 | ||
0abaa3a9 | 1630 | proc tellme_rel_desc {v n} { |
d7eda3bc IJ |
1631 | manyset $v rel every within |
1632 | switch -exact $rel { | |
1633 | unreliable { | |
ed982e50 IJ |
1634 | return "As soon as I've told you message(s), I'll forget them\ |
1635 | - note that this means messages can get lost !" | |
d7eda3bc IJ |
1636 | } |
1637 | pester { | |
1638 | set u {} | |
1639 | } | |
1640 | remind { | |
1641 | set u ", or talk on channel within [showintervalsecs $within 1] of me having told you" | |
1642 | } | |
1643 | default { | |
1644 | error "bad tellrel $rel" | |
1645 | } | |
1646 | } | |
ed982e50 IJ |
1647 | return "After delivering messages, I'll remind you every\ |
1648 | [showintervalsecs $every 1] until you say delmsg$u." | |
d7eda3bc IJ |
1649 | } |
1650 | ||
11d9bff9 | 1651 | def_setting timeformat { |
20087363 | 1652 | set tf [nickdb_get $n timeformat] |
11d9bff9 IJ |
1653 | return "$tf: [timeformat_desc $tf]" |
1654 | } { | |
1655 | set tf [string tolower [ta_word]] | |
1656 | ta_nomore | |
1657 | set desc [timeformat_desc $tf] | |
1658 | nickdb_set $n timeformat $tf | |
1659 | ucmdr {} $desc | |
1660 | } | |
1661 | ||
ebbae0a9 IJ |
1662 | proc marktime_desc {mt} { |
1663 | if {"$mt" == "off"} { | |
1664 | return "I will not send you periodic messages." | |
1665 | } elseif {"$mt" == "once"} { | |
1666 | return "I will send you one informational message when I see you." | |
1667 | } else { | |
ef177383 | 1668 | return "I'll send you a message every [showintervalsecs $mt 0]." |
ebbae0a9 IJ |
1669 | } |
1670 | } | |
1671 | ||
1672 | def_setting marktime { | |
1673 | set mt [nickdb_get $n marktime] | |
1674 | set p $mt | |
a4e294d4 | 1675 | if {[string match {[0-9]*} $mt]} { append p s } |
ebbae0a9 IJ |
1676 | append p ": " |
1677 | append p [marktime_desc $mt] | |
1678 | return $p | |
1679 | } { | |
1680 | global marktime_min | |
1681 | set mt [string tolower [ta_word]] | |
1682 | ta_nomore | |
1683 | ||
1684 | if {"$mt" == "off" || "$mt" == "once"} { | |
ebbae0a9 | 1685 | } else { |
d7eda3bc | 1686 | set mt [parse_interval $mt $marktime_min] |
ebbae0a9 IJ |
1687 | } |
1688 | nickdb_set $n marktime $mt | |
34c25cd7 | 1689 | lnick_marktime_start [irctolower $n] "So:" 500 0 |
ebbae0a9 IJ |
1690 | ucmdr {} [marktime_desc $mt] |
1691 | } | |
1692 | ||
11d9bff9 | 1693 | def_setting security { |
20087363 | 1694 | set s [nickdb_get $n username] |
11d9bff9 IJ |
1695 | if {[string length $s]} { |
1696 | return "Your nick, $n, is controlled by the user $s." | |
1697 | } else { | |
1698 | return "Your nick, $n, is not secure." | |
1699 | } | |
1700 | } {} | |
1701 | ||
26477e22 | 1702 | proc tellme_setting_sec_simple {} { |
268336f8 IJ |
1703 | uplevel 1 { |
1704 | ta_nomore | |
1705 | set sr sec | |
1706 | set v $setting | |
1707 | } | |
1708 | } | |
1709 | ||
26477e22 | 1710 | proc tellme_setting_neednomsgs {} { |
268336f8 IJ |
1711 | uplevel 1 { |
1712 | if {[llength [msgsdb_get $n inbound]]} { | |
0abaa3a9 | 1713 | usererror "You must delete the incoming messages you have, first." |
268336f8 IJ |
1714 | } |
1715 | } | |
26477e22 | 1716 | } |
268336f8 | 1717 | |
d7eda3bc IJ |
1718 | def_setting tellme { |
1719 | set secv [nickdb_get $n tellsec] | |
26477e22 | 1720 | set ms [tellme_sec_desc $secv $n] |
d7eda3bc IJ |
1721 | manyset $secv sec |
1722 | switch -exact $sec { | |
1723 | insecure - secure { | |
0abaa3a9 | 1724 | set mr [tellme_rel_desc [nickdb_get $n tellrel] $n] |
d7eda3bc IJ |
1725 | return "$ms $mr" |
1726 | } | |
470968c3 | 1727 | reject - mailto { |
d7eda3bc IJ |
1728 | return $ms |
1729 | } | |
1730 | } | |
1731 | } { | |
1732 | set setting [string tolower [ta_word]] | |
37ad12ba | 1733 | set nl [irctolower $n] |
d7eda3bc | 1734 | switch -exact $setting { |
268336f8 | 1735 | insecure { |
26477e22 | 1736 | tellme_setting_sec_simple |
268336f8 IJ |
1737 | } |
1738 | secure { | |
26477e22 IJ |
1739 | set every [ta_interval_optional 60 600] |
1740 | ta_nomore | |
1741 | set sr sec | |
1742 | set v [list secure $every] | |
268336f8 | 1743 | } |
470968c3 | 1744 | reject { |
0abaa3a9 IJ |
1745 | tellme_setting_neednomsgs |
1746 | tellme_setting_sec_simple | |
d7eda3bc IJ |
1747 | } |
1748 | mailto { | |
0abaa3a9 | 1749 | tellme_setting_neednomsgs |
6cc2e28a | 1750 | |
37ad12ba IJ |
1751 | upvar #0 nick_username($nl) nu |
1752 | if {!([info exists nu] && [string length $nu])} { | |
26477e22 IJ |
1753 | usererror \ |
1754 | "Sorry, you must register securely to have your messages mailed\ | |
1755 | (to prevent the use of this feature for spamming). See `help register'." | |
1756 | } | |
d7eda3bc | 1757 | set sr sec |
37ad12ba | 1758 | set v [list mailto [ta_word] $nu] |
d7eda3bc IJ |
1759 | } |
1760 | unreliable - pester - remind { | |
1761 | manyset [nickdb_get $n tellsec] sec | |
1762 | switch -exact $sec { | |
470968c3 | 1763 | reject - mailto { |
26477e22 | 1764 | usererror \ |
81acf1c7 IJ |
1765 | "Sorry, I shan't change when I'll consider a message delivered, because\ |
1766 | you've asked me not to keep messages, or to mail them to you.\ | |
1767 | You should say `set tellme secure' or some such, first." | |
d7eda3bc IJ |
1768 | } |
1769 | } | |
1770 | set sr rel | |
1771 | set v $setting | |
1772 | if {"$setting" != "unreliable"} { | |
0abaa3a9 | 1773 | set every [ta_interval_optional 300 3600] |
d7eda3bc IJ |
1774 | lappend v $every |
1775 | } | |
1776 | if {"$setting" == "remind"} { | |
26477e22 | 1777 | set within [ta_interval_optional 5 30] |
d7eda3bc IJ |
1778 | if {$within > $every} { |
1779 | error "remind interval must be at least time to respond" | |
1780 | } | |
1781 | lappend v $within | |
1782 | } | |
1783 | ta_nomore | |
1784 | } | |
1785 | default { | |
1786 | error "invalid tellme setting $setting" | |
1787 | } | |
1788 | } | |
1789 | nickdb_set $n tell$sr $v | |
37ad12ba | 1790 | upvar #0 nick_telling($nl) telling |
0abaa3a9 IJ |
1791 | catch { unset telling } |
1792 | ucmdr [tellme_${sr}_desc $v $n] {} | |
d7eda3bc IJ |
1793 | } |
1794 | ||
34c25cd7 IJ |
1795 | proc lnick_checktold {luser} { |
1796 | set ml [msgsdb_get $luser outbound] | |
1797 | if {![llength $ml]} return | |
1798 | set is1 [expr {[llength $ml]==3}] | |
0abaa3a9 | 1799 | set m1 "FYI, I haven't yet delivered your" |
34c25cd7 IJ |
1800 | set ol {} |
1801 | set now [clock seconds] | |
1802 | while {[llength $ml]} { | |
1803 | manyset $ml r t n | |
1804 | set ml [lreplace $ml 0 2] | |
1805 | set td [expr {$now-$t}] | |
1806 | if {$n == 1} { | |
1807 | set iv [showinterval $td] | |
1808 | set ifo "$r, $iv" | |
1809 | set if1 "message to $r, $iv." | |
1810 | } else { | |
1811 | set iv [showintervalsecs $td 0] | |
1812 | set ifo "$r, $n messages, oldest $iv" | |
1813 | set if1 "$n messages to $r, oldest $iv." | |
1814 | } | |
1815 | if {$is1} { | |
1816 | sendprivmsg $luser "$m1 $if1" | |
1817 | return | |
1818 | } else { | |
1819 | lappend ol " to $ifo[expr {[llength $ml] ? ";" : "."}]" | |
1820 | } | |
1821 | } | |
1822 | sendprivmsg $luser "$m1 messages:" | |
1823 | msendprivmsg $luser $ol | |
1824 | } | |
1825 | ||
11d9bff9 | 1826 | def_ucmd set { |
d7eda3bc | 1827 | global settings |
11d9bff9 IJ |
1828 | prefix_nick |
1829 | check_notonchan | |
1830 | if {![nickdb_exists $n]} { | |
d83fb8db | 1831 | ucmdr {} "You are unknown to me and so have no settings. (Use `register'.)" |
11d9bff9 IJ |
1832 | } |
1833 | if {![ta_anymore]} { | |
1834 | set ol {} | |
d7eda3bc | 1835 | foreach opt $settings { |
11d9bff9 IJ |
1836 | lappend ol [format "%-10s %s" $opt [set_show/$opt]] |
1837 | } | |
1838 | ucmdr {} [join $ol "\n"] | |
1839 | } else { | |
1840 | set opt [ta_word] | |
1841 | if {[catch { info body set_show/$opt }]} { | |
1842 | error "no setting $opt" | |
1843 | } | |
1844 | if {![ta_anymore]} { | |
d7eda3bc | 1845 | ucmdr {} "$opt: [set_show/$opt]" |
11d9bff9 | 1846 | } else { |
86892128 | 1847 | nick_securitycheck 0 |
11d9bff9 IJ |
1848 | if {[catch { info body set_set/$opt }]} { |
1849 | error "setting $opt cannot be set with `set'" | |
1850 | } | |
1851 | set_set/$opt | |
1852 | } | |
1853 | } | |
1854 | } | |
7a70431a | 1855 | |
4fd2739c | 1856 | def_ucmd identpass { |
4fd2739c | 1857 | prefix_nick |
11d9bff9 | 1858 | check_notonchan |
534e26a9 | 1859 | set luser [irctolower $n] |
ed982e50 IJ |
1860 | set username [ta_word] |
1861 | set passmd5 [md5sum "[ta_word]\n"] | |
1862 | ta_nomore | |
534e26a9 | 1863 | upvar #0 nick_onchans($luser) onchans |
4fd2739c | 1864 | if {![info exists onchans] || ![llength $onchans]} { |
7a70431a | 1865 | ucmdr "You must be on a channel with me to identify yourself." {} |
4fd2739c IJ |
1866 | } |
1867 | check_username $username | |
1868 | exec userv --timeout 3 $username << "$passmd5\n" > /dev/null \ | |
1869 | irc-identpass $n | |
534e26a9 | 1870 | upvar #0 nick_username($luser) rec_username |
4fd2739c | 1871 | set rec_username $username |
0abaa3a9 | 1872 | after 50 [list tell_event $luser ident] |
c99281b8 | 1873 | ucmdr "Pleased to see you, $username." {} |
4fd2739c IJ |
1874 | } |
1875 | ||
49a4dc8f IJ |
1876 | def_ucmd kill { |
1877 | global nick | |
1878 | prefix_nick | |
1879 | set target [ta_nick] | |
1880 | if {![nickdb_exists $target]} { error "$target is not a registered nick." } | |
1881 | set wantu [nickdb_get $target username] | |
1882 | if {![string length $wantu]} { error "$target is insecurely registred." } | |
1883 | upvar #0 nick_username([irctolower $n]) nu | |
1884 | if {![info exists nu]} { error "You must identify yourself first." } | |
1885 | if {"$wantu" != "$nu"} { | |
1886 | error "You are the wrong user, $nu - $target belongs to $wantu." | |
1887 | } | |
1888 | set reason "at request of user $nu" | |
1889 | if {[ta_anymore]} { append reason "; $text" } | |
1890 | sendout KILL $target $reason | |
c2f66f61 | 1891 | ucmdr {} {} |
49a4dc8f IJ |
1892 | } |
1893 | ||
4fd2739c IJ |
1894 | def_ucmd summon { |
1895 | set target [ta_word] | |
1896 | ta_nomore | |
49a4dc8f | 1897 | # fixme would be nice if the rest of the text was passed on instead |
4fd2739c | 1898 | check_username $target |
7ce72032 IJ |
1899 | prefix_nick |
1900 | ||
1901 | upvar #0 lastsummon($target) ls | |
1902 | set now [clock seconds] | |
1903 | if {[info exists ls]} { | |
1904 | set interval [expr {$now - $ls}] | |
1905 | if {$interval < 30} { | |
1906 | ucmdr {} \ | |
1907 | "Please be patient; $target was summoned only [showinterval $interval]." | |
1908 | } | |
1909 | } | |
1910 | regsub {^[^!]*!} $p {} path | |
1911 | if {[catch { | |
1912 | exec userv --timeout 3 $target irc-summon $n $path \ | |
1913 | [expr {[ischan $dest] ? "$dest" : ""}] \ | |
1914 | < /dev/null | |
1915 | } rv]} { | |
1916 | regsub -all "\n" $rv { / } rv | |
1917 | error $rv | |
1918 | } | |
1919 | if {[regexp {^problem (.*)} $rv dummy problem]} { | |
8a8d337d | 1920 | ucmdr {} "The user `$target' $problem." |
7ce72032 IJ |
1921 | } elseif {[regexp {^ok ([^ ]+) ([0-9]+)$} $rv dummy tty idlesince]} { |
1922 | set idletime [expr {$now - $idlesince}] | |
1923 | set ls $now | |
1924 | ucmdr {} {} {} "invites $target ($tty[expr { | |
ef177383 | 1925 | $idletime > 10 ? ", idle for [showintervalsecs $idletime 0]" : "" |
7ce72032 IJ |
1926 | }]) to [expr { |
1927 | [ischan $dest] ? "join us here" : "talk to you" | |
1928 | }]." | |
1929 | } else { | |
1930 | error "unexpected response from userv service: $rv" | |
1931 | } | |
1932 | } | |
1933 | ||
a69f7d2c IJ |
1934 | proc md5sum {value} { exec md5sum << $value } |
1935 | ||
83dd1224 | 1936 | def_ucmd seen { |
422f52e4 | 1937 | global lastseen nick |
83dd1224 IJ |
1938 | prefix_nick |
1939 | set ncase [ta_nick] | |
1940 | set nlower [irctolower $ncase] | |
422f52e4 | 1941 | ta_nomore |
83dd1224 IJ |
1942 | set now [clock seconds] |
1943 | if {"$nlower" == "[irctolower $nick]"} { | |
a01859b6 | 1944 | usererror "I am not self-aware." |
83dd1224 IJ |
1945 | } elseif {![info exists lastseen($nlower)]} { |
1946 | set rstr "I've never seen $ncase." | |
422f52e4 | 1947 | } else { |
83dd1224 IJ |
1948 | manyset $lastseen($nlower) realnick time what |
1949 | set howlong [expr {$now - $time}] | |
1950 | set string [showinterval $howlong] | |
1951 | set rstr "I last saw $realnick $string, $what." | |
1952 | } | |
1953 | if {[ischan $dest]} { | |
1954 | set where $dest | |
1955 | } else { | |
1956 | set where {} | |
1957 | } | |
1958 | upvar #0 lookedfor($nlower) lf | |
1959 | if {[info exists lf]} { set oldvalue $lf } else { set oldvalue {} } | |
1960 | set lf [list [list $now $n $where]] | |
1961 | foreach v $oldvalue { | |
1962 | if {"[irctolower [lindex $v 1]]" == "[irctolower $n]"} continue | |
1963 | lappend lf $v | |
cc2d31de | 1964 | } |
83dd1224 | 1965 | ucmdr {} $rstr |
cc2d31de IJ |
1966 | } |
1967 | ||
ebbae0a9 IJ |
1968 | proc lnick_marktime_cancel {luser} { |
1969 | upvar #0 nick_markid($luser) mi | |
1970 | if {![info exists mi]} return | |
1971 | catch { after cancel $mi } | |
1972 | catch { unset mi } | |
1973 | } | |
1974 | ||
34c25cd7 | 1975 | proc lnick_marktime_doafter {luser why ms mentiontold} { |
ebbae0a9 IJ |
1976 | lnick_marktime_cancel $luser |
1977 | upvar #0 nick_markid($luser) mi | |
34c25cd7 | 1978 | set mi [after $ms [list lnick_marktime_now $luser $why 0]] |
ebbae0a9 IJ |
1979 | } |
1980 | ||
1981 | proc lnick_marktime_reset {luser} { | |
1982 | set mt [nickdb_get $luser marktime] | |
1983 | if {"$mt" == "off" || "$mt" == "once"} return | |
34c25cd7 | 1984 | lnick_marktime_doafter $luser "Time passes." [expr {$mt*1000}] 0 |
ebbae0a9 IJ |
1985 | } |
1986 | ||
34c25cd7 | 1987 | proc lnick_marktime_start {luser why ms mentiontold} { |
ebbae0a9 IJ |
1988 | set mt [nickdb_get $luser marktime] |
1989 | if {"$mt" == "off"} { | |
1990 | lnick_marktime_cancel $luser | |
52c775e8 | 1991 | if {$mentiontold} { after $ms [list lnick_checktold $luser] } |
ebbae0a9 | 1992 | } else { |
34c25cd7 | 1993 | lnick_marktime_doafter $luser $why $ms $mentiontold |
ebbae0a9 IJ |
1994 | } |
1995 | } | |
1996 | ||
34c25cd7 | 1997 | proc lnick_marktime_now {luser why mentiontold} { |
ebbae0a9 | 1998 | upvar #0 nick_onchans($luser) oc |
93e9bcff IJ |
1999 | global calling_nick |
2000 | set calling_nick $luser | |
ebbae0a9 | 2001 | sendprivmsg $luser [lnick_pingstring $why $oc ""] |
5d6d1db7 | 2002 | if {$mentiontold} { after 150 [list lnick_checktold $luser] } |
ebbae0a9 IJ |
2003 | lnick_marktime_reset $luser |
2004 | } | |
2005 | ||
2006 | proc lnick_pingstring {why oc apstring} { | |
2007 | global nick_onchans | |
2008 | catch { exec uptime } uptime | |
2009 | set nnicks [llength [array names nick_onchans]] | |
2010 | if {[regexp \ | |
ea8a1bfe | 2011 | {^ *([0-9:apm]+) +up.*, +(\d+) users?, +load average: +([0-9., ]+) *$} \ |
ebbae0a9 | 2012 | $uptime dummy time users load]} { |
93e9bcff | 2013 | regsub -all , $load {} load |
ebbae0a9 IJ |
2014 | set uptime "$time $nnicks/$users $load" |
2015 | } else { | |
2016 | append uptime ", $nnicks nicks" | |
2017 | } | |
2018 | if {[llength $oc]} { | |
2019 | set best_la 0 | |
2020 | set activity quiet | |
2021 | foreach ch $oc { | |
2022 | upvar #0 chan_lastactivity($ch) la | |
2023 | if {![info exists la]} continue | |
2024 | if {$la <= $best_la} continue | |
ef177383 IJ |
2025 | set since [showintervalsecs [expr {[clock seconds]-$la}] 1] |
2026 | set activity "$ch $since" | |
ebbae0a9 IJ |
2027 | set best_la $la |
2028 | } | |
2029 | } else { | |
2030 | set activity unseen | |
2031 | } | |
2032 | set str $why | |
2033 | append str " " $uptime " " $activity | |
2034 | if {[string length $apstring]} { append str " " $apstring } | |
2035 | return $str | |
2036 | } | |
2037 | ||
2038 | def_ucmd ping { | |
34c25cd7 IJ |
2039 | prefix_nick |
2040 | set ln [irctolower $n] | |
ebbae0a9 IJ |
2041 | if {[ischan $dest]} { |
2042 | set oc [irctolower $dest] | |
2043 | } else { | |
2044 | global nick_onchans | |
ebbae0a9 IJ |
2045 | if {[info exists nick_onchans($ln)]} { |
2046 | set oc $nick_onchans($ln) | |
2047 | } else { | |
2048 | set oc {} | |
2049 | } | |
2050 | if {[llength $oc]} { lnick_marktime_reset $ln } | |
2051 | } | |
5d6d1db7 | 2052 | after 150 [list lnick_checktold $ln] |
ebbae0a9 IJ |
2053 | ucmdr {} [lnick_pingstring "Pong!" $oc $text] |
2054 | } | |
2055 | ||
28c8ab78 IJ |
2056 | proc ensure_globalsecret {} { |
2057 | global globalsecret | |
2058 | ||
2059 | if {[info exists globalsecret]} return | |
2060 | set gsfile [open /dev/urandom r] | |
2061 | fconfigure $gsfile -translation binary | |
2062 | set globalsecret [read $gsfile 32] | |
2063 | binary scan $globalsecret H* globalsecret | |
2064 | close $gsfile | |
2065 | unset gsfile | |
2066 | } | |
2067 | ||
534e26a9 | 2068 | proc connected {} { |
49a4dc8f IJ |
2069 | global operuserpass |
2070 | if {[info exists operuserpass]} { | |
2071 | eval sendout OPER $operuserpass | |
2072 | } | |
534e26a9 IJ |
2073 | foreach chan [chandb_list] { |
2074 | if {[chandb_get $chan autojoin]} { dojoin $chan } | |
2075 | } | |
2076 | } | |
2077 | ||
28c8ab78 | 2078 | ensure_globalsecret |
e6cc22dc | 2079 | loadhelp |
28c8ab78 | 2080 | ensure_connecting |