1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | our $TOPIC; |
3 | our $TOPIC; |
|
|
4 | |
|
|
5 | our $HELP_CHANNEL = { |
|
|
6 | id => "help", |
|
|
7 | title => "Help", |
|
|
8 | reply => "help ", |
|
|
9 | tooltip => "Online Help", |
|
|
10 | }; |
4 | |
11 | |
5 | sub load_topics($$) { |
12 | sub load_topics($$) { |
6 | my ($type, $path) = @_; |
13 | my ($type, $path) = @_; |
7 | |
14 | |
8 | my $paragraphs = cf::pod::load_pod "$PODDIR/$path.pod" |
15 | my $paragraphs = cf::pod::load_pod "$PODDIR/$path.pod" |
… | |
… | |
57 | |
64 | |
58 | cf::register_command help => sub { |
65 | cf::register_command help => sub { |
59 | my ($pl, $topic) = @_; |
66 | my ($pl, $topic) = @_; |
60 | |
67 | |
61 | if (cf::lock_active "ext::help::loading") { |
68 | if (cf::lock_active "ext::help::loading") { |
62 | $pl->reply (undef, "help files are being loaded currently, try again in a few seconds."); |
69 | $pl->send_msg ($HELP_CHANNEL => "help files are being loaded currently, try again in a few seconds.", cf::NDI_REPLY | cf::NDI_CLEAR); |
63 | return; |
70 | return; |
64 | } |
71 | } |
65 | |
72 | |
66 | $topic = $1 if $topic =~ /(\S+)/; |
73 | $topic = $1 if $topic =~ /(\S+)/; |
67 | |
74 | |
… | |
… | |
76 | my $res; |
83 | my $res; |
77 | while (my ($k, $v) = each %topics) { |
84 | while (my ($k, $v) = each %topics) { |
78 | $res .= "B<$k:>\n" . (join " ", sort @$v) . "\n\n"; |
85 | $res .= "B<$k:>\n" . (join " ", sort @$v) . "\n\n"; |
79 | } |
86 | } |
80 | |
87 | |
81 | $pl->reply (undef, $res); |
88 | $pl->send_msg ($HELP_CHANNEL => $res, cf::NDI_REPLY | cf::NDI_CLEAR); |
82 | |
89 | |
83 | } elsif (my $item = $TOPIC->{$topic}) { |
90 | } elsif (my $item = $TOPIC->{$topic}) { |
84 | my ($type, @pars) = @$item; |
91 | my ($type, @pars) = @$item; |
85 | $pl->reply (undef, cf::pod::as_cfpod \@pars); |
92 | $pl->send_msg ($HELP_CHANNEL => (cf::pod::as_cfpod \@pars), cf::NDI_REPLY | cf::NDI_CLEAR); |
86 | |
93 | |
87 | } else { |
94 | } else { |
88 | $pl->reply (undef, "'$topic' no such help topic, try just 'help' to get a list of topics."); |
95 | $pl->send_msg ($HELP_CHANNEL => "'$topic' no such help topic, try just 'help' to get a list of topics.", cf::NDI_REPLY); |
89 | } |
96 | } |
90 | }; |
97 | }; |
91 | |
98 | |