… | |
… | |
2 | |
2 | |
3 | # implement a replacement for the built-in say/chat/shout/tell/reply commands |
3 | # implement a replacement for the built-in say/chat/shout/tell/reply commands |
4 | # adds ignore/unignore functionality |
4 | # adds ignore/unignore functionality |
5 | |
5 | |
6 | use NPC_Dialogue; |
6 | use NPC_Dialogue; |
|
|
7 | use POSIX (); # for strftime only |
7 | |
8 | |
8 | sub clean_timeouts($) { |
9 | sub clean_timeouts($) { |
9 | my ($player) = @_; |
10 | my ($player) = @_; |
10 | my $NOW = time; |
11 | my $NOW = time; |
11 | |
12 | |
… | |
… | |
225 | } else { |
226 | } else { |
226 | $who->message ("No such player: $target", cf::NDI_UNIQUE); |
227 | $who->message ("No such player: $target", cf::NDI_UNIQUE); |
227 | } |
228 | } |
228 | |
229 | |
229 | } else { |
230 | } else { |
230 | $who->message ("Usage: ignore <player> <tell | shout | all> <timeout>\n" |
231 | $who->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
231 | . "will ignore a player for <timeout> hours.\n" |
232 | . "will ignore a player for <timeout> hours.\n" |
232 | . "Usage: ignore list\n" |
233 | . "Usage: ignore list\n" |
233 | . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); |
234 | . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); |
234 | } |
235 | } |
235 | }; |
236 | }; |
… | |
… | |
246 | $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE); |
247 | $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE); |
247 | } else { |
248 | } else { |
248 | $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
249 | $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
249 | } |
250 | } |
250 | } else { |
251 | } else { |
251 | |
|
|
252 | if (cf::player::exists $target) { |
252 | if (cf::player::exists $target) { |
253 | if ($type eq "tell") { |
253 | if ($type eq "tell") { |
254 | $who->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); |
254 | $who->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); |
255 | delete $who->{ext_ignore_tell} {$target}; |
255 | delete $who->{ext_ignore_tell} {$target}; |
256 | } elsif ($type eq "shout") { |
256 | } elsif ($type eq "shout") { |
… | |
… | |
264 | $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
264 | $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
265 | } |
265 | } |
266 | } else { |
266 | } else { |
267 | $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
267 | $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
268 | } |
268 | } |
269 | |
|
|
270 | } |
269 | } |
271 | }; |
270 | }; |
272 | |
271 | |
|
|
272 | cf::register_command seen => 0, sub { |
|
|
273 | my ($who, $args) = @_; |
|
|
274 | |
|
|
275 | if (my ($login) = $args =~ /(\S+)/) { |
|
|
276 | if (cf::player::find $login) { |
|
|
277 | $who->message ("$login is right here on this server!", cf::NDI_UNIQUE); |
|
|
278 | } elsif (cf::player::exists $login |
|
|
279 | and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { |
|
|
280 | my $time = (stat _)[9]; |
|
|
281 | |
|
|
282 | $who->message ("$login was last seen here on " |
|
|
283 | . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) |
|
|
284 | . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); |
|
|
285 | } else { |
|
|
286 | $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE); |
|
|
287 | } |
|
|
288 | } else { |
|
|
289 | $who->message ("Usage: seen <player>", cf::NDI_UNIQUE); |
|
|
290 | } |
|
|
291 | }; |
|
|
292 | |