… | |
… | |
8 | my ($category, $cb) = @_; |
8 | my ($category, $cb) = @_; |
9 | $DOCLET{$category} = $cb; |
9 | $DOCLET{$category} = $cb; |
10 | Guard::guard { delete $DOCLET{$category} } |
10 | Guard::guard { delete $DOCLET{$category} } |
11 | } |
11 | } |
12 | |
12 | |
|
|
13 | sub doclet($$$) { |
|
|
14 | my ($pl, $category, $item) = @_; |
|
|
15 | |
|
|
16 | if (my $cb = $DOCLET{$category}) { |
|
|
17 | $cb->($pl, $category, $item) |
|
|
18 | } else { |
|
|
19 | "No documentation found for $category/$item." |
|
|
20 | } |
|
|
21 | } |
|
|
22 | |
|
|
23 | our $SKILL_HANDLER = ext::doclet::register skill => sub { |
|
|
24 | my ($pl, $category, $name) = @_; |
|
|
25 | |
|
|
26 | my $skill = $pl->find_skill ($name); |
|
|
27 | |
|
|
28 | "B<$name>\n\n" |
|
|
29 | . ($skill ? $skill->msg : "You don't know anything about this skill.") |
|
|
30 | }; |
|
|
31 | |
13 | cf::register_async_exticmd doclet => sub { |
32 | cf::register_async_exticmd doclet => sub { |
14 | my ($ns, $reply, $category, $entry) = @_; |
33 | my ($ns, $reply, $category, $item) = @_; |
15 | |
34 | |
16 | cf::async { |
35 | $ns->async (sub { |
17 | my $cfpod; |
36 | my $cfpod; |
18 | |
37 | |
19 | if (my $pl = $ns->pl) { |
38 | if (my $pl = $ns->pl) { |
20 | |
|
|
21 | if (my $cb = $DOCLET{$category}) { |
|
|
22 | $cfpod = $cb->($pl, $category, $entry); |
|
|
23 | } else { |
|
|
24 | $cfpod = "No documentation found for $category/$entry."; |
|
|
25 | } |
|
|
26 | |
|
|
27 | $cfpod = $pl->expand_cfpod ($cfpod); |
39 | $cfpod = $pl->expand_cfpod (doclet $pl, $category, $item); |
28 | } else { |
40 | } else { |
29 | $cfpod = "(documentation not available before login)"; |
41 | $cfpod = "(documentation not available before login)"; |
30 | } |
42 | } |
31 | |
43 | |
32 | $reply->($cfpod); |
44 | $reply->($cfpod); |
33 | }; |
45 | }); |
34 | }; |
46 | }; |
35 | |
47 | |