#! perl our $TOPIC; sub load_topics($) { my ($path) = @_; my $paragraphs = cf::pod::load_pod "$PODDIR/$path.pod" or die "unable to load $path"; my @topics; my $level = 1e9; for my $par (@$paragraphs) { Coro::cede; if ($par->{type} eq "head2") { if ($par->{markup} =~ /^(\S+)/) { push @topics, $1 => [$par]; $level = $par->{level}; } } elsif ($par->{level} > $level) { push @{ $topics[-1] }, $par; } } @topics } sub reload() { $TOPIC = { load_topics "dmcommand_help", load_topics "emote_help", load_topics "command_help", load_topics "generic_help", }; } cf::sync_job { my $guard = cf::lock_acquire "ext::help::loading"; cf::async_ext { reload; undef $guard; }; }; cf::register_command xhelp => sub { my ($pl, $topic) = @_; if (cf::lock_active "ext::help::loading") { $pl->reply (undef, "help files are being loaded currently, try again in a few seconds"); return; } };