1 |
cf::register_command ignore => 0, sub |
2 |
{ |
3 |
my ($who, $args) = @_; |
4 |
my ($target, $type, $timeout) = split /\s+/, $args, 4; |
5 |
my @ignored_players = split /\s+/, $who->{ignore}; |
6 |
|
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}})) { |
9 |
$who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); |
10 |
$who->message (join (", ", @ignored_tell ), cf::NDI_UNIQUE); |
11 |
$who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); |
12 |
$who->message (join (", ", @ignored_shout ), cf::NDI_UNIQUE); |
13 |
$who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); |
14 |
} else { |
15 |
$who->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
16 |
} |
17 |
} elsif ($target ne "" && $type ne "") { |
18 |
if ($timeout eq "") { |
19 |
$timeout = 24; |
20 |
} |
21 |
my $absolute_timeout = time + ( $timeout * 3600 ); |
22 |
if (my $other = cf::player::find $target) { |
23 |
if ($type eq "tell") { |
24 |
$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; |
26 |
} elsif ($type eq "shout") { |
27 |
$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; |
29 |
} elsif ($type eq "all") { |
30 |
$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; |
32 |
$who->{ext_ignore_shout}{$other->ob->name} = $absolute_timeout; |
33 |
} else { |
34 |
$who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
35 |
} |
36 |
} else { |
37 |
$who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
38 |
} |
39 |
} else { |
40 |
$who->message ("Usage:", cf::NDI_UNIQUE); |
41 |
$who->message ("ignore <player> <tell | shout | all> <timeout>", cf::NDI_UNIQUE); |
42 |
$who->message ("will ignore a player for <timeout> hours.", cf::NDI_UNIQUE); |
43 |
$who->message ("ignore list", cf::NDI_UNIQUE); |
44 |
$who->message ("will show you a list of players currently ignored.", cf::NDI_UNIQUE); |
45 |
} |
46 |
} |