--- deliantra/server/ext/chat.ext 2008/09/19 01:39:45 1.44 +++ deliantra/server/ext/chat.ext 2008/09/23 00:24:52 1.45 @@ -56,7 +56,9 @@ on_login => sub { my ($pl) = @_; - clean_timeouts $pl->ob; + cf::async { + clean_timeouts $pl->ob; + }; $pl->send_msg ($cf::SAY_CHANNEL); $pl->send_msg ($cf::CHAT_CHANNEL); @@ -925,82 +927,85 @@ my ($pl, $args) = @_; my ($target, $type, $timeout) = split /\s+/, $args; - if ($args eq "list") { - clean_timeouts $pl; - - if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) - + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { - $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); - $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); - $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); - $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); - $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); - } else { - $pl->message ("Not ignoring anyone", cf::NDI_REPLY); - } - - } elsif ($target && $type) { - - $timeout ne "" or $timeout = 24; - my $absolute_timeout = time + $timeout * 3600; - - if (cf::player::exists $target) { - if ($type eq "tell") { - $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY); - $pl->{ext_ignore_tell}{$target} = $absolute_timeout; - } elsif ($type eq "shout") { - $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY); - $pl->{ext_ignore_shout}{$target} = $absolute_timeout; - } elsif ($type eq "all") { - $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY); - $pl->{ext_ignore_tell}{$target} = $absolute_timeout; - $pl->{ext_ignore_shout}{$target} = $absolute_timeout; + cf::async { + if ($args eq "list") { + clean_timeouts $pl; + + if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) + + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { + $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); + $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); + $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); + $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); + $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); } else { - $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); + $pl->message ("Not ignoring anyone", cf::NDI_REPLY); } + + } elsif ($target && $type) { + $timeout ne "" or $timeout = 24; + my $absolute_timeout = time + $timeout * 3600; + + if (cf::player::exists $target) { + if ($type eq "tell") { + $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY); + $pl->{ext_ignore_tell}{$target} = $absolute_timeout; + } elsif ($type eq "shout") { + $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY); + $pl->{ext_ignore_shout}{$target} = $absolute_timeout; + } elsif ($type eq "all") { + $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY); + $pl->{ext_ignore_tell}{$target} = $absolute_timeout; + $pl->{ext_ignore_shout}{$target} = $absolute_timeout; + } else { + $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); + } + } else { + $pl->message ("No such player: $target", cf::NDI_REPLY); + } + } else { - $pl->message ("No such player: $target", cf::NDI_REPLY); + $pl->message ("Usage: ignore \n" + . "will ignore a player for hours.\n" + . "Usage: ignore list\n" + . "will show you a list of players currently ignored.", cf::NDI_REPLY); } - - } else { - $pl->message ("Usage: ignore \n" - . "will ignore a player for hours.\n" - . "Usage: ignore list\n" - . "will show you a list of players currently ignored.", cf::NDI_REPLY); - } + }; }; cf::register_command unignore => sub { my ($pl, $args) = @_; my ($target, $type) = split /\s+/, $args; - if ($args eq "") { - if ($pl->{ext_ignore_tell}) { - $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); - $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); - $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); - $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); - } else { - $pl->message ("Not ignoring anyone", cf::NDI_REPLY); - } - } else { - if (cf::player::exists $target) { - if ($type eq "tell") { - $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY); - delete $pl->{ext_ignore_tell} {$target}; - } elsif ($type eq "shout") { - $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY); - delete $pl->{ext_ignore_shout}{$target}; - } elsif ($type eq "all") { - $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY); - delete $pl->{ext_ignore_tell} {$target}; - delete $pl->{ext_ignore_shout}{$target}; + cf::async { + if ($args eq "") { + if ($pl->{ext_ignore_tell}) { + $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); + $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); + $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); + $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); } else { - $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); + $pl->message ("Not ignoring anyone", cf::NDI_REPLY); } } else { - $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); + if (cf::player::exists $target) { + if ($type eq "tell") { + $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY); + delete $pl->{ext_ignore_tell} {$target}; + } elsif ($type eq "shout") { + $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY); + delete $pl->{ext_ignore_shout}{$target}; + } elsif ($type eq "all") { + $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY); + delete $pl->{ext_ignore_tell} {$target}; + delete $pl->{ext_ignore_shout}{$target}; + } else { + $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); + } + } else { + $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); + } } - } + }; };