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.6 by pippijn, Wed Feb 28 19:25:27 2007 UTC vs.
Revision 1.14 by root, Tue Apr 24 18:24:31 2007 UTC

29 on_login => sub { 29 on_login => sub {
30 my ($pl) = @_; 30 my ($pl) = @_;
31 31
32 clean_timeouts $pl->ob; 32 clean_timeouts $pl->ob;
33 }, 33 },
34
35 1
36); 34);
37 35
38cf::register_command listen => sub { 36cf::register_command listen => sub {
39 my ($who, $msg) = @_; 37 my ($pl, $msg) = @_;
40 my $player = cf::player::find_active $who->name; 38 my $player = cf::player::find_active $pl->name;
41 39
42 if ($msg ne "") { 40 if ($msg ne "") {
41 $msg = 10 if $msg > 10;
42
43 my $prev_listen = $player->listening; 43 my $prev_listen = $player->listening;
44 $player->listening ($msg); 44 $player->listening ($msg);
45 if ($prev_listen == $player->listening) { 45 if ($prev_listen == $player->listening) {
46 $who->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); 46 $pl->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE);
47 } else { 47 } else {
48 $who->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); 48 $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE);
49 } 49 }
50 } else { 50 } else {
51 $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); 51 $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE);
52 } 52 }
53};
53 54
55cf::register_command cointoss => sub {
56 my ($pl, $msg) = @_;
57
58 my $name = $pl->name;
59
60 if (int rand 2) {
61 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
62 next
63 if $other->ob == $pl;
64 $other->ob->message ("$name flips a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE);
65 }
66
67 $pl->message ("You flip a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE);
68 } else {
69 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
70 next
71 if $other->ob == $pl;
72 $other->ob->message ("$name flips a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE);
73 }
74
75 $pl->message ("You flip a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE);
54 1 76 }
77};
78
79cf::register_command orcknuckle => sub {
80 my ($pl, $msg) = @_;
81 my @orcknuckle = ("none", "beholder", "ghost", "knight", "princess", "dragon", "orc");
82
83 my $name = $pl->name;
84
85 my ($i, $j, $k, $l) = ((int rand 5) + 1, (int rand 5) + 1, (int rand 5) + 1, (int rand 6) + 1);
86 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
87
88 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
89 next
90 if $other->ob == $pl;
91 $other->ob->message ("$name rolls $result!", cf::NDI_GREY | cf::NDI_UNIQUE);
92 }
93
94 $pl->message ("You roll $result!", cf::NDI_GREY | cf::NDI_UNIQUE);
55}; 95};
56 96
57my $emotes = { 97my $emotes = {
58 growl => { 98 growl => {
59 noparams => { 99 noparams => {
189 noparams => { 229 noparams => {
190 other => "<self> winks suggestively.", 230 other => "<self> winks suggestively.",
191 self => "Have you got something in your eye?", 231 self => "Have you got something in your eye?",
192 }, 232 },
193 params => { 233 params => {
234 target => "<self> winks at you.",
194 target => "<self> winks at <other>.", 235 other => "<self> winks at <other>.",
195 self => "You wink suggestively at <other>.", 236 self => "You wink suggestively at <other>.",
196 }, 237 },
197 self => { 238 self => {
198 other => "<self> winks at himself - something strange is going on...", 239 other => "<self> winks at himself - something strange is going on...",
199 self => "You wink at yourself?? What are you up to?", 240 self => "You wink at yourself?? What are you up to?",
289 noparams => { 330 noparams => {
290 other => "<self> is bleeding all over the carpet - got a spare tourniquet?", 331 other => "<self> is bleeding all over the carpet - got a spare tourniquet?",
291 self => "You bleed all over your nice new armour.", 332 self => "You bleed all over your nice new armour.",
292 }, 333 },
293 params => { 334 params => {
335 target => "<self> slashes his wrist and bleeds all over you.",
294 target => "<self> slashes his wrist and bleeds all over <other>.", 336 other => "<self> slashes his wrist and bleeds all over <other>.",
295 self => "You slash your wrist and bleed all over <other>", 337 self => "You slash your wrist and bleed all over <other>",
296 }, 338 },
297 self => { 339 self => {
298 other => "<self> performs some satanic ritual while wiping his blood on himself.", 340 other => "<self> performs some satanic ritual while wiping his blood on himself.",
299 self => "Very impressive! You wipe your blood all over yourself.", 341 self => "Very impressive! You wipe your blood all over yourself.",
631 }, 673 },
632 self => { 674 self => {
633 }, 675 },
634 }, 676 },
635}; 677};
678
636for my $emotion (keys %$emotes) { 679for my $emotion (keys %$emotes) {
637 cf::register_command $emotion => sub { 680 cf::register_command $emotion => sub {
638 my ($ob, $tname) = @_; 681 my ($pl, $tname) = @_;
639 682
640 cf::async { 683 cf::async {
641 my $name = $ob->name; 684 my $name = $pl->name;
642 685
643 if ($tname eq $name) { 686 if ($tname eq $name) {
644 my $emote = $emotes->{$emotion}->{self}; 687 my $emote = $emotes->{$emotion}->{self};
688
689 $emote->{other} = "You look away from <self>."
690 if !$emote->{other};
691 $emote->{self} = "My god! Is that LEGAL?"
692 if !$emote->{self};
693
645 $emote->{other} =~ s/<self>/$name/; 694 $emote->{other} =~ s/<self>/$name/;
646 695
647 for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { 696 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
648 next 697 next
649 if $other->ob == $ob; 698 if $other->ob == $pl;
650 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); 699 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
651 } 700 }
652 701
653 $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 702 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE);
654 } elsif ($tname) { 703 } elsif ($tname) {
655 my $target = cf::player::find $tname 704 my $target = cf::player::find $tname
656 or return $ob->reply (undef, "$tname is not around."); 705 or return $pl->reply (undef, "$tname is not around.");
657 706
658 my $emote = $emotes->{$emotion}->{params}; 707 my $emote = $emotes->{$emotion}->{params};
708
709 $emote->{other} = "<self> is eyeing <other> quizzically."
710 if !$emote->{other};
711 $emote->{self} = "You are still nuts."
712 if !$emote->{self};
713 $emote->{target} = "You get the distinct feeling that <other> is nuts."
714 if !$emote->{target};
715
659 $emote->{self} =~ s/<other>/$tname/; 716 $emote->{self} =~ s/<other>/$tname/;
660 $emote->{target} =~ s/<self>/$name/; 717 $emote->{target} =~ s/<self>/$name/;
661 $emote->{other} =~ s/<other>/$tname/; 718 $emote->{other} =~ s/<other>/$tname/;
662 $emote->{other} =~ s/<self>/$name/; 719 $emote->{other} =~ s/<self>/$name/;
663 720
664 for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { 721 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
665 next 722 next
666 if $other->ob == $ob or $other == $target; 723 if $other->ob == $pl or $other == $target;
667 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); 724 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
668 } 725 }
669 726
670 $target->ob->message ($emote->{target}, cf::NDI_GREY | cf::NDI_UNIQUE); 727 $target->ob->message ($emote->{target}, cf::NDI_GREY | cf::NDI_UNIQUE);
671 $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 728 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE);
672 } else { 729 } else {
673 my $emote = $emotes->{$emotion}->{noparams}; 730 my $emote = $emotes->{$emotion}->{noparams};
674 $emote->{other} =~ s/<self>/$name/; 731 $emote->{other} =~ s/<self>/$name/;
732
733 $emote->{other} = "<self> dances with glee."
734 if !$emote->{other};
735 $emote->{self} = "You are a nut."
736 if !$emote->{self};
675 737
676 for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { 738 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
677 next 739 next
678 if $other->ob == $ob; 740 if $other->ob == $pl;
679 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); 741 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
680 } 742 }
681 743
682 $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 744 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE);
683 } 745 }
684 }; 746 };
685 }; 747 };
686} 748}
687 749
750cf::register_command me => sub {
751 my ($pl, $msg) = @_;
752
753 my $name = $pl->name;
754
755 $_->ob->message ("* $name $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
756 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
757};
758
688cf::register_command say => sub { 759cf::register_command say => sub {
689 my ($who, $msg) = @_; 760 my ($pl, $msg) = @_;
690 761
691 utf8::decode $msg; 762 utf8::decode $msg;
692 763
693 return if $who->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); 764 return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg);
694 765
695 if ($msg) { 766 if ($msg) {
696 my $name = $who->name; 767 my $name = $pl->name;
697 768
698 utf8::encode $msg; # ->message not yet utf8-ified 769 utf8::encode $msg; # ->message not yet utf8-ified
699 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) 770 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
700 for grep $who->on_same_map_as ($_->ob), cf::player::list; 771 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
701 utf8::decode $msg; 772 utf8::decode $msg;
702 773
703 # npcs, magic_ears etc. 774 # npcs, magic_ears etc.
704 # first find all objects and theirt-level inventories 775 # first find all objects and theirt-level inventories
705 # within a 5x5 square # that have something resembling 776 # within a 5x5 square # that have something resembling
706 # dialogue or support on_say. 777 # dialogue or support on_say.
707 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); 778 my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2);
708 779
709 for my $npc ( 780 for my $npc (
710 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $who->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 781 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_,
711 map +($_, $_->inv), 782 map +($_, $_->inv),
712 grep $_, 783 grep $_,
713 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 784 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
714 0..24 785 0..24
715 ) { 786 ) {
716 # if some listener teleported us somewhere else, stop right here 787 # if some listener teleported us somewhere else, stop right here
717 last unless $map->path == $who->map->path; 788 last unless $map->path == $pl->map->path;
718 789
719 my $dialog = new NPC_Dialogue ob => $who, npc => $npc; 790 my $dialog = new NPC_Dialogue ob => $pl, npc => $npc;
720 my ($reply, @kw) = $dialog->tell ($msg); 791 my ($reply, @kw) = $dialog->tell ($msg);
721 792
722 if (defined $reply) { 793 if (defined $reply) {
723 if ($npc->type == cf::MAGIC_EAR) { 794 if ($npc->type == cf::MAGIC_EAR) {
724 if (length $reply) { 795 if (length $reply) {
725 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) 796 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE)
726 for grep $who->on_same_map_as ($_->ob), cf::player::list; 797 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
727 } 798 }
728 $npc->use_trigger; 799 $npc->use_trigger;
729 } else { 800 } else {
730 if (length $reply) { 801 if (length $reply) {
731 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) 802 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE)
732 for grep $who->on_same_map_as ($_->ob), cf::player::list; 803 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
733 } 804 }
734 } 805 }
735 } 806 }
736 807
737 if (@kw) { 808 if (@kw) {
738 $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) 809 $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE)
739 for grep $who->on_same_map_as ($_->ob), cf::player::list; 810 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
740 } 811 }
741 } 812 }
742 813
743 } else { 814 } else {
744 $who->message ("What do you want to say?", cf::NDI_UNIQUE); 815 $pl->message ("What do you want to say?", cf::NDI_UNIQUE);
745 } 816 }
746
747 1
748}; 817};
749 818
750cf::register_command chat => sub { 819cf::register_command chat => sub {
751 my ($who, $msg) = @_; 820 my ($pl, $msg) = @_;
752 821
753 utf8::decode $msg; 822 utf8::decode $msg;
754 823
755 return if $who->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); 824 return if $pl->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg);
756 825
757 if ($msg) { 826 if ($msg) {
758 my $name = $who->name; 827 my $name = $pl->name;
759 my $NOW = time; 828 my $NOW = time;
760 829
761 utf8::encode $msg; # ->message not yet utf8-ified 830 utf8::encode $msg; # ->message not yet utf8-ified
762 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 831 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
763 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); 832 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg);
764 833
765 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 834 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE)
766 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 835 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
767 836
768 } else { 837 } else {
769 $who->message ("Chat what?", cf::NDI_UNIQUE); 838 $pl->message ("Chat what?", cf::NDI_UNIQUE);
770 } 839 }
771
772 1
773}; 840};
774 841
775cf::register_command shout => sub { 842cf::register_command shout => sub {
776 my ($who, $msg) = @_; 843 my ($pl, $msg) = @_;
777 844
778 utf8::decode $msg; 845 utf8::decode $msg;
779 846
780 return if $who->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); 847 return if $pl->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg);
781 848
782 if ($msg) { 849 if ($msg) {
783 my $NOW = time; 850 my $NOW = time;
784 my $name = $who->name; 851 my $name = $pl->name;
785 852
786 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 853 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
787 ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); 854 ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg);
788 855
789 utf8::encode $msg; # ->message not yet utf8-ified 856 utf8::encode $msg; # ->message not yet utf8-ified
790 $_->ob->message ("$name shouts: $msg", cf::NDI_RED) 857 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
791 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 858 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
792 859
793 } else { 860 } else {
794 $who->message ("Shout what?", cf::NDI_UNIQUE); 861 $pl->message ("Shout what?", cf::NDI_UNIQUE);
795 } 862 }
796
797 1
798}; 863};
799 864
800cf::register_command tell => sub { 865cf::register_command tell => sub {
801 my ($who, $args) = @_; 866 my ($pl, $args) = @_;
802 my ($target, $msg) = split /\s+/, $args, 2; 867 my ($target, $msg) = split /\s+/, $args, 2;
803 868
804 utf8::decode $msg; 869 utf8::decode $msg;
805 870
806 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); 871 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg);
807 872
808 my $name = $who->name; 873 my $name = $pl->name;
809 874
810 if ($target =~ /irc\//) { 875 if ($target =~ /irc\//) {
811 my (undef, $nick) = split /\//, $target, 2; 876 my (undef, $nick) = split /\//, $target, 2;
812 $who->message ("You tell $target: $args"); 877 $pl->message ("You tell $target: $args");
813 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); 878 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg);
814 } elsif (my $other = cf::player::find_active $target) { 879 } elsif (my $other = cf::player::find_active $target) {
815 880
816 if ($msg) { 881 if ($msg) {
817 if ($target eq $name) { 882 if ($target eq $name) {
818 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); 883 $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE);
819 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 884 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
820 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); 885 $pl->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE);
821 } else { 886 } else {
887 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl->contr, $msg);
822 utf8::encode $msg; # ->message not yet utf8-ified 888 utf8::encode $msg; # ->message not yet utf8-ified
823 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 889 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
824 890
825 $who->message ("You tell $target: $msg"); 891 $pl->message ("You tell $target: $msg");
826 $other->ob->message ("$name tells you: $msg"); 892 $other->ob->message ("$name tells you: $msg");
827 $other->ob->{ext_last_tell} = $name; 893 $other->ob->{ext_last_tell} = $name;
828 } 894 }
829 } else { 895 } else {
830 $who->message ("What do you want to tell $target?", cf::NDI_UNIQUE); 896 $pl->message ("What do you want to tell $target?", cf::NDI_UNIQUE);
831 } 897 }
832 898
833 } else { 899 } else {
834 $who->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); 900 $pl->message ("No such player. Your message: $msg", cf::NDI_UNIQUE);
835 } 901 }
836
837 1
838}; 902};
839 903
840cf::register_command reply => sub { 904cf::register_command reply => sub {
841 my ($who, $args) = @_; 905 my ($pl, $args) = @_;
842 my $name = $who->name; 906 my $name = $pl->name;
843 907
844 utf8::decode $args; 908 utf8::decode $args;
845 909
846 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $who->{ext_last_tell}, $args); 910 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args);
847 911
848 if ($who->{ext_last_tell} =~ /irc\//) { 912 if ($pl->{ext_last_tell} =~ /irc\//) {
849 my (undef, $nick) = split /\//, $who->{ext_last_tell}, 2; 913 my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2;
850 $who->message ("You tell " . $who->{ext_last_tell} . ": $args"); 914 $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args");
851 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); 915 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args);
852 } elsif (my $other = cf::player::find_active $who->{ext_last_tell}) { 916 } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) {
853 917
854 if ($args) { 918 if ($args) {
855 $other->ob->{ext_ignore_tell}{$name} >= time 919 $other->ob->{ext_ignore_tell}{$name} >= time
856 or delete $other->ob->{ext_ignore_tell}{$name}; 920 or delete $other->ob->{ext_ignore_tell}{$name};
857 921
858 if ($other->ob->{ext_ignore_tell}{$name} < time) { 922 if ($other->ob->{ext_ignore_tell}{$name} < time) {
859 utf8::encode $args; # ->message not yet utf8-ified 923 utf8::encode $args; # ->message not yet utf8-ified
860 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; 924 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args;
861 925
862 $who->message ("You tell " . $other->ob->name . ": $args"); 926 $pl->message ("You tell " . $other->ob->name . ": $args");
863 $other->ob->message ("$name tells you: $args"); 927 $other->ob->message ("$name tells you: $args");
864 $who->{ext_last_tell} = $other->ob->name; 928 $pl->{ext_last_tell} = $other->ob->name;
865 } else { 929 } else {
866 $who->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); 930 $pl->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE);
867 } 931 }
868 } else { 932 } else {
869 $who->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); 933 $pl->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE);
870 } 934 }
871 935
872 } else { 936 } else {
873 $who->message ("Can't reply, player left. Your message: $args".$who->{ext_last_tell}, cf::NDI_UNIQUE); 937 $pl->message ("Can't reply, player left. Your message: $args".$pl->{ext_last_tell}, cf::NDI_UNIQUE);
874 } 938 }
875
876 1
877}; 939};
878 940
879cf::register_command ignore => sub { 941cf::register_command ignore => sub {
880 my ($who, $args) = @_; 942 my ($pl, $args) = @_;
881 my ($target, $type, $timeout) = split /\s+/, $args; 943 my ($target, $type, $timeout) = split /\s+/, $args;
882 944
883 if ($args eq "list") { 945 if ($args eq "list") {
884 clean_timeouts $who; 946 clean_timeouts $pl;
885 947
886 if ((my @ignored_tell = sort keys %{$who->{ext_ignore_tell}}) 948 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}})
887 + (my @ignored_shout = sort keys %{$who->{ext_ignore_shout}})) { 949 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) {
888 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 950 $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE);
889 $who->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE); 951 $pl->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE);
890 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 952 $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE);
891 $who->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE); 953 $pl->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE);
892 $who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); 954 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE);
893 } else { 955 } else {
894 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); 956 $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE);
895 } 957 }
896 958
897 } elsif ($target && $type) { 959 } elsif ($target && $type) {
898 960
899 $timeout ne "" or $timeout = 24; 961 $timeout ne "" or $timeout = 24;
900 my $absolute_timeout = time + $timeout * 3600; 962 my $absolute_timeout = time + $timeout * 3600;
901 963
902 if (cf::player::exists $target) { 964 if (cf::player::exists $target) {
903 if ($type eq "tell") { 965 if ($type eq "tell") {
904 $who->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE); 966 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE);
905 $who->{ext_ignore_tell}{$target} = $absolute_timeout; 967 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
906 } elsif ($type eq "shout") { 968 } elsif ($type eq "shout") {
907 $who->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE); 969 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE);
908 $who->{ext_ignore_shout}{$target} = $absolute_timeout; 970 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
909 } elsif ($type eq "all") { 971 } elsif ($type eq "all") {
910 $who->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE); 972 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE);
911 $who->{ext_ignore_tell}{$target} = $absolute_timeout; 973 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
912 $who->{ext_ignore_shout}{$target} = $absolute_timeout; 974 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
913 } else { 975 } else {
914 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 976 $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE);
915 } 977 }
916 } else { 978 } else {
917 $who->message ("No such player: $target", cf::NDI_UNIQUE); 979 $pl->message ("No such player: $target", cf::NDI_UNIQUE);
918 } 980 }
919 981
920 } else { 982 } else {
921 $who->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" 983 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
922 . "will ignore a player for <timeout> hours.\n" 984 . "will ignore a player for <timeout> hours.\n"
923 . "Usage: ignore list\n" 985 . "Usage: ignore list\n"
924 . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); 986 . "will show you a list of players currently ignored.", cf::NDI_UNIQUE);
925 } 987 }
926
927 1
928}; 988};
929 989
930cf::register_command unignore => sub { 990cf::register_command unignore => sub {
931 my ($who, $args) = @_; 991 my ($pl, $args) = @_;
932 my ($target, $type) = split /\s+/, $args; 992 my ($target, $type) = split /\s+/, $args;
933 993
934 if ($args eq "") { 994 if ($args eq "") {
935 if ($who->{ext_ignore_tell}) { 995 if ($pl->{ext_ignore_tell}) {
936 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 996 $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE);
937 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_tell} }), cf::NDI_UNIQUE); 997 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_UNIQUE);
938 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 998 $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE);
939 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE); 999 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_UNIQUE);
940 } else { 1000 } else {
941 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); 1001 $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE);
942 } 1002 }
943 } else { 1003 } else {
944 if (cf::player::exists $target) { 1004 if (cf::player::exists $target) {
945 if ($type eq "tell") { 1005 if ($type eq "tell") {
946 $who->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); 1006 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE);
947 delete $who->{ext_ignore_tell} {$target}; 1007 delete $pl->{ext_ignore_tell} {$target};
948 } elsif ($type eq "shout") { 1008 } elsif ($type eq "shout") {
949 $who->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE); 1009 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE);
950 delete $who->{ext_ignore_shout}{$target}; 1010 delete $pl->{ext_ignore_shout}{$target};
951 } elsif ($type eq "all") { 1011 } elsif ($type eq "all") {
952 $who->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE); 1012 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE);
953 delete $who->{ext_ignore_tell} {$target}; 1013 delete $pl->{ext_ignore_tell} {$target};
954 delete $who->{ext_ignore_shout}{$target}; 1014 delete $pl->{ext_ignore_shout}{$target};
955 } else { 1015 } else {
956 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 1016 $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE);
957 } 1017 }
958 } else { 1018 } else {
959 $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); 1019 $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE);
960 } 1020 }
961 } 1021 }
962
963 1
964}; 1022};
965 1023
966cf::register_command seen => sub {
967 my ($who, $args) = @_;
968
969 if (my ($login) = $args =~ /(\S+)/) {
970 if ($login eq $who->name) {
971 $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE);
972 } elsif (cf::player::find_active $login) {
973 $who->message ("$login is right here on this server!", cf::NDI_UNIQUE);
974 } elsif (cf::player::exists $login
975 and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) {
976 my $time = (stat _)[9];
977
978 $who->message ("$login was last seen here "
979 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
980 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE);
981 } else {
982 $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE);
983 }
984 } else {
985 $who->message ("Usage: seen <player>", cf::NDI_UNIQUE);
986 }
987
988 1
989};
990

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines