1 | #! perl |
1 | #! perl # depends=irc |
2 | #CONVERSION: PARTIAL |
2 | #CONVERSION: PARTIAL |
3 | |
3 | |
4 | # implement a replacement for the built-in say/chat/shout/tell/reply commands |
4 | # implement a replacement for the built-in say/chat/shout/tell/reply commands |
5 | # adds ignore/unignore functionality |
5 | # adds ignore/unignore functionality |
6 | |
6 | |
… | |
… | |
22 | } |
22 | } |
23 | } |
23 | } |
24 | } |
24 | } |
25 | } |
25 | } |
26 | |
26 | |
|
|
27 | # send_irc ($format, @args, $msg) |
|
|
28 | # make sure the last argument is the message! |
|
|
29 | sub send_irc { |
|
|
30 | my ($format, @args) = @_; |
|
|
31 | my $msg = pop @args; |
|
|
32 | for (split /\n/, $msg) { |
|
|
33 | ext::irc::do_notice (sprintf $format, @args, $_) |
|
|
34 | } |
|
|
35 | } |
|
|
36 | |
27 | cf::player->attach ( |
37 | cf::player->attach ( |
28 | prio => -1000, |
38 | prio => -1000, |
29 | on_login => sub { |
39 | on_login => sub { |
30 | my ($pl) = @_; |
40 | my ($pl) = @_; |
31 | |
41 | |
… | |
… | |
36 | cf::register_command listen => sub { |
46 | cf::register_command listen => sub { |
37 | my ($pl, $msg) = @_; |
47 | my ($pl, $msg) = @_; |
38 | my $player = cf::player::find_active $pl->name; |
48 | my $player = cf::player::find_active $pl->name; |
39 | |
49 | |
40 | if ($msg ne "") { |
50 | if ($msg ne "") { |
|
|
51 | $msg = 10 if $msg > 10; |
|
|
52 | |
41 | my $prev_listen = $player->listening; |
53 | my $prev_listen = $player->listening; |
42 | $player->listening ($msg); |
54 | $player->listening ($msg); |
43 | if ($prev_listen == $player->listening) { |
55 | if ($prev_listen == $player->listening) { |
44 | $pl->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); |
56 | $pl->message ("Your verbose level stays at $prev_listen.", cf::NDI_UNIQUE); |
45 | } else { |
57 | } else { |
46 | $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); |
58 | $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); |
47 | } |
59 | } |
48 | } else { |
60 | } else { |
49 | $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
61 | $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
… | |
… | |
52 | |
64 | |
53 | cf::register_command cointoss => sub { |
65 | cf::register_command cointoss => sub { |
54 | my ($pl, $msg) = @_; |
66 | my ($pl, $msg) = @_; |
55 | |
67 | |
56 | my $name = $pl->name; |
68 | my $name = $pl->name; |
|
|
69 | my $coin = int rand 2 ? "Heads" : "Tails"; |
57 | |
70 | |
58 | if (int rand 2) { |
|
|
59 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
71 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
60 | next |
72 | next |
61 | if $other->ob == $pl; |
73 | 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); |
74 | $other->ob->message ("$name flips a coin.... $coin!", 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 | |
|
|
77 | $pl->message ("You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_UNIQUE); |
75 | }; |
78 | }; |
76 | |
79 | |
77 | cf::register_command orcknuckle => sub { |
80 | cf::register_command orcknuckle => sub { |
78 | my ($pl, $msg) = @_; |
81 | my ($pl, $msg) = @_; |
79 | my @orcknuckle = ("none", "beholder", "ghost", "knight", "princess", "dragon", "orc"); |
82 | my @orcknuckle = ("none", "beholder", "ghost", "knight", "princess", "dragon", "orc"); |
… | |
… | |
227 | noparams => { |
230 | noparams => { |
228 | other => "<self> winks suggestively.", |
231 | other => "<self> winks suggestively.", |
229 | self => "Have you got something in your eye?", |
232 | self => "Have you got something in your eye?", |
230 | }, |
233 | }, |
231 | params => { |
234 | params => { |
|
|
235 | target => "<self> winks at you.", |
232 | target => "<self> winks at <other>.", |
236 | other => "<self> winks at <other>.", |
233 | self => "You wink suggestively at <other>.", |
237 | self => "You wink suggestively at <other>.", |
234 | }, |
238 | }, |
235 | self => { |
239 | self => { |
236 | other => "<self> winks at himself - something strange is going on...", |
240 | other => "<self> winks at himself - something strange is going on...", |
237 | self => "You wink at yourself?? What are you up to?", |
241 | self => "You wink at yourself?? What are you up to?", |
… | |
… | |
327 | noparams => { |
331 | noparams => { |
328 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
332 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
329 | self => "You bleed all over your nice new armour.", |
333 | self => "You bleed all over your nice new armour.", |
330 | }, |
334 | }, |
331 | params => { |
335 | params => { |
|
|
336 | target => "<self> slashes his wrist and bleeds all over you.", |
332 | target => "<self> slashes his wrist and bleeds all over <other>.", |
337 | other => "<self> slashes his wrist and bleeds all over <other>.", |
333 | self => "You slash your wrist and bleed all over <other>", |
338 | self => "You slash your wrist and bleed all over <other>", |
334 | }, |
339 | }, |
335 | self => { |
340 | self => { |
336 | other => "<self> performs some satanic ritual while wiping his blood on himself.", |
341 | other => "<self> performs some satanic ritual while wiping his blood on himself.", |
337 | self => "Very impressive! You wipe your blood all over yourself.", |
342 | self => "Very impressive! You wipe your blood all over yourself.", |
… | |
… | |
741 | } |
746 | } |
742 | }; |
747 | }; |
743 | }; |
748 | }; |
744 | } |
749 | } |
745 | |
750 | |
|
|
751 | our $SAY_CHANNEL = { |
|
|
752 | id => "say", |
|
|
753 | title => "Map", |
|
|
754 | reply => "say ", |
|
|
755 | tooltip => "Things said to and replied from npcs near you and other players on the same map only.", |
|
|
756 | }; |
|
|
757 | |
746 | cf::register_command me => sub { |
758 | cf::register_command me => sub { |
747 | my ($pl, $msg) = @_; |
759 | my ($pl, $msg) = @_; |
748 | |
760 | |
749 | my $name = $pl->name; |
761 | my $name = $pl->name; |
750 | |
762 | |
751 | $_->ob->message ("* $name $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
763 | $_->ns->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY, $_ == $pl ? (reply => 1) : ()) |
752 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
764 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
753 | }; |
765 | }; |
754 | |
766 | |
755 | cf::register_command say => sub { |
767 | cf::register_command say => sub { |
756 | my ($pl, $msg) = @_; |
768 | my ($pl, $msg) = @_; |
… | |
… | |
759 | |
771 | |
760 | return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
772 | return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
761 | |
773 | |
762 | if ($msg) { |
774 | if ($msg) { |
763 | my $name = $pl->name; |
775 | my $name = $pl->name; |
764 | |
|
|
765 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
766 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
|
|
767 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
776 | my @plonmap = grep $pl->on_same_map_as ($_->ob), cf::player::list; |
768 | utf8::decode $msg; |
777 | |
|
|
778 | $_->ns->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, $_ == $pl ? (reply => 1) : ()) |
|
|
779 | for @plonmap; |
769 | |
780 | |
770 | # npcs, magic_ears etc. |
781 | # npcs, magic_ears etc. |
771 | # first find all objects and theirt-level inventories |
782 | # first find all objects and their first-level inventories |
772 | # within a 5x5 square # that have something resembling |
783 | # within a 5x5 square that have something resembling |
773 | # dialogue or support on_say. |
784 | # dialogue or support on_say. |
774 | my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2); |
785 | my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2); |
775 | |
786 | |
776 | for my $npc ( |
787 | for my $npc ( |
777 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
788 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
… | |
… | |
781 | 0..24 |
792 | 0..24 |
782 | ) { |
793 | ) { |
783 | # if some listener teleported us somewhere else, stop right here |
794 | # if some listener teleported us somewhere else, stop right here |
784 | last unless $map->path == $pl->map->path; |
795 | last unless $map->path == $pl->map->path; |
785 | |
796 | |
786 | my $dialog = new NPC_Dialogue ob => $pl, npc => $npc; |
797 | my $dialog = new NPC_Dialogue pl => $pl->contr, npc => $npc; |
787 | my ($reply, @kw) = $dialog->tell ($msg); |
798 | my ($reply, @kw) = $dialog->tell ($msg); |
788 | |
799 | |
789 | if (defined $reply) { |
800 | if (defined $reply) { |
790 | if ($npc->type == cf::MAGIC_EAR) { |
801 | if ($npc->type == cf::MAGIC_EAR) { |
791 | if (length $reply) { |
802 | if (length $reply) { |
792 | $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) |
803 | $_->contr->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) |
793 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
804 | for @plonmap; |
794 | } |
805 | } |
795 | $npc->use_trigger; |
806 | $npc->use_trigger; |
796 | } else { |
807 | } else { |
797 | if (length $reply) { |
808 | if (length $reply) { |
798 | $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) |
809 | $_->contr->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) |
799 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
810 | for @plonmap; |
800 | } |
811 | } |
801 | } |
812 | } |
802 | } |
813 | } |
803 | |
814 | |
804 | if (@kw) { |
815 | if (@kw) { |
805 | $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) |
816 | $_->contr->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
806 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
817 | for @plonmap; |
807 | } |
818 | } |
808 | } |
819 | } |
809 | |
820 | |
810 | } else { |
821 | } else { |
811 | $pl->message ("What do you want to say?", cf::NDI_UNIQUE); |
822 | $pl->contr->send_msg ($SAY_CHANNEL => "What do you want to say?", 0, reply => 1); |
812 | } |
823 | } |
|
|
824 | }; |
|
|
825 | |
|
|
826 | our $CHAT_CHANNEL = { |
|
|
827 | id => "chat", |
|
|
828 | title => "Chat", |
|
|
829 | reply => "chat ", |
|
|
830 | tooltip => "Player chat and shouts, global to the server.", |
813 | }; |
831 | }; |
814 | |
832 | |
815 | cf::register_command chat => sub { |
833 | cf::register_command chat => sub { |
816 | my ($pl, $msg) = @_; |
834 | my ($pl, $msg) = @_; |
817 | |
835 | |
… | |
… | |
821 | |
839 | |
822 | if ($msg) { |
840 | if ($msg) { |
823 | my $name = $pl->name; |
841 | my $name = $pl->name; |
824 | my $NOW = time; |
842 | my $NOW = time; |
825 | |
843 | |
826 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
827 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
844 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
828 | ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); |
845 | send_irc ("[%s] %s", $name, $msg); |
829 | |
846 | |
830 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
847 | $_->ns->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE, $_ == $pl ? (reply => 1) : ()) |
831 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
848 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
832 | |
849 | |
833 | } else { |
850 | } else { |
834 | $pl->message ("Chat what?", cf::NDI_UNIQUE); |
851 | $pl->ns->send_msg ($CHAT_CHANNEL => "Chat what?"); |
835 | } |
852 | } |
836 | }; |
853 | }; |
837 | |
854 | |
838 | cf::register_command shout => sub { |
855 | cf::register_command shout => sub { |
839 | my ($pl, $msg) = @_; |
856 | my ($pl, $msg) = @_; |
… | |
… | |
845 | if ($msg) { |
862 | if ($msg) { |
846 | my $NOW = time; |
863 | my $NOW = time; |
847 | my $name = $pl->name; |
864 | my $name = $pl->name; |
848 | |
865 | |
849 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
866 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
850 | ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); |
867 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
851 | |
868 | |
852 | utf8::encode $msg; # ->message not yet utf8-ified |
869 | $_->ns->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_BLUE, $_ == $pl ? (reply => 1) : ()) |
853 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
|
|
854 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
870 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
855 | |
871 | |
856 | } else { |
872 | } else { |
857 | $pl->message ("Shout what?", cf::NDI_UNIQUE); |
873 | $pl->ns->send_msg ($CHAT_CHANNEL => "Shout what?"); |
858 | } |
874 | } |
859 | }; |
875 | }; |
860 | |
876 | |
861 | cf::register_command tell => sub { |
877 | cf::register_command tell => sub { |
862 | my ($pl, $args) = @_; |
878 | my ($ob, $args) = @_; |
863 | my ($target, $msg) = split /\s+/, $args, 2; |
879 | my ($target, $msg) = split /\s+/, $args, 2; |
864 | |
880 | |
865 | utf8::decode $msg; |
881 | utf8::decode $msg; |
866 | |
882 | |
|
|
883 | my $pl = $ob->contr; |
|
|
884 | my $ns = $pl->ns |
|
|
885 | or return; |
|
|
886 | my $name = $ob->name; |
|
|
887 | |
867 | return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
888 | return if $pl->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
868 | |
889 | |
869 | my $name = $pl->name; |
890 | my $pl_channel = { |
|
|
891 | id => "tell-$target", |
|
|
892 | title => "$target", |
|
|
893 | reply => "tell $target ", |
|
|
894 | tooltip => "Private messages from/to $target", |
|
|
895 | }; |
870 | |
896 | |
871 | if ($target =~ /irc\//) { |
897 | if ($target =~ /irc\//) { |
872 | my (undef, $nick) = split /\//, $target, 2; |
898 | my (undef, $nick) = split /\//, $target, 2; |
873 | $pl->message ("You tell $target: $args"); |
899 | $ns->send_msg ($pl_channel => "You tell $target: $args", reply => 1); |
874 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); |
900 | send_irc ("(%s) %s: %s\n", $name, $nick, $msg); |
875 | } elsif (my $other = cf::player::find_active $target) { |
901 | } elsif (my $other = cf::player::find_active $target) { |
|
|
902 | my $other_channel = { |
|
|
903 | id => "tell-$name", |
|
|
904 | title => "$name", |
|
|
905 | reply => "tell $name ", |
|
|
906 | tooltip => "Private messages from/to $name", |
|
|
907 | }; |
876 | |
908 | |
877 | if ($msg) { |
909 | if ($msg) { |
878 | if ($target eq $name) { |
910 | if ($target eq $name) { |
879 | $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
911 | $ns->send_msg ($pl_channel => "You are talking to yourself, you freak!", reply => 1); |
880 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
912 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
881 | $pl->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
913 | $ns->send_msg ($pl_channel => "$target ignores what you say. Give up on it.", reply => 1); |
882 | } else { |
914 | } else { |
883 | utf8::encode $msg; # ->message not yet utf8-ified |
915 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl->contr, $msg); |
884 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
916 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
885 | |
917 | |
886 | $pl->message ("You tell $target: $msg"); |
918 | $ns->send_msg ($pl_channel => "You tell $target: $msg", reply => 1); |
887 | $other->ob->message ("$name tells you: $msg"); |
919 | $other->ns->send_msg ($other_channel => "$name tells you: $msg"); |
888 | $other->ob->{ext_last_tell} = $name; |
|
|
889 | } |
920 | } |
890 | } else { |
921 | } else { |
891 | $pl->message ("What do you want to tell $target?", cf::NDI_UNIQUE); |
922 | $ns->send_msg ($pl_channel => "What do you want to tell $target?"); |
892 | } |
923 | } |
893 | |
924 | |
894 | } else { |
925 | } else { |
895 | $pl->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); |
926 | $ns->send_msg ($pl_channel => "No such player. Your message: $msg"); |
896 | } |
|
|
897 | }; |
|
|
898 | |
|
|
899 | cf::register_command reply => sub { |
|
|
900 | my ($pl, $args) = @_; |
|
|
901 | my $name = $pl->name; |
|
|
902 | |
|
|
903 | utf8::decode $args; |
|
|
904 | |
|
|
905 | return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args); |
|
|
906 | |
|
|
907 | if ($pl->{ext_last_tell} =~ /irc\//) { |
|
|
908 | my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2; |
|
|
909 | $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args"); |
|
|
910 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); |
|
|
911 | } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) { |
|
|
912 | |
|
|
913 | if ($args) { |
|
|
914 | $other->ob->{ext_ignore_tell}{$name} >= time |
|
|
915 | or delete $other->ob->{ext_ignore_tell}{$name}; |
|
|
916 | |
|
|
917 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
|
|
918 | utf8::encode $args; # ->message not yet utf8-ified |
|
|
919 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; |
|
|
920 | |
|
|
921 | $pl->message ("You tell " . $other->ob->name . ": $args"); |
|
|
922 | $other->ob->message ("$name tells you: $args"); |
|
|
923 | $pl->{ext_last_tell} = $other->ob->name; |
|
|
924 | } else { |
|
|
925 | $pl->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
|
|
926 | } |
|
|
927 | } else { |
|
|
928 | $pl->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); |
|
|
929 | } |
|
|
930 | |
|
|
931 | } else { |
|
|
932 | $pl->message ("Can't reply, player left. Your message: $args".$pl->{ext_last_tell}, cf::NDI_UNIQUE); |
|
|
933 | } |
927 | } |
934 | }; |
928 | }; |
935 | |
929 | |
936 | cf::register_command ignore => sub { |
930 | cf::register_command ignore => sub { |
937 | my ($pl, $args) = @_; |
931 | my ($pl, $args) = @_; |
… | |
… | |
1014 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
1008 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
1015 | } |
1009 | } |
1016 | } |
1010 | } |
1017 | }; |
1011 | }; |
1018 | |
1012 | |
1019 | cf::register_command seen => sub { |
|
|
1020 | my ($pl, $args) = @_; |
|
|
1021 | |
|
|
1022 | if (my ($login) = $args =~ /(\S+)/) { |
|
|
1023 | if ($login eq $pl->name) { |
|
|
1024 | $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); |
|
|
1025 | } elsif (cf::player::find_active $login) { |
|
|
1026 | $pl->message ("$login is right here on this server!", cf::NDI_UNIQUE); |
|
|
1027 | } elsif (cf::player::exists $login |
|
|
1028 | and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { |
|
|
1029 | my $time = (stat _)[9]; |
|
|
1030 | |
|
|
1031 | $pl->message ("$login was last seen here " |
|
|
1032 | . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) |
|
|
1033 | . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); |
|
|
1034 | } else { |
|
|
1035 | $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE); |
|
|
1036 | } |
|
|
1037 | } else { |
|
|
1038 | $pl->message ("Usage: seen <player>", cf::NDI_UNIQUE); |
|
|
1039 | } |
|
|
1040 | }; |
|
|
1041 | |
|
|