1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | sub do_help { |
3 | sub do_help { |
4 | my ($board, $who, $npc) = @_; |
4 | my ($board, $who, $npc) = @_; |
5 | $who->reply ($npc, |
5 | $who->reply ($npc, |
6 | "Help for $board\n" |
6 | "Help for $board\n\n" |
7 | ."List of commands:\n\n" |
7 | . "List of commands:\n\n" |
8 | ."- list\n" |
8 | . " - list\n" |
9 | ."- write <message>\n" |
9 | . " - write <message>\n" |
10 | ."- remove <id>\n" |
10 | . " - remove <id>\n" |
11 | ); |
11 | ); |
12 | } |
12 | } |
13 | |
13 | |
14 | sub do_write { |
14 | sub do_write { |
15 | my ($board, $msg, $who, $npc) = @_; |
15 | my ($board, $msg, $who, $npc) = @_; |
… | |
… | |
23 | } |
23 | } |
24 | |
24 | |
25 | sub do_list { |
25 | sub do_list { |
26 | my ($board, $who, $npc) = @_; |
26 | my ($board, $who, $npc) = @_; |
27 | my $cont = CFBoard::get ($board); |
27 | my $cont = CFBoard::get ($board); |
28 | if (@{$cont || []}) { |
|
|
29 | $who->reply ($npc, "$board content:"); |
|
|
30 | my $idx = 0; |
|
|
31 | for (@$cont) { |
28 | if (@$cont) { |
32 | $who->reply ($npc, "<$idx> $_->[0]: $_->[1]"); |
29 | my $msg = "$board content:\n\n"; |
33 | $idx++; |
30 | $msg .= "<$_> $cont->[$_][0]: $cont->[$_][1]\r" |
34 | } |
31 | for 0 .. $#$cont; |
|
|
32 | $who->reply ($npc, $msg); |
35 | } else { |
33 | } else { |
36 | $who->reply ($npc, "$board is empty."); |
34 | $who->reply ($npc, "$board is empty."); |
37 | } |
35 | } |
38 | 1 |
36 | 1 |
39 | } |
37 | } |