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

Comparing deliantra/maps/perl/ignore.ext (file contents):
Revision 1.2 by pippijn, Sat May 6 20:04:48 2006 UTC vs.
Revision 1.3 by root, Sat May 6 21:05:07 2006 UTC

1#! perl
2
1cf::register_command ignore => 0, sub 3cf::register_command ignore => 0, sub {
2{
3 my ($who, $args) = @_; 4 my ($who, $args) = @_;
4 my ($target, $type, $timeout) = split /\s+/, $args, 4; 5 my ($target, $type, $timeout) = split /\s+/, $args;
5 my @ignored_players = split /\s+/, $who->{ignore};
6 6
7 if ($args eq "list") { 7 if ($args eq "list") {
8 if ((my @ignored_tell = sort keys %{$who->{ext_ignore_tell}}) + (my @ignored_shout = sort keys %{$who->{ext_ignore_shout}})) { 8 if ((my @ignored_tell = sort keys %{$who->{ext_ignore_tell}})
9 + (my @ignored_shout = sort keys %{$who->{ext_ignore_shout}})) {
9 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 10 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE);
10 $who->message (join (", ", @ignored_tell ), cf::NDI_UNIQUE); 11 $who->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE);
11 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 12 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE);
12 $who->message (join (", ", @ignored_shout ), cf::NDI_UNIQUE); 13 $who->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE);
13 $who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); 14 $who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE);
14 } else { 15 } else {
15 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); 16 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE);
16 } 17 }
18
17 } elsif ($target ne "" && $type ne "") { 19 } elsif ($target && $type) {
18 if ($timeout eq "") { 20
19 $timeout = 24; 21 $timeout ne "" or $timeout = 24;
20 } 22
21 my $absolute_timeout = time + ( $timeout * 3600 ); 23 my $absolute_timeout = time + $timeout * 3600;
24
22 if (my $other = cf::player::find $target) { 25 if (my $other = cf::player::find $target) {
23 if ($type eq "tell") { 26 if ($type eq "tell") {
24 $who->message ("Now ignoring private messages from ".$other->ob->name." for $timeout hours.", cf::NDI_UNIQUE); 27 $who->message ("Now ignoring private messages from " . $other->ob->name . " for $timeout hours.", cf::NDI_UNIQUE);
25 $who->{ext_ignore_tell}{$other->ob->name} = $absolute_timeout; 28 $who->{ext_ignore_tell}{$other->ob->name} = $absolute_timeout;
26 } elsif ($type eq "shout") { 29 } elsif ($type eq "shout") {
27 $who->message ("Now ignoring shouts from ".$other->ob->name." for $timeout hours.", cf::NDI_UNIQUE); 30 $who->message ("Now ignoring shouts from " . $other->ob->name . " for $timeout hours.", cf::NDI_UNIQUE);
28 $who->{ext_ignore_shout}{$other->ob->name} = $absolute_timeout; 31 $who->{ext_ignore_shout}{$other->ob->name} = $absolute_timeout;
29 } elsif ($type eq "all") { 32 } elsif ($type eq "all") {
30 $who->message ("Now ignoring everything from ".$other->ob->name." for $timeout hours.", cf::NDI_UNIQUE); 33 $who->message ("Now ignoring everything from " . $other->ob->name . " for $timeout hours.", cf::NDI_UNIQUE);
31 $who->{ext_ignore_tell}{$other->ob->name} = $absolute_timeout; 34 $who->{ext_ignore_tell}{$other->ob->name} = $absolute_timeout;
32 $who->{ext_ignore_shout}{$other->ob->name} = $absolute_timeout; 35 $who->{ext_ignore_shout}{$other->ob->name} = $absolute_timeout;
33 } else { 36 } else {
34 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 37 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE);
35 } 38 }
36 } else { 39 } else {
37 $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); 40 $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE);
38 } 41 }
42
39 } else { 43 } else {
40 $who->message ("Usage:", cf::NDI_UNIQUE); 44 $who->message ("Usage:", cf::NDI_UNIQUE);
41 $who->message ("ignore <player> <tell | shout | all> <timeout>", cf::NDI_UNIQUE); 45 $who->message ("ignore <player> <tell | shout | all> <timeout>", cf::NDI_UNIQUE);
42 $who->message ("will ignore a player for <timeout> hours.", cf::NDI_UNIQUE); 46 $who->message ("will ignore a player for <timeout> hours.", cf::NDI_UNIQUE);
43 $who->message ("ignore list", cf::NDI_UNIQUE); 47 $who->message ("ignore list", cf::NDI_UNIQUE);
45 } 49 }
46}; 50};
47 51
48cf::register_command unignore => 0, sub { 52cf::register_command unignore => 0, sub {
49 my ($who, $args) = @_; 53 my ($who, $args) = @_;
50 my ($target, $type) = split /\s+/, $args, 3; 54 my ($target, $type) = split /\s+/, $args;
51 my @ignored_players = split /\s+/, $who->{ignore};
52 55
53 if ($args eq "") { 56 if ($args eq "") {
54 if ($who->{ ext_ignore_tell }) { 57 if ($who->{ ext_ignore_tell }) {
55 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 58 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE);
56 $who->message (join (", ", sort keys %{ $who->{ ext_ignore_tell } } ), cf::NDI_UNIQUE); 59 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_tell} }), cf::NDI_UNIQUE);
57 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 60 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE);
58 $who->message (join (", ", sort keys %{ $who->{ ext_ignore_shout } } ), cf::NDI_UNIQUE); 61 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE);
59 } else { 62 } else {
60 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); 63 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE);
61 } 64 }
62 } else { 65 } else {
66
63 if (my $other = cf::player::find $target) { 67 if (my $other = cf::player::find $target) {
64 if ($type eq "tell") { 68 if ($type eq "tell") {
65 $who->message ("Not ignoring private messages from ".$other->ob->name." anymore.", cf::NDI_UNIQUE); 69 $who->message ("Not ignoring private messages from " . $other->ob->name . " anymore.", cf::NDI_UNIQUE);
66 delete $who->{ext_ignore_tell}{$other->ob->name}; 70 delete $who->{ext_ignore_tell}{$other->ob->name};
67 } elsif ($type eq "shout") { 71 } elsif ($type eq "shout") {
68 $who->message ("Not ignoring shouts from ".$other->ob->name." anymore.", cf::NDI_UNIQUE); 72 $who->message ("Not ignoring shouts from " . $other->ob->name." anymore . ", cf::NDI_UNIQUE);
69 delete $who->{ext_ignore_shout}{$other->ob->name}; 73 delete $who->{ext_ignore_shout}{$other->ob->name};
70 } elsif ($type eq "all") { 74 } elsif ($type eq "all") {
71 $who->message ("Not ignoring anything from ".$other->ob->name." anymore.", cf::NDI_UNIQUE); 75 $who->message ("Not ignoring anything from " . $other->ob->name." anymore . ", cf::NDI_UNIQUE);
72 delete $who->{ext_ignore_tell}{$other->ob->name}; 76 delete $who->{ext_ignore_tell} {$other->ob->name};
73 delete $who->{ext_ignore_shout}{$other->ob->name}; 77 delete $who->{ext_ignore_shout}{$other->ob->name};
74 } else { 78 } else {
75 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 79 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE);
76 } 80 }
77 } else { 81 } else {
78 $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); 82 $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE);
79 } 83 }
84
80 } 85 }
81}; 86};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines