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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines