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 . ($pl->ob->flag (cf::FLAG_WIZ) ? " [WIZ] " : "") |
|
|
43 | ." [" . ($pl->ob->map ? $pl->ob->map->path : "NULL") . "]", $BOTCHAN); |
|
|
44 | } |
|
|
45 | } |
|
|
46 | } elsif ($msg =~ /^\!tell/) { |
33 | } elsif ($msg =~ /^\!tell/) { |
47 | my (undef, $target, $tmsg) = split / /, $msg, 3; |
34 | my (undef, $target, $tmsg) = split / /, $msg, 3; |
48 | |
35 | |
49 | if (my $other = cf::player::find $target) { |
36 | if (my $other = cf::player::find $target) { |
50 | |
37 | |
… | |
… | |
82 | my $name = 'irc'; |
69 | my $name = 'irc'; |
83 | my $nick = Net::IRC3::Util::prefix_nick ($msg); |
70 | my $nick = Net::IRC3::Util::prefix_nick ($msg); |
84 | my $NOW = Time::HiRes::time; |
71 | my $NOW = Time::HiRes::time; |
85 | my $tmsg = $msg->{trailing}; |
72 | my $tmsg = $msg->{trailing}; |
86 | $tmsg =~ s/\x01[^\x01]*\x01//g; |
73 | $tmsg =~ s/\x01[^\x01]*\x01//g; |
|
|
74 | $tmsg =~ s/\015?\012/ /g; |
87 | if ($tmsg =~ /^\!/) { |
75 | if ($tmsg =~ /^\!/) { |
88 | handle_fcmd ($name, $nick, $tmsg); |
76 | handle_fcmd ($name, $nick, $tmsg); |
89 | } elsif ($tmsg =~ m/\S/) { |
77 | } elsif ($tmsg =~ m/\S/) { |
90 | $_->ob->message ( |
78 | $_->ob->message ( |
91 | "$name/".$nick." chats: $tmsg", cf::NDI_BLUE |
79 | "$name/".$nick." chats: $tmsg", cf::NDI_BLUE |