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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines