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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines