1 | #! perl # depends=irc |
1 | #! perl # depends=irc |
2 | |
2 | |
|
|
3 | use Fcntl; |
|
|
4 | use Coro::AIO; |
|
|
5 | |
3 | our $UPDATE_LOGINS = EV::idle Coro::unblock_sub { |
6 | our $UPDATE_LOGINS = EV::idle sub { |
4 | $_[0]->stop; |
7 | $_[0]->stop; |
5 | |
8 | |
|
|
9 | cf::async { |
6 | my ($status, @pl) = ext::commands::who_listing; |
10 | my ($status, @pl) = ext::commands::who_listing; |
7 | |
11 | |
8 | #TODO: write files asynchronously |
12 | my $fh = aio_open "$LOCALDIR/usercount", O_WRONLY | O_CREAT | O_TRUNC, 0644 |
9 | open my $fh, ">", "$LOCALDIR/usercount"; |
13 | or return; |
10 | print $fh scalar @pl; |
14 | aio_write $fh, 0, undef, scalar @pl, 0; |
|
|
15 | aio_close $fh; |
11 | |
16 | |
12 | open my $fh, ">", "$LOCALDIR/userlisting.html"; |
17 | my $who; |
13 | for ($status, @pl) { |
18 | for ($status, @pl) { |
14 | s/[<&]//g; |
19 | s/[<&]//g; |
15 | print $fh "$_<br />\n"; |
20 | $who .= "$_<br />\n"; |
|
|
21 | } |
|
|
22 | |
|
|
23 | my $fh = aio_open "$LOCALDIR/userlisting.html", O_WRONLY | O_CREAT | O_TRUNC, 0644 |
|
|
24 | or return; |
|
|
25 | aio_write $fh, 0, undef, $who, 0; |
|
|
26 | aio_close $fh; |
16 | } |
27 | }; |
17 | }; |
28 | }; |
18 | |
29 | |
19 | cf::player->attach ( |
30 | cf::player->attach ( |
20 | on_login => sub { |
31 | on_login => sub { |
21 | my ($pl) = @_; |
32 | my ($pl) = @_; |