ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/schmorp-irc.ext
(Generate patch)

Comparing deliantra/maps/perl/schmorp-irc.ext (file contents):
Revision 1.8 by root, Fri Aug 25 17:08:20 2006 UTC vs.
Revision 1.9 by pippijn, Sun Sep 17 22:48:03 2006 UTC

3use Time::HiRes; 3use Time::HiRes;
4use Net::IRC3::Client::Connection; 4use Net::IRC3::Client::Connection;
5 5
6my $BOTSERVER = 'localhost'; 6my $BOTSERVER = 'localhost';
7my $BOTPORT = '6667'; 7my $BOTPORT = '6667';
8my $BOTNAME = 'cfbot'; 8my $BOTNAME = 'cfbot2';
9my $BOTCHAN = '#cf'; 9my $BOTCHAN = '#cf';
10 10
11my $CON; # the connection 11my $CON; # the connection
12 12
13sub unload { 13sub unload {
17 17
18sub do_notice { 18sub do_notice {
19 my ($msg) = @_; 19 my ($msg) = @_;
20 $CON->send_chan ($BOTCHAN, NOTICE => $msg, $BOTCHAN) 20 $CON->send_chan ($BOTCHAN, NOTICE => $msg, $BOTCHAN)
21 if $CON; 21 if $CON;
22}
23
24sub handle_fcmd {
25 my ($msg) = @_;
26
27 if ($msg eq "!who") {
28 my ($numplayers, $numwiz, @plist) = (0, 0);
29
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
43 ." [" . ($pl->ob->map ? $pl->ob->map->path : "NULL") . "]", $BOTCHAN);
44 }
45 }
46 }
22} 47}
23 48
24sub check_connection { 49sub check_connection {
25 return if $CON; 50 return if $CON;
26 51
34 my ($con, $msg) = @_; 59 my ($con, $msg) = @_;
35 my $name = 'irc'; 60 my $name = 'irc';
36 my $NOW = Time::HiRes::time; 61 my $NOW = Time::HiRes::time;
37 my $tmsg = $msg->{trailing}; 62 my $tmsg = $msg->{trailing};
38 $tmsg =~ s/\x01[^\x01]*\x01//g; 63 $tmsg =~ s/\x01[^\x01]*\x01//g;
39 if ($tmsg =~ m/\S/) { 64 if ($tmsg =~ /^\!/) {
65 handle_fcmd ($tmsg);
66 } elsif ($tmsg =~ m/\S/) {
40 $_->ob->message ( 67 $_->ob->message (
41 "$name/".Net::IRC3::Util::prefix_nick ($msg)." chats: $tmsg", 68 "$name/".Net::IRC3::Util::prefix_nick ($msg)." chats: $tmsg", cf::NDI_BLUE
42 cf::NDI_BLUE
43 ) for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 69 ) for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
44 } 70 }
45 1; 71 1;
46 }, 72 },
47# registered => sub { 73# registered => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines