ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/chat.ext
(Generate patch)

Comparing deliantra/server/ext/chat.ext (file contents):
Revision 1.12 by pippijn, Fri Mar 2 00:29:08 2007 UTC vs.
Revision 1.44 by root, Fri Sep 19 01:39:45 2008 UTC

1#! perl 1#! perl # depends=irc mandatory
2#CONVERSION: PARTIAL
3 2
4# 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 commands
5# adds ignore/unignore functionality 4# adds ignore/unignore functionality
6 5
7use NPC_Dialogue; 6use NPC_Dialogue;
8use POSIX (); # for strftime only 7use POSIX (); # for strftime only
8
9sub tell_channel($) {
10 my ($target) = @_;
11
12 {
13 id => "tell-$target",
14 title => "$target",
15 reply => "tell $target ",
16 tooltip => "Private messages from/to $target",
17 }
18}
19
20sub send_msg($$$$$) {
21 my ($pl, $channel, $msg, $flags, $sound) = @_;
22 $pl->play_sound (cf::sound::find $sound) if defined $sound;
23 $pl->send_msg ($channel, $msg, $flags);
24 ()
25}
9 26
10sub clean_timeouts($) { 27sub clean_timeouts($) {
11 my ($player) = @_; 28 my ($player) = @_;
12 my $NOW = time; 29 my $NOW = time;
13 30
14 for my $hash (@$player{qw(ext_ignore_shout ext_ignore_tell)}) { 31 for my $hash (@$player{qw(ext_ignore_shout ext_ignore_tell)}) {
15 while (my ($k, $v) = each %$hash) { 32 while (my ($k, $v) = each %$hash) {
16 if ($v < $NOW) { 33 if ($v < $NOW) {
17 $player->message ("Your ignore on $k has expired.", cf::NDI_GREEN | cf::NDI_UNIQUE); 34 $player->message ("Your ignore on $k has expired.", cf::NDI_GREEN);
18 delete $hash->{$k}; 35 delete $hash->{$k};
19 } elsif (!cf::player::exists $k) { 36 } elsif (!cf::player::exists $k) {
20 $player->message ("Your ignore on $k is no longer valid (no such user).", cf::NDI_GREEN | cf::NDI_UNIQUE); 37 $player->message ("Your ignore on $k is no longer valid (no such user).", cf::NDI_GREEN);
21 delete $hash->{$k}; 38 delete $hash->{$k};
22 } 39 }
23 } 40 }
24 } 41 }
25} 42}
26 43
44# send_irc ($format, @args, $msg)
45# make sure the last argument is the message!
46sub send_irc {
47 my ($format, @args) = @_;
48 my $msg = pop @args;
49 for (split /\n/, $msg) {
50 ext::irc::do_notice (sprintf $format, @args, $_)
51 }
52}
53
27cf::player->attach ( 54cf::player->attach (
28 prio => -1000, 55 prio => -1000,
29 on_login => sub { 56 on_login => sub {
30 my ($pl) = @_; 57 my ($pl) = @_;
31 58
32 clean_timeouts $pl->ob; 59 clean_timeouts $pl->ob;
60
61 $pl->send_msg ($cf::SAY_CHANNEL);
62 $pl->send_msg ($cf::CHAT_CHANNEL);
33 }, 63 },
34); 64);
35 65
66# TODO: remove once safe
36cf::register_command listen => sub { 67cf::register_command listen => sub {
37 my ($pl, $msg) = @_;
38 my $player = cf::player::find_active $pl->name;
39
40 if ($msg ne "") {
41 my $prev_listen = $player->listening;
42 $player->listening ($msg);
43 if ($prev_listen == $player->listening) {
44 $pl->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE);
45 } else {
46 $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE);
47 }
48 } else {
49 $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE);
50 }
51}; 68};
52 69
53cf::register_command cointoss => sub { 70cf::register_command cointoss => sub {
54 my ($pl, $msg) = @_; 71 my ($ob, $msg) = @_;
55 72
73 my $pl = $ob->contr;
56 my $name = $pl->name; 74 my $name = $ob->name;
57 75
58 if (int rand 2) { 76 my $coin = int rand 2 ? "Heads" : "Tails";
77
78 send_msg $_, $cf::SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say"
59 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { 79 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
60 next
61 if $other->ob == $pl;
62 $other->ob->message ("$name flips a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE);
63 }
64
65 $pl->message ("You flip a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE);
66 } else {
67 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
68 next
69 if $other->ob == $pl;
70 $other->ob->message ("$name flips a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE);
71 }
72
73 $pl->message ("You flip a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE);
74 } 80
81 $pl->send_msg ($cf::SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY);
75}; 82};
76 83
77cf::register_command orcknuckle => sub { 84cf::register_command orcknuckle => sub {
78 my ($pl, $msg) = @_; 85 my ($ob, $msg) = @_;
86
87 my $pl = $ob->contr;
88 my $name = $ob->name;
89
79 my @orcknuckle = ("none", "beholder", "ghost", "knight", "princess", "dragon", "orc"); 90 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc");
80 91 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6);
81 my $name = $pl->name;
82
83 my ($i, $j, $k, $l) = ((int rand 5) + 1, (int rand 5) + 1, (int rand 5) + 1, (int rand 6) + 1);
84 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; 92 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
85 93
94 send_msg $_, $cf::SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say"
86 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { 95 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
87 next
88 if $other->ob == $pl;
89 $other->ob->message ("$name rolls $result!", cf::NDI_GREY | cf::NDI_UNIQUE);
90 } 96
91
92 $pl->message ("You roll $result!", cf::NDI_GREY | cf::NDI_UNIQUE); 97 $pl->send_msg ($cf::SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY);
93}; 98};
94 99
95my $emotes = { 100my $emotes = {
96 growl => { 101 growl => {
97 noparams => { 102 noparams => {
143 self => { 148 self => {
144 }, 149 },
145 }, 150 },
146 scream => { 151 scream => {
147 noparams => { 152 noparams => {
148 other => "<self> screams at the top of his lungs!", 153 other => "<self> screams at the top of G<his|her> lungs!",
149 self => "ARRRRRRRRRRGH!!!!!", 154 self => "ARRRRRRRRRRGH!!!!!",
150 }, 155 },
151 params => { 156 params => {
152 }, 157 },
153 self => { 158 self => {
162 target => "<self> pukes on your clothes!", 167 target => "<self> pukes on your clothes!",
163 other => "<self> pukes on <other>.", 168 other => "<self> pukes on <other>.",
164 self => "You puke on <other>.", 169 self => "You puke on <other>.",
165 }, 170 },
166 self => { 171 self => {
167 other => "<self> pukes on his clothes.", 172 other => "<self> pukes on G<his|her> clothes.",
168 self => "You puke on yourself.", 173 self => "You puke on yourself.",
169 }, 174 },
170 }, 175 },
171 strut => { 176 strut => {
172 noparams => { 177 noparams => {
221 self => "You kiss <other>.", 226 self => "You kiss <other>.",
222 }, 227 },
223 self => { 228 self => {
224 }, 229 },
225 }, 230 },
231 smother => {
232 noparams => {
233 other => "<self> makes weird facial contortions",
234 self => "All the lonely people..",
235 },
236 params => {
237 target => "<self> smothers you with kisses.",
238 other => "<self> smothers <other> with kisses.",
239 self => "You smother <other> with kisses.",
240 },
241 self => {
242 },
243 },
226 wink => { 244 wink => {
227 noparams => { 245 noparams => {
228 other => "<self> winks suggestively.", 246 other => "<self> winks suggestively.",
229 self => "Have you got something in your eye?", 247 self => "Have you got something in your eye?",
230 }, 248 },
232 target => "<self> winks at you.", 250 target => "<self> winks at you.",
233 other => "<self> winks at <other>.", 251 other => "<self> winks at <other>.",
234 self => "You wink suggestively at <other>.", 252 self => "You wink suggestively at <other>.",
235 }, 253 },
236 self => { 254 self => {
237 other => "<self> winks at himself - something strange is going on...", 255 other => "<self> winks at G<him|her>self - something strange is going on...",
238 self => "You wink at yourself?? What are you up to?", 256 self => "You wink at yourself?? What are you up to?",
239 }, 257 },
240 }, 258 },
241 pout => { 259 pout => {
242 noparams => { 260 noparams => {
248 self => { 266 self => {
249 }, 267 },
250 }, 268 },
251 cackle => { 269 cackle => {
252 noparams => { 270 noparams => {
253 other => "<self> throws back his head and cackles with insane glee!", 271 other => "<self> throws back G<his|her> head and cackles with insane glee!",
254 self => "You cackle gleefully.", 272 self => "You cackle gleefully.",
255 }, 273 },
256 params => { 274 params => {
257 }, 275 },
258 self => { 276 self => {
267 target => "<self> sniffs you.", 285 target => "<self> sniffs you.",
268 other => "<self> sniffs <other>", 286 other => "<self> sniffs <other>",
269 self => "You sniff <other>.", 287 self => "You sniff <other>.",
270 }, 288 },
271 self => { 289 self => {
272 other => "<self> sniffs himself.", 290 other => "<self> sniffs G<him|her>self.",
273 self => "You sniff yourself.", 291 self => "You sniff yourself.",
274 }, 292 },
275 }, 293 },
276 nod => { 294 nod => {
277 noparams => { 295 noparams => {
278 other => "<self> nods solemnly.", 296 other => "<self> nods solemnly.",
279 self => "You nod solemnly.", 297 self => "You nod solemnly.",
280 }, 298 },
281 params => { 299 params => {
282 target => "<self> nods solemnly to you.", 300 target => "<self> nods solemnly at you.",
283 other => "<self> nods solemnly to <other>.", 301 other => "<self> nods solemnly at <other>.",
284 self => "You nod solemnly to <other>.", 302 self => "You nod solemnly at <other>.",
285 }, 303 },
286 self => { 304 self => {
287 }, 305 },
288 }, 306 },
289 frown => { 307 frown => {
295 target => "<self> frowns darkly at you.", 313 target => "<self> frowns darkly at you.",
296 other => "<self> frowns darkly at <other>.", 314 other => "<self> frowns darkly at <other>.",
297 self => "You frown darkly at <other>.", 315 self => "You frown darkly at <other>.",
298 }, 316 },
299 self => { 317 self => {
300 other => "<self> frowns at himself.", 318 other => "<self> frowns at G<him|her>self.",
301 self => "You frown at yourself.", 319 self => "You frown at yourself.",
302 }, 320 },
303 }, 321 },
304 snicker => { 322 snicker => {
305 noparams => { 323 noparams => {
328 noparams => { 346 noparams => {
329 other => "<self> is bleeding all over the carpet - got a spare tourniquet?", 347 other => "<self> is bleeding all over the carpet - got a spare tourniquet?",
330 self => "You bleed all over your nice new armour.", 348 self => "You bleed all over your nice new armour.",
331 }, 349 },
332 params => { 350 params => {
333 target => "<self> slashes his wrist and bleeds all over you.", 351 target => "<self> slashes G<his|her> wrist and bleeds all over you.",
334 other => "<self> slashes his wrist and bleeds all over <other>.", 352 other => "<self> slashes G<his|her> wrist and bleeds all over <other>.",
335 self => "You slash your wrist and bleed all over <other>", 353 self => "You slash your wrist and bleed all over <other>",
336 }, 354 },
337 self => { 355 self => {
338 other => "<self> performs some satanic ritual while wiping his blood on himself.", 356 other => "<self> performs some satanic ritual while wiping G<his|her> blood on G<him|her>self.",
339 self => "Very impressive! You wipe your blood all over yourself.", 357 self => "Very impressive! You wipe your blood all over yourself.",
340 }, 358 },
341 }, 359 },
342 twiddle => { 360 twiddle => {
343 noparams => { 361 noparams => {
344 other => "<self> patiently twiddles his thumbs.", 362 other => "<self> patiently twiddles G<his|her> thumbs.",
345 self => "You patiently twiddle your thumbs.", 363 self => "You patiently twiddle your thumbs.",
346 }, 364 },
347 params => { 365 params => {
348 }, 366 },
349 self => { 367 self => {
350 }, 368 },
351 }, 369 },
352 spit => { 370 spit => {
353 noparams => { 371 noparams => {
354 other => "<self> spits over his left shoulder.", 372 other => "<self> spits over G<his|her> left shoulder.",
355 self => "You spit over your left shoulder.", 373 self => "You spit over your left shoulder.",
356 }, 374 },
357 params => { 375 params => {
358 target => "<self> spits in your face!", 376 target => "<self> spits in your face!",
359 other => "<self> spits in <other>'s face.", 377 other => "<self> spits in <other>'s face.",
360 self => "You spit on <other>.", 378 self => "You spit on <other>.",
361 }, 379 },
362 self => { 380 self => {
363 other => "<self> drools all over himself.", 381 other => "<self> drools all over G<him|her>self.",
364 self => "You drool all over yourself.", 382 self => "You drool all over yourself.",
365 }, 383 },
366 }, 384 },
367 glare => { 385 glare => {
368 noparams => { 386 noparams => {
369 other => "<self> glares around him.", 387 other => "<self> glares around G<him|her>.",
370 self => "You glare at nothing in particular.", 388 self => "You glare at nothing in particular.",
371 }, 389 },
372 params => { 390 params => {
373 target => "<self> glares icily at you, you feel cold to your bones.", 391 target => "<self> glares icily at you, you feel cold to your bones.",
374 other => "<self> glares at <other>.", 392 other => "<self> glares at <other>.",
375 self => "You glare icily at <other>.", 393 self => "You glare icily at <other>.",
376 }, 394 },
377 self => { 395 self => {
378 other => "<self> glares at his feet, what is bothering him?", 396 other => "<self> glares at G<his|her> feet, what is bothering G<him|her>?",
379 self => "You glare icily at your feet, they are suddenly very cold.", 397 self => "You glare icily at your feet, they are suddenly very cold.",
380 }, 398 },
381 }, 399 },
382 bow => { 400 bow => {
383 noparams => { 401 noparams => {
388 target => "<self> bows before you.", 406 target => "<self> bows before you.",
389 other => "<self> bows before <other>.", 407 other => "<self> bows before <other>.",
390 self => "You bow before <other>.", 408 self => "You bow before <other>.",
391 }, 409 },
392 self => { 410 self => {
393 other => "<self> folds up like a jackknife and kisses his own toes.", 411 other => "<self> folds up like a jackknife and kisses G<his|her> own toes.",
394 self => "You kiss your toes.", 412 self => "You kiss your toes.",
395 }, 413 },
396 }, 414 },
397 dance => { 415 dance => {
398 noparams => { 416 noparams => {
399 other => "<self> expresses himself through interpretive dance.", 417 other => "<self> expresses G<him|her>self through interpretive dance.",
400 self => "You dance with glee.", 418 self => "You dance with glee.",
401 }, 419 },
402 params => { 420 params => {
403 target => "<self> grabs you, and begins dancing!", 421 target => "<self> grabs you, and begins dancing!",
404 other => "Yipe! <self> and <other> are doing the Macarena!", 422 other => "Yipe! <self> and <other> are doing the Macarena!",
405 self => "You grab <other> and begin doing the Cha-Cha!", 423 self => "You grab <other> and begin doing the Cha-Cha!",
406 }, 424 },
407 self => { 425 self => {
408 other => "<self> embraces himself and begins to dance!", 426 other => "<self> embraces G<him|her>self and begins to dance!",
409 self => "You skip and dance around by yourself.", 427 self => "You skip and dance around by yourself.",
410 }, 428 },
411 }, 429 },
412 snore => { 430 snore => {
413 noparams => { 431 noparams => {
429 self => { 447 self => {
430 }, 448 },
431 }, 449 },
432 snap => { 450 snap => {
433 noparams => { 451 noparams => {
434 other => "<self> snaps his fingers.", 452 other => "<self> snaps G<his|her> fingers.",
435 self => "PRONTO! you snap your fingers.", 453 self => "PRONTO! you snap your fingers.",
436 }, 454 },
437 params => { 455 params => {
438 }, 456 },
439 self => { 457 self => {
448 target => "<self> waves goodbye to you. Have a good journey.", 466 target => "<self> waves goodbye to you. Have a good journey.",
449 other => "<self> waves goodbye to <other>.", 467 other => "<self> waves goodbye to <other>.",
450 self => "You wave goodbye to <other>.", 468 self => "You wave goodbye to <other>.",
451 }, 469 },
452 self => { 470 self => {
453 other => "<self> waves goodbye to himself.", 471 other => "<self> waves goodbye to G<him|her>self.",
454 self => "Are you going on adventures as well??", 472 self => "Are you going on adventures as well??",
455 }, 473 },
456 }, 474 },
457 smile => { 475 smile => {
458 noparams => { 476 noparams => {
472 other => "<self> sneezes.", 490 other => "<self> sneezes.",
473 self => "Gesundheit!", 491 self => "Gesundheit!",
474 }, 492 },
475 params => { 493 params => {
476 target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.", 494 target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.",
477 other => "<self> sneezes on <other> and a film of snot covers him.", 495 other => "<self> sneezes on <other> and a film of snot covers G<him|her>.",
478 self => "You sneeze at <other> and a film of snot shoots onto him.", 496 self => "You sneeze at <other> and a film of snot shoots onto G<him|her>.",
479 }, 497 },
480 self => { 498 self => {
481 other => "<self> sneezes, and covers himself in a slimy substance.", 499 other => "<self> sneezes, and covers G<him|her>self in a slimy substance.",
482 self => "You sneeze on yourself, what a mess!", 500 self => "You sneeze on yourself, what a mess!",
483 }, 501 },
484 }, 502 },
485 bounce => { 503 bounce => {
486 noparams => { 504 noparams => {
495 self => { 513 self => {
496 }, 514 },
497 }, 515 },
498 shake => { 516 shake => {
499 noparams => { 517 noparams => {
500 other => "<self> shakes his head.", 518 other => "<self> shakes G<his|her> head.",
501 self => "You shake your head.", 519 self => "You shake your head.",
502 }, 520 },
503 params => { 521 params => {
504 target => "<self> shakes your hand.", 522 target => "<self> shakes your hand.",
505 other => "<self> shakes <other>'s hand.", 523 other => "<self> shakes <other>'s hand.",
510 self => "You are shaken by yourself.", 528 self => "You are shaken by yourself.",
511 }, 529 },
512 }, 530 },
513 lick => { 531 lick => {
514 noparams => { 532 noparams => {
515 other => "<self> licks his mouth and smiles.", 533 other => "<self> licks G<his|her> mouth and smiles.",
516 self => "You lick your mouth and smile.", 534 self => "You lick your mouth and smile.",
517 }, 535 },
518 params => { 536 params => {
519 target => "<self> licks you.", 537 target => "<self> licks you.",
520 other => "<self> licks <other>.", 538 other => "<self> licks <other>.",
521 self => "You lick <other>.", 539 self => "You lick <other>.",
522 }, 540 },
523 self => { 541 self => {
524 other => "<self> licks himself - YUCK.", 542 other => "<self> licks G<him|her>self - YUCK.",
525 self => "You lick yourself.", 543 self => "You lick yourself.",
526 }, 544 },
527 }, 545 },
528 flip => { 546 flip => {
529 noparams => { 547 noparams => {
535 self => { 553 self => {
536 }, 554 },
537 }, 555 },
538 think => { 556 think => {
539 noparams => { 557 noparams => {
540 other => "<self> closes his eyes and thinks really hard.", 558 other => "<self> closes G<his|her> eyes and thinks really hard.",
541 self => "Anything in particular that you'd care to think about?", 559 self => "Anything in particular that you'd care to think about?",
542 }, 560 },
543 params => { 561 params => {
544 }, 562 },
545 self => { 563 self => {
609 target => "<self> cries on your shoulder.", 627 target => "<self> cries on your shoulder.",
610 other => "<self> cries on <other>'s shoulder.", 628 other => "<self> cries on <other>'s shoulder.",
611 self => "You cry on <other>'s shoulder.", 629 self => "You cry on <other>'s shoulder.",
612 }, 630 },
613 self => { 631 self => {
614 other => "<self> sobs quietly to himself.", 632 other => "<self> sobs quietly to G<him|her>self.",
615 self => "You cry to yourself.", 633 self => "You cry to yourself.",
616 }, 634 },
617 }, 635 },
618 sulk => { 636 sulk => {
619 noparams => { 637 noparams => {
633 params => { 651 params => {
634 target => "<self> whistles at <other>.", 652 target => "<self> whistles at <other>.",
635 self => "You whistle at <other>.", 653 self => "You whistle at <other>.",
636 }, 654 },
637 self => { 655 self => {
638 other => "<self> whistles to himself in boredom.", 656 other => "<self> whistles to G<him|her>self in boredom.",
639 self => "You whistle while you work.", 657 self => "You whistle while you work.",
640 }, 658 },
641 }, 659 },
642 groan => { 660 groan => {
643 noparams => { 661 noparams => {
674 }, 692 },
675}; 693};
676 694
677for my $emotion (keys %$emotes) { 695for my $emotion (keys %$emotes) {
678 cf::register_command $emotion => sub { 696 cf::register_command $emotion => sub {
679 my ($pl, $tname) = @_; 697 my ($ob, $tname) = @_;
698
699 my $pl = $ob->contr;
680 700
681 cf::async { 701 cf::async {
682 my $name = $pl->name; 702 my $name = $ob->name;
703 $Coro::current->{desc} = "emote handler for $name";
683 704
684 if ($tname eq $name) { 705 if ($tname eq $name) {
685 my $emote = $emotes->{$emotion}->{self}; 706 my %emote = %{ $emotes->{$emotion}->{self} || {} };
686 707
687 $emote->{other} = "You look away from <self>." 708 $emote{other} ||= "You look away from <self>.";
688 if !$emote->{other};
689 $emote->{self} = "My god! Is that LEGAL?" 709 $emote{self} ||= "My god! Is that LEGAL?";
690 if !$emote->{self};
691 710
692 $emote->{other} =~ s/<self>/$name/; 711 $emote{other} =~ s/<self>/$name/;
712
713 $_ = $pl->expand_cfpod ($_)
714 for values %emote;
693 715
716 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
694 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { 717 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list;
695 next
696 if $other->ob == $pl;
697 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
698 }
699 718
700 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 719 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
701 } elsif ($tname) { 720 } elsif ($tname) {
702 my $target = cf::player::find $tname 721 my $target = cf::player::find $tname
703 or return $pl->reply (undef, "$tname is not around."); 722 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat";
704 723
705 my $emote = $emotes->{$emotion}->{params}; 724 my %emote = %{ $emotes->{$emotion}->{params} || {} };
706 725
707 $emote->{other} = "<self> is eyeing <other> quizzically." 726 $emote{other} ||= "<self> is eyeing <other> quizzically.";
708 if !$emote->{other};
709 $emote->{self} = "You are still nuts." 727 $emote{self} ||= "You are still nuts.";
710 if !$emote->{self};
711 $emote->{target} = "You get the distinct feeling that <other> is nuts." 728 $emote{target} ||= "You get the distinct feeling that <self> is nuts.";
712 if !$emote->{target};
713 729
714 $emote->{self} =~ s/<other>/$tname/; 730 $emote{self} =~ s/<other>/$tname/;
715 $emote->{target} =~ s/<self>/$name/; 731 $emote{target} =~ s/<self>/$name/;
716 $emote->{other} =~ s/<other>/$tname/; 732 $emote{other} =~ s/<other>/$tname/;
717 $emote->{other} =~ s/<self>/$name/; 733 $emote{other} =~ s/<self>/$name/;
718 734
719 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { 735 $_ = $pl->expand_cfpod ($_)
720 next 736 for values %emote;
721 if $other->ob == $pl or $other == $target;
722 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
723 }
724 737
725 $target->ob->message ($emote->{target}, cf::NDI_GREY | cf::NDI_UNIQUE); 738 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
726 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 739 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list;
740
741 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_shout";
742 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
727 } else { 743 } else {
728 my $emote = $emotes->{$emotion}->{noparams}; 744 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
729 $emote->{other} =~ s/<self>/$name/;
730 745
731 $emote->{other} = "<self> dances with glee." 746 $emote{other} ||= "<self> dances with glee.";
732 if !$emote->{other};
733 $emote->{self} = "You are a nut." 747 $emote{self} ||= "You are a nut.";
734 if !$emote->{self};
735 748
749 $emote{other} =~ s/<self>/$name/;
750
751 $_ = $pl->expand_cfpod ($_)
752 for values %emote;
753
754 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
736 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { 755 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list;
737 next
738 if $other->ob == $pl;
739 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
740 }
741 756
742 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 757 $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
743 } 758 }
744 }; 759 };
745 }; 760 };
746} 761}
747 762
748cf::register_command me => sub { 763cf::register_command me => sub {
749 my ($pl, $msg) = @_; 764 my ($pl, $msg) = @_;
750 765
751 my $name = $pl->name; 766 my $name = $pl->name;
752 767
753 $_->ob->message ("* $name $msg", cf::NDI_GREY | cf::NDI_UNIQUE) 768 send_msg $_, $cf::SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say"
754 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 769 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
755}; 770};
756 771
757cf::register_command say => sub { 772cf::register_command say => sub {
758 my ($pl, $msg) = @_; 773 my ($ob, $msg) = @_;
759 774
760 utf8::decode $msg; 775 utf8::decode $msg;
761 776
762 return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); 777 return if $ob->contr->invoke (cf::EVENT_PLAYER_SAY, $msg);
763 778
764 if ($msg) { 779 if ($msg) {
765 my $name = $pl->name; 780 my $name = $ob->name;
766
767 utf8::encode $msg; # ->message not yet utf8-ified
768 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
769 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 781 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
770 utf8::decode $msg; 782
783 send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say"
784 for grep $_ != $ob->contr, @plonmap;
785 $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY);
771 786
772 # npcs, magic_ears etc. 787 # npcs, magic_ears etc.
773 # first find all objects and theirt-level inventories 788 # first find all objects and their first-level inventories
774 # within a 5x5 square # that have something resembling 789 # within a 5x5 square that have something resembling
775 # dialogue or support on_say. 790 # dialogue or support on_say.
776 my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2); 791 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2);
777 792
778 for my $npc ( 793 for my $npc (
779 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 794 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || $_->has_dialogue,
780 map +($_, $_->inv), 795 map +($_, $_->inv),
781 grep $_, 796 grep $_,
782 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 797 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
783 0..24 798 0..24
784 ) { 799 ) {
785 # if some listener teleported us somewhere else, stop right here 800 # if some listener teleported us somewhere else, stop right here
786 last unless $map->path == $pl->map->path; 801 last unless $map->path == $ob->map->path;
787 802
788 my $dialog = new NPC_Dialogue ob => $pl, npc => $npc; 803 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc;
789 my ($reply, @kw) = $dialog->tell ($msg); 804 my ($reply, @kw) = $dialog->tell ($msg);
790 805
791 if (defined $reply) { 806 if (defined $reply) {
792 if ($npc->type == cf::MAGIC_EAR) { 807 if ($npc->type == cf::MAGIC_EAR) {
793 if (length $reply) { 808 if (length $reply) {
794 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) 809 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
795 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 810 for @plonmap;
796 } 811 }
797 $npc->use_trigger; 812 $npc->use_trigger;
798 } else { 813 } else {
799 if (length $reply) { 814 if (length $reply) {
800 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) 815 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
801 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 816 for @plonmap;
802 } 817 }
803 } 818 }
804 } 819 }
805 820
806 if (@kw) { 821 if (@kw) {
807 $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) 822 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
808 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 823 for @plonmap;
809 } 824 }
810 } 825 }
811 826
812 } else { 827 } else {
813 $pl->message ("What do you want to say?", cf::NDI_UNIQUE); 828 $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY);
814 } 829 }
815}; 830};
816 831
817cf::register_command chat => sub { 832cf::register_command chat => sub {
818 my ($pl, $msg) = @_; 833 my ($ob, $msg) = @_;
819 834
820 utf8::decode $msg; 835 utf8::decode $msg;
821 836
837 my $pl = $ob->contr;
838
822 return if $pl->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); 839 return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg);
823 840
824 if ($msg) { 841 if ($msg) {
825 my $name = $pl->name; 842 my $name = $ob->name;
826 my $NOW = time; 843 my $NOW = time;
827 844
828 utf8::encode $msg; # ->message not yet utf8-ified
829 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 845 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
830 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); 846 send_irc ("[%s] %s", $name, $msg);
831 847
832 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 848 send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat"
833 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 849 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
834 850
835 } else { 851 } else {
836 $pl->message ("Chat what?", cf::NDI_UNIQUE); 852 $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
837 } 853 }
838}; 854};
839 855
840cf::register_command shout => sub { 856cf::register_command shout => sub {
841 my ($pl, $msg) = @_; 857 my ($ob, $msg) = @_;
842 858
843 utf8::decode $msg; 859 utf8::decode $msg;
844 860
861 my $pl = $ob->contr;
862
845 return if $pl->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); 863 return if $pl->invoke (cf::EVENT_PLAYER_SHOUT, $msg);
846 864
847 if ($msg) { 865 if ($msg) {
848 my $NOW = time; 866 my $NOW = time;
849 my $name = $pl->name; 867 my $name = $ob->name;
850 868
851 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 869 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
852 ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); 870 send_irc ("\007\0034{%s} %s\n", $name, $msg);
853 871
854 utf8::encode $msg; # ->message not yet utf8-ified 872 send_msg $_, $cf::CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout"
855 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
856 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 873 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
857 874
858 } else { 875 } else {
859 $pl->message ("Shout what?", cf::NDI_UNIQUE); 876 $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY);
860 } 877 }
861}; 878};
862 879
863cf::register_command tell => sub { 880cf::register_command tell => sub {
864 my ($pl, $args) = @_; 881 my ($ob, $args) = @_;
865 my ($target, $msg) = split /\s+/, $args, 2; 882 my ($target, $msg) = split /\s+/, $args, 2;
866 883
867 utf8::decode $msg; 884 utf8::decode $msg;
868 885
886 my $pl = $ob->contr;
887 my $ns = $pl->ns
888 or return;
889 my $name = $ob->name;
890
869 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); 891 return if $pl->invoke (cf::EVENT_PLAYER_TELL, $target, $msg);
870 892
871 my $name = $pl->name; 893 my $pl_channel = tell_channel $target;
872 894
873 if ($target =~ /irc\//) { 895 if ($target =~ /irc\//) {
874 my (undef, $nick) = split /\//, $target, 2; 896 my (undef, $nick) = split /\//, $target, 2;
875 $pl->message ("You tell $target: $args"); 897 $ns->send_msg ($pl_channel => "You tell $target: $args", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
876 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); 898 send_irc ("(%s) %s: %s\n", $name, $nick, $msg);
899
877 } elsif (my $other = cf::player::find_active $target) { 900 } elsif (my $other = cf::player::find_active $target) {
901 my $other_channel = tell_channel $name;
878 902
879 if ($msg) { 903 if ($msg) {
880 if ($target eq $name) { 904 if ($target eq $name) {
881 $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); 905 $ns->send_msg ($pl_channel => "You are talking to yourself, you freak!", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
882 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 906 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
883 $pl->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); 907 $ns->send_msg ($pl_channel => "$target ignores what you say. Give up on it.", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
884 } else { 908 } else {
885 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl->contr, $msg); 909 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg);
886 utf8::encode $msg; # ->message not yet utf8-ified
887 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 910 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
888 911
889 $pl->message ("You tell $target: $msg"); 912 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
890 $other->ob->message ("$name tells you: $msg"); 913 send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell";
891 $other->ob->{ext_last_tell} = $name;
892 } 914 }
893 } else { 915 } else {
894 $pl->message ("What do you want to tell $target?", cf::NDI_UNIQUE); 916 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
895 } 917 }
896 918
897 } else { 919 } else {
898 $pl->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); 920 $ns->send_msg ($pl_channel => "No such player. Your message: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
899 }
900};
901
902cf::register_command reply => sub {
903 my ($pl, $args) = @_;
904 my $name = $pl->name;
905
906 utf8::decode $args;
907
908 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args);
909
910 if ($pl->{ext_last_tell} =~ /irc\//) {
911 my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2;
912 $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args");
913 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args);
914 } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) {
915
916 if ($args) {
917 $other->ob->{ext_ignore_tell}{$name} >= time
918 or delete $other->ob->{ext_ignore_tell}{$name};
919
920 if ($other->ob->{ext_ignore_tell}{$name} < time) {
921 utf8::encode $args; # ->message not yet utf8-ified
922 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args;
923
924 $pl->message ("You tell " . $other->ob->name . ": $args");
925 $other->ob->message ("$name tells you: $args");
926 $pl->{ext_last_tell} = $other->ob->name;
927 } else {
928 $pl->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE);
929 }
930 } else {
931 $pl->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE);
932 }
933
934 } else {
935 $pl->message ("Can't reply, player left. Your message: $args".$pl->{ext_last_tell}, cf::NDI_UNIQUE);
936 } 921 }
937}; 922};
938 923
939cf::register_command ignore => sub { 924cf::register_command ignore => sub {
940 my ($pl, $args) = @_; 925 my ($pl, $args) = @_;
943 if ($args eq "list") { 928 if ($args eq "list") {
944 clean_timeouts $pl; 929 clean_timeouts $pl;
945 930
946 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) 931 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}})
947 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { 932 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) {
948 $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 933 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
949 $pl->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE); 934 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY);
950 $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 935 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
951 $pl->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE); 936 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY);
952 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); 937 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY);
953 } else { 938 } else {
954 $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE); 939 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
955 } 940 }
956 941
957 } elsif ($target && $type) { 942 } elsif ($target && $type) {
958 943
959 $timeout ne "" or $timeout = 24; 944 $timeout ne "" or $timeout = 24;
960 my $absolute_timeout = time + $timeout * 3600; 945 my $absolute_timeout = time + $timeout * 3600;
961 946
962 if (cf::player::exists $target) { 947 if (cf::player::exists $target) {
963 if ($type eq "tell") { 948 if ($type eq "tell") {
964 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE); 949 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY);
965 $pl->{ext_ignore_tell}{$target} = $absolute_timeout; 950 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
966 } elsif ($type eq "shout") { 951 } elsif ($type eq "shout") {
967 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE); 952 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY);
968 $pl->{ext_ignore_shout}{$target} = $absolute_timeout; 953 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
969 } elsif ($type eq "all") { 954 } elsif ($type eq "all") {
970 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE); 955 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY);
971 $pl->{ext_ignore_tell}{$target} = $absolute_timeout; 956 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
972 $pl->{ext_ignore_shout}{$target} = $absolute_timeout; 957 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
973 } else { 958 } else {
974 $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 959 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
975 } 960 }
976 } else { 961 } else {
977 $pl->message ("No such player: $target", cf::NDI_UNIQUE); 962 $pl->message ("No such player: $target", cf::NDI_REPLY);
978 } 963 }
979 964
980 } else { 965 } else {
981 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" 966 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
982 . "will ignore a player for <timeout> hours.\n" 967 . "will ignore a player for <timeout> hours.\n"
983 . "Usage: ignore list\n" 968 . "Usage: ignore list\n"
984 . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); 969 . "will show you a list of players currently ignored.", cf::NDI_REPLY);
985 } 970 }
986}; 971};
987 972
988cf::register_command unignore => sub { 973cf::register_command unignore => sub {
989 my ($pl, $args) = @_; 974 my ($pl, $args) = @_;
990 my ($target, $type) = split /\s+/, $args; 975 my ($target, $type) = split /\s+/, $args;
991 976
992 if ($args eq "") { 977 if ($args eq "") {
993 if ($pl->{ext_ignore_tell}) { 978 if ($pl->{ext_ignore_tell}) {
994 $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 979 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
995 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_UNIQUE); 980 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY);
996 $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 981 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
997 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_UNIQUE); 982 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY);
998 } else { 983 } else {
999 $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE); 984 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
1000 } 985 }
1001 } else { 986 } else {
1002 if (cf::player::exists $target) { 987 if (cf::player::exists $target) {
1003 if ($type eq "tell") { 988 if ($type eq "tell") {
1004 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); 989 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY);
1005 delete $pl->{ext_ignore_tell} {$target}; 990 delete $pl->{ext_ignore_tell} {$target};
1006 } elsif ($type eq "shout") { 991 } elsif ($type eq "shout") {
1007 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE); 992 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY);
1008 delete $pl->{ext_ignore_shout}{$target}; 993 delete $pl->{ext_ignore_shout}{$target};
1009 } elsif ($type eq "all") { 994 } elsif ($type eq "all") {
1010 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE); 995 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY);
1011 delete $pl->{ext_ignore_tell} {$target}; 996 delete $pl->{ext_ignore_tell} {$target};
1012 delete $pl->{ext_ignore_shout}{$target}; 997 delete $pl->{ext_ignore_shout}{$target};
1013 } else { 998 } else {
1014 $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 999 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
1015 } 1000 }
1016 } else { 1001 } else {
1017 $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); 1002 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY);
1018 } 1003 }
1019 } 1004 }
1020}; 1005};
1021 1006
1022cf::register_command seen => sub {
1023 my ($pl, $args) = @_;
1024
1025 if (my ($login) = $args =~ /(\S+)/) {
1026 if ($login eq $pl->name) {
1027 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE);
1028 } elsif (cf::player::find_active $login) {
1029 $pl->message ("$login is right here on this server!", cf::NDI_UNIQUE);
1030 } elsif (cf::player::exists $login
1031 and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) {
1032 my $time = (stat _)[9];
1033
1034 $pl->message ("$login was last seen here "
1035 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
1036 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE);
1037 } else {
1038 $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE);
1039 }
1040 } else {
1041 $pl->message ("Usage: seen <player>", cf::NDI_UNIQUE);
1042 }
1043};
1044

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines