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.11 by pippijn, Sun Sep 17 22:56:52 2006 UTC vs.
Revision 1.14 by pippijn, Thu Sep 21 14:49:36 2006 UTC

20 $CON->send_chan ($BOTCHAN, NOTICE => $msg, $BOTCHAN) 20 $CON->send_chan ($BOTCHAN, NOTICE => $msg, $BOTCHAN)
21 if $CON; 21 if $CON;
22} 22}
23 23
24sub handle_fcmd { 24sub handle_fcmd {
25 my ($msg) = @_; 25 my ($name, $me, $msg) = @_;
26 26
27 if ($msg eq "!who") { 27 if ($msg eq "!who") {
28 my ($numplayers, $numwiz, @plist) = (0, 0); 28 my ($numplayers, $numwiz, @plist) = (0, 0);
29 29
30 foreach my $pl (cf::player::list) { 30 foreach my $pl (cf::player::list) {
37 $CON->send_chan ($BOTCHAN, NOTICE => "Total Players in The World. ($numplayers) -- WIZ($numwiz)", $BOTCHAN); 37 $CON->send_chan ($BOTCHAN, NOTICE => "Total Players in The World. ($numplayers) -- WIZ($numwiz)", $BOTCHAN);
38 38
39 if ($numplayers > 0) { 39 if ($numplayers > 0) {
40 foreach my $pl (@plist) { 40 foreach my $pl (@plist) {
41 $CON->send_chan ($BOTCHAN, NOTICE => 41 $CON->send_chan ($BOTCHAN, NOTICE =>
42 "* " . $pl->ob->name . "/" . $pl->ob->level . ($pl->ob->flag (cf::FLAG_WIZ) ? " [WIZ] " : "") 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] " : "")
43 ." [" . ($pl->ob->map ? $pl->ob->map->path : "NULL") . "]", $BOTCHAN); 44 ." [" . ($pl->ob->map ? $pl->ob->map->path : "NULL") . "]", $BOTCHAN);
44 } 45 }
46 }
47 } elsif ($msg =~ /^\!tell/) {
48 my (undef, $target, $tmsg) = split / /, $msg, 3;
49
50 if (my $other = cf::player::find $target) {
51
52 if ($tmsg) {
53 if ($me eq $target) {
54 $CON->send_chan ($BOTCHAN, NOTICE => "$me: You are talking to yourself, you freak!", $BOTCHAN);
55 } elsif ($other->ob->{ext_ignore_tell}{$me} >= time) {
56 $CON->send_chan ($BOTCHAN, NOTICE => "$me: $target ignores what you say. Give up on it.", $BOTCHAN);
57 } else {
58 utf8::encode $tmsg; # ->message not yet utf8-ified
59 cf::LOG cf::llevDebug, sprintf "TELL [%s/%s>%s] %s\n", $name, $me, $target, $tmsg;
60
61 $other->ob->message ("$name/$me tells you: $tmsg");
62 $other->ob->{ext_last_tell} = "$name/$me";
63 }
64 } else {
65 $CON->send_chan ($BOTCHAN, NOTICE => "$me: What do you want to tell $target?", cf::NDI_UNIQUE);
66 }
67
45 } 68 }
46 } 69 }
47} 70}
48 71
49sub check_connection { 72sub check_connection {
56 $CON->reg_cb ( 79 $CON->reg_cb (
57 #d# 'irc_*' => sub { warn "IRC $_[1]->{trailing}\n"; 1 }, 80 #d# 'irc_*' => sub { warn "IRC $_[1]->{trailing}\n"; 1 },
58 irc_privmsg => sub { 81 irc_privmsg => sub {
59 my ($con, $msg) = @_; 82 my ($con, $msg) = @_;
60 my $name = 'irc'; 83 my $name = 'irc';
84 my $nick = Net::IRC3::Util::prefix_nick ($msg);
61 my $NOW = Time::HiRes::time; 85 my $NOW = Time::HiRes::time;
62 my $tmsg = $msg->{trailing}; 86 my $tmsg = $msg->{trailing};
63 $tmsg =~ s/\x01[^\x01]*\x01//g; 87 $tmsg =~ s/\x01[^\x01]*\x01//g;
64 if ($tmsg =~ /^\!/) { 88 if ($tmsg =~ /^\!/) {
65 handle_fcmd ($tmsg); 89 handle_fcmd ($name, $nick, $tmsg);
66 } elsif ($tmsg =~ m/\S/) { 90 } elsif ($tmsg =~ m/\S/) {
67 $_->ob->message ( 91 $_->ob->message (
68 "$name/".Net::IRC3::Util::prefix_nick ($msg)." chats: $tmsg", cf::NDI_BLUE 92 "$name/".$nick." chats: $tmsg", cf::NDI_BLUE
69 ) for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 93 ) for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
70 } 94 }
71 1; 95 1;
72 }, 96 },
73# registered => sub { 97# registered => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines