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.42 by root, Fri Aug 29 02:07:09 2008 UTC vs.
Revision 1.46 by root, Thu Dec 18 02:49:22 2008 UTC

54cf::player->attach ( 54cf::player->attach (
55 prio => -1000, 55 prio => -1000,
56 on_login => sub { 56 on_login => sub {
57 my ($pl) = @_; 57 my ($pl) = @_;
58 58
59 cf::async {
59 clean_timeouts $pl->ob; 60 clean_timeouts $pl->ob;
61 };
60 62
61 $pl->send_msg ($cf::SAY_CHANNEL); 63 $pl->send_msg ($cf::SAY_CHANNEL);
62 $pl->send_msg ($cf::CHAT_CHANNEL); 64 $pl->send_msg ($cf::CHAT_CHANNEL);
63 }, 65 },
64); 66);
148 self => { 150 self => {
149 }, 151 },
150 }, 152 },
151 scream => { 153 scream => {
152 noparams => { 154 noparams => {
153 other => "<self> screams at the top of his lungs!", 155 other => "<self> screams at the top of G<his|her> lungs!",
154 self => "ARRRRRRRRRRGH!!!!!", 156 self => "ARRRRRRRRRRGH!!!!!",
155 }, 157 },
156 params => { 158 params => {
157 }, 159 },
158 self => { 160 self => {
167 target => "<self> pukes on your clothes!", 169 target => "<self> pukes on your clothes!",
168 other => "<self> pukes on <other>.", 170 other => "<self> pukes on <other>.",
169 self => "You puke on <other>.", 171 self => "You puke on <other>.",
170 }, 172 },
171 self => { 173 self => {
172 other => "<self> pukes on his clothes.", 174 other => "<self> pukes on G<his|her> clothes.",
173 self => "You puke on yourself.", 175 self => "You puke on yourself.",
174 }, 176 },
175 }, 177 },
176 strut => { 178 strut => {
177 noparams => { 179 noparams => {
250 target => "<self> winks at you.", 252 target => "<self> winks at you.",
251 other => "<self> winks at <other>.", 253 other => "<self> winks at <other>.",
252 self => "You wink suggestively at <other>.", 254 self => "You wink suggestively at <other>.",
253 }, 255 },
254 self => { 256 self => {
255 other => "<self> winks at himself - something strange is going on...", 257 other => "<self> winks at G<him|her>self - something strange is going on...",
256 self => "You wink at yourself?? What are you up to?", 258 self => "You wink at yourself?? What are you up to?",
257 }, 259 },
258 }, 260 },
259 pout => { 261 pout => {
260 noparams => { 262 noparams => {
266 self => { 268 self => {
267 }, 269 },
268 }, 270 },
269 cackle => { 271 cackle => {
270 noparams => { 272 noparams => {
271 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!",
272 self => "You cackle gleefully.", 274 self => "You cackle gleefully.",
273 }, 275 },
274 params => { 276 params => {
275 }, 277 },
276 self => { 278 self => {
285 target => "<self> sniffs you.", 287 target => "<self> sniffs you.",
286 other => "<self> sniffs <other>", 288 other => "<self> sniffs <other>",
287 self => "You sniff <other>.", 289 self => "You sniff <other>.",
288 }, 290 },
289 self => { 291 self => {
290 other => "<self> sniffs himself.", 292 other => "<self> sniffs G<him|her>self.",
291 self => "You sniff yourself.", 293 self => "You sniff yourself.",
292 }, 294 },
293 }, 295 },
294 nod => { 296 nod => {
295 noparams => { 297 noparams => {
296 other => "<self> nods solemnly.", 298 other => "<self> nods solemnly.",
297 self => "You nod solemnly.", 299 self => "You nod solemnly.",
298 }, 300 },
299 params => { 301 params => {
300 target => "<self> nods solemnly to you.", 302 target => "<self> nods solemnly at you.",
301 other => "<self> nods solemnly to <other>.", 303 other => "<self> nods solemnly at <other>.",
302 self => "You nod solemnly to <other>.", 304 self => "You nod solemnly at <other>.",
303 }, 305 },
304 self => { 306 self => {
305 }, 307 },
306 }, 308 },
307 frown => { 309 frown => {
313 target => "<self> frowns darkly at you.", 315 target => "<self> frowns darkly at you.",
314 other => "<self> frowns darkly at <other>.", 316 other => "<self> frowns darkly at <other>.",
315 self => "You frown darkly at <other>.", 317 self => "You frown darkly at <other>.",
316 }, 318 },
317 self => { 319 self => {
318 other => "<self> frowns at himself.", 320 other => "<self> frowns at G<him|her>self.",
319 self => "You frown at yourself.", 321 self => "You frown at yourself.",
320 }, 322 },
321 }, 323 },
322 snicker => { 324 snicker => {
323 noparams => { 325 noparams => {
346 noparams => { 348 noparams => {
347 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?",
348 self => "You bleed all over your nice new armour.", 350 self => "You bleed all over your nice new armour.",
349 }, 351 },
350 params => { 352 params => {
351 target => "<self> slashes his wrist and bleeds all over you.", 353 target => "<self> slashes G<his|her> wrist and bleeds all over you.",
352 other => "<self> slashes his wrist and bleeds all over <other>.", 354 other => "<self> slashes G<his|her> wrist and bleeds all over <other>.",
353 self => "You slash your wrist and bleed all over <other>", 355 self => "You slash your wrist and bleed all over <other>",
354 }, 356 },
355 self => { 357 self => {
356 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.",
357 self => "Very impressive! You wipe your blood all over yourself.", 359 self => "Very impressive! You wipe your blood all over yourself.",
358 }, 360 },
359 }, 361 },
360 twiddle => { 362 twiddle => {
361 noparams => { 363 noparams => {
362 other => "<self> patiently twiddles his thumbs.", 364 other => "<self> patiently twiddles G<his|her> thumbs.",
363 self => "You patiently twiddle your thumbs.", 365 self => "You patiently twiddle your thumbs.",
364 }, 366 },
365 params => { 367 params => {
366 }, 368 },
367 self => { 369 self => {
368 }, 370 },
369 }, 371 },
370 spit => { 372 spit => {
371 noparams => { 373 noparams => {
372 other => "<self> spits over his left shoulder.", 374 other => "<self> spits over G<his|her> left shoulder.",
373 self => "You spit over your left shoulder.", 375 self => "You spit over your left shoulder.",
374 }, 376 },
375 params => { 377 params => {
376 target => "<self> spits in your face!", 378 target => "<self> spits in your face!",
377 other => "<self> spits in <other>'s face.", 379 other => "<self> spits in <other>'s face.",
378 self => "You spit on <other>.", 380 self => "You spit on <other>.",
379 }, 381 },
380 self => { 382 self => {
381 other => "<self> drools all over himself.", 383 other => "<self> drools all over G<him|her>self.",
382 self => "You drool all over yourself.", 384 self => "You drool all over yourself.",
383 }, 385 },
384 }, 386 },
385 glare => { 387 glare => {
386 noparams => { 388 noparams => {
387 other => "<self> glares around him.", 389 other => "<self> glares around G<him|her>.",
388 self => "You glare at nothing in particular.", 390 self => "You glare at nothing in particular.",
389 }, 391 },
390 params => { 392 params => {
391 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.",
392 other => "<self> glares at <other>.", 394 other => "<self> glares at <other>.",
393 self => "You glare icily at <other>.", 395 self => "You glare icily at <other>.",
394 }, 396 },
395 self => { 397 self => {
396 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>?",
397 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.",
398 }, 400 },
399 }, 401 },
400 bow => { 402 bow => {
401 noparams => { 403 noparams => {
406 target => "<self> bows before you.", 408 target => "<self> bows before you.",
407 other => "<self> bows before <other>.", 409 other => "<self> bows before <other>.",
408 self => "You bow before <other>.", 410 self => "You bow before <other>.",
409 }, 411 },
410 self => { 412 self => {
411 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.",
412 self => "You kiss your toes.", 414 self => "You kiss your toes.",
413 }, 415 },
414 }, 416 },
415 dance => { 417 dance => {
416 noparams => { 418 noparams => {
417 other => "<self> expresses himself through interpretive dance.", 419 other => "<self> expresses G<him|her>self through interpretive dance.",
418 self => "You dance with glee.", 420 self => "You dance with glee.",
419 }, 421 },
420 params => { 422 params => {
421 target => "<self> grabs you, and begins dancing!", 423 target => "<self> grabs you, and begins dancing!",
422 other => "Yipe! <self> and <other> are doing the Macarena!", 424 other => "Yipe! <self> and <other> are doing the Macarena!",
423 self => "You grab <other> and begin doing the Cha-Cha!", 425 self => "You grab <other> and begin doing the Cha-Cha!",
424 }, 426 },
425 self => { 427 self => {
426 other => "<self> embraces himself and begins to dance!", 428 other => "<self> embraces G<him|her>self and begins to dance!",
427 self => "You skip and dance around by yourself.", 429 self => "You skip and dance around by yourself.",
428 }, 430 },
429 }, 431 },
430 snore => { 432 snore => {
431 noparams => { 433 noparams => {
447 self => { 449 self => {
448 }, 450 },
449 }, 451 },
450 snap => { 452 snap => {
451 noparams => { 453 noparams => {
452 other => "<self> snaps his fingers.", 454 other => "<self> snaps G<his|her> fingers.",
453 self => "PRONTO! you snap your fingers.", 455 self => "PRONTO! you snap your fingers.",
454 }, 456 },
455 params => { 457 params => {
456 }, 458 },
457 self => { 459 self => {
466 target => "<self> waves goodbye to you. Have a good journey.", 468 target => "<self> waves goodbye to you. Have a good journey.",
467 other => "<self> waves goodbye to <other>.", 469 other => "<self> waves goodbye to <other>.",
468 self => "You wave goodbye to <other>.", 470 self => "You wave goodbye to <other>.",
469 }, 471 },
470 self => { 472 self => {
471 other => "<self> waves goodbye to himself.", 473 other => "<self> waves goodbye to G<him|her>self.",
472 self => "Are you going on adventures as well??", 474 self => "Are you going on adventures as well??",
473 }, 475 },
474 }, 476 },
475 smile => { 477 smile => {
476 noparams => { 478 noparams => {
490 other => "<self> sneezes.", 492 other => "<self> sneezes.",
491 self => "Gesundheit!", 493 self => "Gesundheit!",
492 }, 494 },
493 params => { 495 params => {
494 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.",
495 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>.",
496 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>.",
497 }, 499 },
498 self => { 500 self => {
499 other => "<self> sneezes, and covers himself in a slimy substance.", 501 other => "<self> sneezes, and covers G<him|her>self in a slimy substance.",
500 self => "You sneeze on yourself, what a mess!", 502 self => "You sneeze on yourself, what a mess!",
501 }, 503 },
502 }, 504 },
503 bounce => { 505 bounce => {
504 noparams => { 506 noparams => {
513 self => { 515 self => {
514 }, 516 },
515 }, 517 },
516 shake => { 518 shake => {
517 noparams => { 519 noparams => {
518 other => "<self> shakes his head.", 520 other => "<self> shakes G<his|her> head.",
519 self => "You shake your head.", 521 self => "You shake your head.",
520 }, 522 },
521 params => { 523 params => {
522 target => "<self> shakes your hand.", 524 target => "<self> shakes your hand.",
523 other => "<self> shakes <other>'s hand.", 525 other => "<self> shakes <other>'s hand.",
528 self => "You are shaken by yourself.", 530 self => "You are shaken by yourself.",
529 }, 531 },
530 }, 532 },
531 lick => { 533 lick => {
532 noparams => { 534 noparams => {
533 other => "<self> licks his mouth and smiles.", 535 other => "<self> licks G<his|her> mouth and smiles.",
534 self => "You lick your mouth and smile.", 536 self => "You lick your mouth and smile.",
535 }, 537 },
536 params => { 538 params => {
537 target => "<self> licks you.", 539 target => "<self> licks you.",
538 other => "<self> licks <other>.", 540 other => "<self> licks <other>.",
539 self => "You lick <other>.", 541 self => "You lick <other>.",
540 }, 542 },
541 self => { 543 self => {
542 other => "<self> licks himself - YUCK.", 544 other => "<self> licks G<him|her>self - YUCK.",
543 self => "You lick yourself.", 545 self => "You lick yourself.",
544 }, 546 },
545 }, 547 },
546 flip => { 548 flip => {
547 noparams => { 549 noparams => {
553 self => { 555 self => {
554 }, 556 },
555 }, 557 },
556 think => { 558 think => {
557 noparams => { 559 noparams => {
558 other => "<self> closes his eyes and thinks really hard.", 560 other => "<self> closes G<his|her> eyes and thinks really hard.",
559 self => "Anything in particular that you'd care to think about?", 561 self => "Anything in particular that you'd care to think about?",
560 }, 562 },
561 params => { 563 params => {
562 }, 564 },
563 self => { 565 self => {
627 target => "<self> cries on your shoulder.", 629 target => "<self> cries on your shoulder.",
628 other => "<self> cries on <other>'s shoulder.", 630 other => "<self> cries on <other>'s shoulder.",
629 self => "You cry on <other>'s shoulder.", 631 self => "You cry on <other>'s shoulder.",
630 }, 632 },
631 self => { 633 self => {
632 other => "<self> sobs quietly to himself.", 634 other => "<self> sobs quietly to G<him|her>self.",
633 self => "You cry to yourself.", 635 self => "You cry to yourself.",
634 }, 636 },
635 }, 637 },
636 sulk => { 638 sulk => {
637 noparams => { 639 noparams => {
651 params => { 653 params => {
652 target => "<self> whistles at <other>.", 654 target => "<self> whistles at <other>.",
653 self => "You whistle at <other>.", 655 self => "You whistle at <other>.",
654 }, 656 },
655 self => { 657 self => {
656 other => "<self> whistles to himself in boredom.", 658 other => "<self> whistles to G<him|her>self in boredom.",
657 self => "You whistle while you work.", 659 self => "You whistle while you work.",
658 }, 660 },
659 }, 661 },
660 groan => { 662 groan => {
661 noparams => { 663 noparams => {
707 709
708 $emote{other} ||= "You look away from <self>."; 710 $emote{other} ||= "You look away from <self>.";
709 $emote{self} ||= "My god! Is that LEGAL?"; 711 $emote{self} ||= "My god! Is that LEGAL?";
710 712
711 $emote{other} =~ s/<self>/$name/; 713 $emote{other} =~ s/<self>/$name/;
714
715 $_ = $pl->expand_cfpod ($_)
716 for values %emote;
712 717
713 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" 718 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
714 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; 719 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list;
715 720
716 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 721 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
717 } elsif ($tname) { 722 } elsif ($tname) {
718 my $target = cf::player::find $tname 723 my $target = cf::player::find $tname
719 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat"; 724 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat";
720 725
721 my %emote = %{ $emotes->{$emotion}->{params} || {} }; 726 my %emote = %{ $emotes->{$emotion}->{params} || {} };
727 $emote{self} =~ s/<other>/$tname/; 732 $emote{self} =~ s/<other>/$tname/;
728 $emote{target} =~ s/<self>/$name/; 733 $emote{target} =~ s/<self>/$name/;
729 $emote{other} =~ s/<other>/$tname/; 734 $emote{other} =~ s/<other>/$tname/;
730 $emote{other} =~ s/<self>/$name/; 735 $emote{other} =~ s/<self>/$name/;
731 736
737 $_ = $pl->expand_cfpod ($_)
738 for values %emote;
739
732 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" 740 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
733 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; 741 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list;
734 742
735 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY, "msg_shout"; 743 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_shout";
736 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 744 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
737 } else { 745 } else {
738 my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; 746 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
739 747
740 $emote{other} ||= "<self> dances with glee."; 748 $emote{other} ||= "<self> dances with glee.";
741 $emote{self} ||= "You are a nut."; 749 $emote{self} ||= "You are a nut.";
742 750
743 $emote{other} =~ s/<self>/$name/; 751 $emote{other} =~ s/<self>/$name/;
744 752
753 $_ = $pl->expand_cfpod ($_)
754 for values %emote;
755
745 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" 756 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
746 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; 757 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list;
747 758
748 $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 759 $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
749 } 760 }
750 }; 761 };
751 }; 762 };
752} 763}
753 764
794 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; 805 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc;
795 my ($reply, @kw) = $dialog->tell ($msg); 806 my ($reply, @kw) = $dialog->tell ($msg);
796 807
797 if (defined $reply) { 808 if (defined $reply) {
798 if ($npc->type == cf::MAGIC_EAR) { 809 if ($npc->type == cf::MAGIC_EAR) {
799 if (length $reply) {
800 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" 810 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
801 for @plonmap; 811 for @plonmap;
802 }
803 $npc->use_trigger;
804 } else { 812 } else {
805 if (length $reply) {
806 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" 813 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
807 for @plonmap; 814 for @plonmap;
808 }
809 } 815 }
810 } 816 }
811 817
812 if (@kw) { 818 if (@kw) {
813 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) 819 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
835 841
836 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 842 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
837 send_irc ("[%s] %s", $name, $msg); 843 send_irc ("[%s] %s", $name, $msg);
838 844
839 send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" 845 send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat"
840 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;
841 847
842 } else { 848 } else {
843 $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); 849 $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
844 } 850 }
845}; 851};
859 865
860 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 866 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
861 send_irc ("\007\0034{%s} %s\n", $name, $msg); 867 send_irc ("\007\0034{%s} %s\n", $name, $msg);
862 868
863 send_msg $_, $cf::CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout" 869 send_msg $_, $cf::CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout"
864 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;
865 871
866 } else { 872 } else {
867 $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); 873 $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY);
868 } 874 }
869}; 875};
914 920
915cf::register_command ignore => sub { 921cf::register_command ignore => sub {
916 my ($pl, $args) = @_; 922 my ($pl, $args) = @_;
917 my ($target, $type, $timeout) = split /\s+/, $args; 923 my ($target, $type, $timeout) = split /\s+/, $args;
918 924
925 cf::async {
919 if ($args eq "list") { 926 if ($args eq "list") {
920 clean_timeouts $pl; 927 clean_timeouts $pl;
921 928
922 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) 929 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}})
923 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { 930 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) {
924 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); 931 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
925 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); 932 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY);
926 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); 933 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
927 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); 934 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY);
928 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); 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
929 } else { 962 } else {
930 $pl->message ("Not ignoring anyone", cf::NDI_REPLY); 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);
931 } 967 }
932
933 } elsif ($target && $type) {
934
935 $timeout ne "" or $timeout = 24;
936 my $absolute_timeout = time + $timeout * 3600;
937
938 if (cf::player::exists $target) {
939 if ($type eq "tell") {
940 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY);
941 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
942 } elsif ($type eq "shout") {
943 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY);
944 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
945 } elsif ($type eq "all") {
946 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY);
947 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
948 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
949 } else {
950 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
951 }
952 } else {
953 $pl->message ("No such player: $target", cf::NDI_REPLY);
954 }
955
956 } else {
957 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
958 . "will ignore a player for <timeout> hours.\n"
959 . "Usage: ignore list\n"
960 . "will show you a list of players currently ignored.", cf::NDI_REPLY);
961 } 968 };
962}; 969};
963 970
964cf::register_command unignore => sub { 971cf::register_command unignore => sub {
965 my ($pl, $args) = @_; 972 my ($pl, $args) = @_;
966 my ($target, $type) = split /\s+/, $args; 973 my ($target, $type) = split /\s+/, $args;
967 974
975 cf::async {
968 if ($args eq "") { 976 if ($args eq "") {
969 if ($pl->{ext_ignore_tell}) { 977 if ($pl->{ext_ignore_tell}) {
970 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); 978 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
971 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); 979 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY);
972 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); 980 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
973 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); 981 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY);
974 } else {
975 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
976 }
977 } else {
978 if (cf::player::exists $target) {
979 if ($type eq "tell") {
980 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY);
981 delete $pl->{ext_ignore_tell} {$target};
982 } elsif ($type eq "shout") {
983 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY);
984 delete $pl->{ext_ignore_shout}{$target};
985 } elsif ($type eq "all") {
986 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY);
987 delete $pl->{ext_ignore_tell} {$target};
988 delete $pl->{ext_ignore_shout}{$target};
989 } else { 982 } else {
990 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); 983 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
991 } 984 }
992 } 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 {
993 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); 1001 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY);
1002 }
994 } 1003 }
995 } 1004 };
996}; 1005};
997 1006

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines