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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines