ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/ignore.ext
Revision: 1.4
Committed: Sun May 7 08:10:23 2006 UTC (18 years ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +0 -0 lines
State: FILE REMOVED
Log Message:
combined chat/Shout/tell/reply/ignore/unignore into a single extension

File Contents

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