2 global help_topics errorInfo helpfile
4 catch { unset help_topics }
5 set f [open $helpfile r]
8 while {[gets $f l] >= 0} {
10 if {[regexp {^#.*} $l]} {
11 } elseif {[regexp {^ *$} $l]} {
12 if {[info exists topic]} {
13 set help_topics($topic) [join $lines "\n"]
17 } elseif {[regexp {^\:\:} $l]} {
18 } elseif {[regexp {^\:([-+._0-9a-z]*)$} $l dummy newtopic]} {
19 if {[info exists topic]} {
20 error "help $newtopic while in $topic"
24 } elseif {[regexp {^[^:#]} $l]} {
26 regsub -all {([^\\])\!\$?} _$l {\1} l
27 regsub -all {\\(.)} $l {\1} l
29 lappend lines [string trimright $l]
34 if {[info exists topic]} { error "unfinished topic $topic" }
36 set errorInfo "in $helpfile line $lno\n$errorInfo"
45 set topic [irctolower [string trim $text]]
46 if {[string length $topic]} {
47 set ontopic " on `$topic'"
51 if {[set lag [out_lagged]]} {
52 if {[ischan $dest]} { set replyto $dest } else { set replyto $n }
54 sendaction_priority 1 $replyto \
55 "is very lagged. Please ask for help$ontopic again later."
58 sendaction_priority 1 $replyto \
59 "is lagged. Your help$ontopic will arrive shortly ..."
63 upvar #0 help_topics($topic) info
64 if {![info exists info]} { ucmdr "No help on $topic, sorry." {} }
70 ucmdr $help_topics() {}