1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | use Time::HiRes; |
3 | use Time::HiRes; |
4 | use Net::IRC3::Client::Connection; |
4 | use Net::IRC3::Client::Connection; |
|
|
5 | |
|
|
6 | # requires: commands.ext |
5 | |
7 | |
6 | my $BOTSERVER = 'localhost'; |
8 | my $BOTSERVER = 'localhost'; |
7 | my $BOTPORT = '6667'; |
9 | my $BOTPORT = '6667'; |
8 | my $BOTNAME = 'cfbot'; |
10 | my $BOTNAME = 'cfbot'; |
9 | my $BOTCHAN = '#cf'; |
11 | my $BOTCHAN = '#cf'; |
… | |
… | |
23 | |
25 | |
24 | sub handle_fcmd { |
26 | sub handle_fcmd { |
25 | my ($name, $me, $msg) = @_; |
27 | my ($name, $me, $msg) = @_; |
26 | |
28 | |
27 | if ($msg eq "!who") { |
29 | if ($msg eq "!who") { |
28 | my ($numplayers, $numwiz, @plist) = (0, 0); |
30 | $CON->send_chan ($BOTCHAN, NOTICE => $_, $BOTCHAN) |
|
|
31 | for ext::commands::who_listing (); |
29 | |
32 | |
30 | foreach my $pl (cf::player::list) { |
|
|
31 | $numplayers++; |
|
|
32 | $numwiz++ |
|
|
33 | if ($pl->ob->flag (cf::FLAG_WIZ)); |
|
|
34 | push (@plist, $pl); |
|
|
35 | } |
|
|
36 | |
|
|
37 | $CON->send_chan ($BOTCHAN, NOTICE => "Total Players in The World. ($numplayers) -- WIZ($numwiz)", $BOTCHAN); |
|
|
38 | |
|
|
39 | if ($numplayers > 0) { |
|
|
40 | foreach my $pl (@plist) { |
|
|
41 | $CON->send_chan ($BOTCHAN, NOTICE => |
|
|
42 | "* " . $pl->ob->name . "/" . $pl->ob->level . " " . ( length $pl->own_title ? $pl->own_title : "the " . $pl->title ) . " " |
|
|
43 | .($pl->ob->flag (cf::FLAG_WIZ) ? " [WIZ] " : "") |
|
|
44 | ." [" . ($pl->ob->map ? $pl->ob->map->path : "NULL") . "]", $BOTCHAN); |
|
|
45 | } |
|
|
46 | } |
|
|
47 | } elsif ($msg =~ /^\!tell/) { |
33 | } elsif ($msg =~ /^\!tell/) { |
48 | my (undef, $target, $tmsg) = split / /, $msg, 3; |
34 | my (undef, $target, $tmsg) = split / /, $msg, 3; |
49 | |
35 | |
50 | if (my $other = cf::player::find $target) { |
36 | if (my $other = cf::player::find $target) { |
51 | |
37 | |