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 | |
7 | use NPC_Dialogue; |
7 | use NPC_Dialogue; |
8 | use POSIX (); # for strftime only |
8 | use POSIX (); # for strftime only |
|
|
9 | |
|
|
10 | our $SAY_CHANNEL = { |
|
|
11 | id => "say", |
|
|
12 | title => "Map", |
|
|
13 | reply => "say ", |
|
|
14 | tooltip => "Things said to and replied from npcs near you and other players on the same map only.", |
|
|
15 | }; |
|
|
16 | |
|
|
17 | our $CHAT_CHANNEL = { |
|
|
18 | id => "chat", |
|
|
19 | title => "Chat", |
|
|
20 | reply => "chat ", |
|
|
21 | tooltip => "Player chat and shouts, global to the server.", |
|
|
22 | }; |
9 | |
23 | |
10 | sub clean_timeouts($) { |
24 | sub clean_timeouts($) { |
11 | my ($player) = @_; |
25 | my ($player) = @_; |
12 | my $NOW = time; |
26 | my $NOW = time; |
13 | |
27 | |
… | |
… | |
22 | } |
36 | } |
23 | } |
37 | } |
24 | } |
38 | } |
25 | } |
39 | } |
26 | |
40 | |
|
|
41 | # send_irc ($format, @args, $msg) |
|
|
42 | # make sure the last argument is the message! |
|
|
43 | sub send_irc { |
|
|
44 | my ($format, @args) = @_; |
|
|
45 | my $msg = pop @args; |
|
|
46 | for (split /\n/, $msg) { |
|
|
47 | ext::irc::do_notice (sprintf $format, @args, $_) |
|
|
48 | } |
|
|
49 | } |
|
|
50 | |
27 | cf::player->attach ( |
51 | cf::player->attach ( |
28 | prio => -1000, |
52 | prio => -1000, |
29 | on_login => sub { |
53 | on_login => sub { |
30 | my ($pl) = @_; |
54 | my ($pl) = @_; |
31 | |
55 | |
32 | clean_timeouts $pl->ob; |
56 | clean_timeouts $pl->ob; |
|
|
57 | $pl->ns->send_msg ($SAY_CHANNEL); |
|
|
58 | $pl->ns->send_msg ($CHAT_CHANNEL); |
33 | }, |
59 | }, |
34 | ); |
60 | ); |
35 | |
61 | |
36 | cf::register_command listen => sub { |
62 | cf::register_command listen => sub { |
37 | my ($pl, $msg) = @_; |
63 | my ($pl, $msg) = @_; |
38 | my $player = cf::player::find_active $pl->name; |
64 | my $player = cf::player::find_active $pl->name; |
39 | |
65 | |
40 | if ($msg ne "") { |
66 | if ($msg ne "") { |
|
|
67 | $msg = 10 if $msg > 10; |
|
|
68 | |
41 | my $prev_listen = $player->listening; |
69 | my $prev_listen = $player->listening; |
42 | $player->listening ($msg); |
70 | $player->listening ($msg); |
43 | if ($prev_listen == $player->listening) { |
71 | if ($prev_listen == $player->listening) { |
44 | $pl->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); |
72 | $pl->message ("Your verbose level stays at $prev_listen.", cf::NDI_UNIQUE); |
45 | } else { |
73 | } else { |
46 | $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); |
74 | $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); |
47 | } |
75 | } |
48 | } else { |
76 | } else { |
49 | $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
77 | $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
… | |
… | |
52 | |
80 | |
53 | cf::register_command cointoss => sub { |
81 | cf::register_command cointoss => sub { |
54 | my ($pl, $msg) = @_; |
82 | my ($pl, $msg) = @_; |
55 | |
83 | |
56 | my $name = $pl->name; |
84 | my $name = $pl->name; |
|
|
85 | my $coin = int rand 2 ? "Heads" : "Tails"; |
57 | |
86 | |
58 | if (int rand 2) { |
|
|
59 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
87 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
60 | next |
88 | next |
61 | if $other->ob == $pl; |
89 | if $other->ob == $pl; |
62 | $other->ob->message ("$name flips a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE); |
90 | $other->ob->message ("$name flips a coin.... $coin!", cf::NDI_GREY | cf::NDI_UNIQUE); |
63 | } |
91 | } |
|
|
92 | |
|
|
93 | $pl->message ("You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_UNIQUE); |
|
|
94 | }; |
|
|
95 | |
|
|
96 | cf::register_command orcknuckle => sub { |
|
|
97 | my ($pl, $msg) = @_; |
|
|
98 | my @orcknuckle = ("none", "beholder", "ghost", "knight", "princess", "dragon", "orc"); |
|
|
99 | |
|
|
100 | my $name = $pl->name; |
|
|
101 | |
|
|
102 | my ($i, $j, $k, $l) = ((int rand 5) + 1, (int rand 5) + 1, (int rand 5) + 1, (int rand 6) + 1); |
|
|
103 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
|
|
104 | |
|
|
105 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
|
|
106 | next |
|
|
107 | if $other->ob == $pl; |
|
|
108 | $other->ob->message ("$name rolls $result!", cf::NDI_GREY | cf::NDI_UNIQUE); |
|
|
109 | } |
64 | |
110 | |
65 | $pl->message ("You flip a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE); |
111 | $pl->message ("You roll $result!", 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 | }; |
112 | }; |
76 | |
113 | |
77 | my $emotes = { |
114 | my $emotes = { |
78 | growl => { |
115 | growl => { |
79 | noparams => { |
116 | noparams => { |
… | |
… | |
209 | noparams => { |
246 | noparams => { |
210 | other => "<self> winks suggestively.", |
247 | other => "<self> winks suggestively.", |
211 | self => "Have you got something in your eye?", |
248 | self => "Have you got something in your eye?", |
212 | }, |
249 | }, |
213 | params => { |
250 | params => { |
|
|
251 | target => "<self> winks at you.", |
214 | target => "<self> winks at <other>.", |
252 | other => "<self> winks at <other>.", |
215 | self => "You wink suggestively at <other>.", |
253 | self => "You wink suggestively at <other>.", |
216 | }, |
254 | }, |
217 | self => { |
255 | self => { |
218 | other => "<self> winks at himself - something strange is going on...", |
256 | other => "<self> winks at himself - something strange is going on...", |
219 | self => "You wink at yourself?? What are you up to?", |
257 | self => "You wink at yourself?? What are you up to?", |
… | |
… | |
309 | noparams => { |
347 | noparams => { |
310 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
348 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
311 | self => "You bleed all over your nice new armour.", |
349 | self => "You bleed all over your nice new armour.", |
312 | }, |
350 | }, |
313 | params => { |
351 | params => { |
|
|
352 | target => "<self> slashes his wrist and bleeds all over you.", |
314 | target => "<self> slashes his wrist and bleeds all over <other>.", |
353 | other => "<self> slashes his wrist and bleeds all over <other>.", |
315 | self => "You slash your wrist and bleed all over <other>", |
354 | self => "You slash your wrist and bleed all over <other>", |
316 | }, |
355 | }, |
317 | self => { |
356 | self => { |
318 | other => "<self> performs some satanic ritual while wiping his blood on himself.", |
357 | other => "<self> performs some satanic ritual while wiping his blood on himself.", |
319 | self => "Very impressive! You wipe your blood all over yourself.", |
358 | self => "Very impressive! You wipe your blood all over yourself.", |
… | |
… | |
728 | cf::register_command me => sub { |
767 | cf::register_command me => sub { |
729 | my ($pl, $msg) = @_; |
768 | my ($pl, $msg) = @_; |
730 | |
769 | |
731 | my $name = $pl->name; |
770 | my $name = $pl->name; |
732 | |
771 | |
733 | $_->ob->message ("* $name $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
772 | $_->ns->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY, $_ == $pl ? (reply => 1) : ()) |
734 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
773 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
735 | }; |
774 | }; |
736 | |
775 | |
737 | cf::register_command say => sub { |
776 | cf::register_command say => sub { |
738 | my ($pl, $msg) = @_; |
777 | my ($ob, $msg) = @_; |
739 | |
778 | |
740 | utf8::decode $msg; |
779 | utf8::decode $msg; |
741 | |
780 | |
742 | return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
781 | return if $ob->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
743 | |
782 | |
744 | if ($msg) { |
783 | if ($msg) { |
745 | my $name = $pl->name; |
784 | my $name = $ob->name; |
746 | |
|
|
747 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
748 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
|
|
749 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
785 | my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; |
750 | utf8::decode $msg; |
786 | |
|
|
787 | $_->ns->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, $_ == $ob ? (reply => 1) : ()) |
|
|
788 | for @plonmap; |
751 | |
789 | |
752 | # npcs, magic_ears etc. |
790 | # npcs, magic_ears etc. |
753 | # first find all objects and theirt-level inventories |
791 | # first find all objects and their first-level inventories |
754 | # within a 5x5 square # that have something resembling |
792 | # within a 5x5 square that have something resembling |
755 | # dialogue or support on_say. |
793 | # dialogue or support on_say. |
756 | my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2); |
794 | my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); |
757 | |
795 | |
758 | for my $npc ( |
796 | for my $npc ( |
759 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
797 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
760 | map +($_, $_->inv), |
798 | map +($_, $_->inv), |
761 | grep $_, |
799 | grep $_, |
762 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
800 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
763 | 0..24 |
801 | 0..24 |
764 | ) { |
802 | ) { |
765 | # if some listener teleported us somewhere else, stop right here |
803 | # if some listener teleported us somewhere else, stop right here |
766 | last unless $map->path == $pl->map->path; |
804 | last unless $map->path == $ob->map->path; |
767 | |
805 | |
768 | my $dialog = new NPC_Dialogue ob => $pl, npc => $npc; |
806 | my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; |
769 | my ($reply, @kw) = $dialog->tell ($msg); |
807 | my ($reply, @kw) = $dialog->tell ($msg); |
770 | |
808 | |
771 | if (defined $reply) { |
809 | if (defined $reply) { |
772 | if ($npc->type == cf::MAGIC_EAR) { |
810 | if ($npc->type == cf::MAGIC_EAR) { |
773 | if (length $reply) { |
811 | if (length $reply) { |
774 | $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) |
812 | $_->ns->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) |
775 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
813 | for @plonmap; |
776 | } |
814 | } |
777 | $npc->use_trigger; |
815 | $npc->use_trigger; |
778 | } else { |
816 | } else { |
779 | if (length $reply) { |
817 | if (length $reply) { |
780 | $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) |
818 | $_->ns->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) |
781 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
819 | for @plonmap; |
782 | } |
820 | } |
783 | } |
821 | } |
784 | } |
822 | } |
785 | |
823 | |
786 | if (@kw) { |
824 | if (@kw) { |
787 | $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) |
825 | $_->ns->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
788 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
826 | for @plonmap; |
789 | } |
827 | } |
790 | } |
828 | } |
791 | |
829 | |
792 | } else { |
830 | } else { |
793 | $pl->message ("What do you want to say?", cf::NDI_UNIQUE); |
831 | $ob->contr->ns->send_msg ($SAY_CHANNEL => "What do you want to say?", 0, reply => 1); |
794 | } |
832 | } |
795 | }; |
833 | }; |
796 | |
834 | |
797 | cf::register_command chat => sub { |
835 | cf::register_command chat => sub { |
798 | my ($pl, $msg) = @_; |
836 | my ($ob, $msg) = @_; |
799 | |
837 | |
800 | utf8::decode $msg; |
838 | utf8::decode $msg; |
801 | |
839 | |
|
|
840 | my $pl = $ob->contr; |
|
|
841 | |
802 | return if $pl->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
842 | return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
803 | |
843 | |
804 | if ($msg) { |
844 | if ($msg) { |
805 | my $name = $pl->name; |
845 | my $name = $ob->name; |
806 | my $NOW = time; |
846 | my $NOW = time; |
807 | |
847 | |
808 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
809 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
848 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
810 | ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); |
849 | send_irc ("[%s] %s", $name, $msg); |
811 | |
850 | |
812 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
851 | $_->ns->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE, $_ == $pl ? (reply => 1) : ()) |
813 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
852 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
814 | |
853 | |
815 | } else { |
854 | } else { |
816 | $pl->message ("Chat what?", cf::NDI_UNIQUE); |
855 | $pl->ns->send_msg ($CHAT_CHANNEL => "Chat what?"); |
817 | } |
856 | } |
818 | }; |
857 | }; |
819 | |
858 | |
820 | cf::register_command shout => sub { |
859 | cf::register_command shout => sub { |
821 | my ($pl, $msg) = @_; |
860 | my ($ob, $msg) = @_; |
822 | |
861 | |
823 | utf8::decode $msg; |
862 | utf8::decode $msg; |
824 | |
863 | |
|
|
864 | my $pl = $ob->contr; |
|
|
865 | |
825 | return if $pl->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); |
866 | return if $pl->invoke (cf::EVENT_PLAYER_SHOUT, $msg); |
826 | |
867 | |
827 | if ($msg) { |
868 | if ($msg) { |
828 | my $NOW = time; |
869 | my $NOW = time; |
829 | my $name = $pl->name; |
870 | my $name = $ob->name; |
830 | |
871 | |
831 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
872 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
832 | ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); |
873 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
833 | |
874 | |
834 | utf8::encode $msg; # ->message not yet utf8-ified |
875 | $_->ns->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED, $_ == $pl ? (reply => 1) : ()) |
835 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
|
|
836 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
876 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
837 | |
877 | |
838 | } else { |
878 | } else { |
839 | $pl->message ("Shout what?", cf::NDI_UNIQUE); |
879 | $pl->ns->send_msg ($CHAT_CHANNEL => "Shout what?"); |
840 | } |
880 | } |
841 | }; |
881 | }; |
842 | |
882 | |
843 | cf::register_command tell => sub { |
883 | cf::register_command tell => sub { |
844 | my ($pl, $args) = @_; |
884 | my ($ob, $args) = @_; |
845 | my ($target, $msg) = split /\s+/, $args, 2; |
885 | my ($target, $msg) = split /\s+/, $args, 2; |
846 | |
886 | |
847 | utf8::decode $msg; |
887 | utf8::decode $msg; |
848 | |
888 | |
|
|
889 | my $pl = $ob->contr; |
|
|
890 | my $ns = $pl->ns |
|
|
891 | or return; |
|
|
892 | my $name = $ob->name; |
|
|
893 | |
849 | return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
894 | return if $pl->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
850 | |
895 | |
851 | my $name = $pl->name; |
896 | my $pl_channel = { |
|
|
897 | id => "tell-$target", |
|
|
898 | title => "$target", |
|
|
899 | reply => "tell $target ", |
|
|
900 | tooltip => "Private messages from/to $target", |
|
|
901 | }; |
852 | |
902 | |
853 | if ($target =~ /irc\//) { |
903 | if ($target =~ /irc\//) { |
854 | my (undef, $nick) = split /\//, $target, 2; |
904 | my (undef, $nick) = split /\//, $target, 2; |
855 | $pl->message ("You tell $target: $args"); |
905 | $ns->send_msg ($pl_channel => "You tell $target: $args", reply => 1); |
856 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); |
906 | send_irc ("(%s) %s: %s\n", $name, $nick, $msg); |
857 | } elsif (my $other = cf::player::find_active $target) { |
907 | } elsif (my $other = cf::player::find_active $target) { |
|
|
908 | my $other_channel = { |
|
|
909 | id => "tell-$name", |
|
|
910 | title => "$name", |
|
|
911 | reply => "tell $name ", |
|
|
912 | tooltip => "Private messages from/to $name", |
|
|
913 | }; |
858 | |
914 | |
859 | if ($msg) { |
915 | if ($msg) { |
860 | if ($target eq $name) { |
916 | if ($target eq $name) { |
861 | $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
917 | $ns->send_msg ($pl_channel => "You are talking to yourself, you freak!", reply => 1); |
862 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
918 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
863 | $pl->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
919 | $ns->send_msg ($pl_channel => "$target ignores what you say. Give up on it.", reply => 1); |
864 | } else { |
920 | } else { |
865 | utf8::encode $msg; # ->message not yet utf8-ified |
921 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
866 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
922 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
867 | |
923 | |
868 | $pl->message ("You tell $target: $msg"); |
924 | $ns->send_msg ($pl_channel => "You tell $target: $msg", reply => 1); |
869 | $other->ob->message ("$name tells you: $msg"); |
925 | $other->ns->send_msg ($other_channel => "$name tells you: $msg"); |
870 | $other->ob->{ext_last_tell} = $name; |
|
|
871 | } |
926 | } |
872 | } else { |
927 | } else { |
873 | $pl->message ("What do you want to tell $target?", cf::NDI_UNIQUE); |
928 | $ns->send_msg ($pl_channel => "What do you want to tell $target?"); |
874 | } |
929 | } |
875 | |
930 | |
876 | } else { |
931 | } else { |
877 | $pl->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); |
932 | $ns->send_msg ($pl_channel => "No such player. Your message: $msg"); |
878 | } |
|
|
879 | }; |
|
|
880 | |
|
|
881 | cf::register_command reply => sub { |
|
|
882 | my ($pl, $args) = @_; |
|
|
883 | my $name = $pl->name; |
|
|
884 | |
|
|
885 | utf8::decode $args; |
|
|
886 | |
|
|
887 | return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args); |
|
|
888 | |
|
|
889 | if ($pl->{ext_last_tell} =~ /irc\//) { |
|
|
890 | my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2; |
|
|
891 | $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args"); |
|
|
892 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); |
|
|
893 | } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) { |
|
|
894 | |
|
|
895 | if ($args) { |
|
|
896 | $other->ob->{ext_ignore_tell}{$name} >= time |
|
|
897 | or delete $other->ob->{ext_ignore_tell}{$name}; |
|
|
898 | |
|
|
899 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
|
|
900 | utf8::encode $args; # ->message not yet utf8-ified |
|
|
901 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; |
|
|
902 | |
|
|
903 | $pl->message ("You tell " . $other->ob->name . ": $args"); |
|
|
904 | $other->ob->message ("$name tells you: $args"); |
|
|
905 | $pl->{ext_last_tell} = $other->ob->name; |
|
|
906 | } else { |
|
|
907 | $pl->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
|
|
908 | } |
|
|
909 | } else { |
|
|
910 | $pl->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); |
|
|
911 | } |
|
|
912 | |
|
|
913 | } else { |
|
|
914 | $pl->message ("Can't reply, player left. Your message: $args".$pl->{ext_last_tell}, cf::NDI_UNIQUE); |
|
|
915 | } |
933 | } |
916 | }; |
934 | }; |
917 | |
935 | |
918 | cf::register_command ignore => sub { |
936 | cf::register_command ignore => sub { |
919 | my ($pl, $args) = @_; |
937 | my ($pl, $args) = @_; |
… | |
… | |
996 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
1014 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
997 | } |
1015 | } |
998 | } |
1016 | } |
999 | }; |
1017 | }; |
1000 | |
1018 | |
1001 | cf::register_command seen => sub { |
|
|
1002 | my ($pl, $args) = @_; |
|
|
1003 | |
|
|
1004 | if (my ($login) = $args =~ /(\S+)/) { |
|
|
1005 | if ($login eq $pl->name) { |
|
|
1006 | $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); |
|
|
1007 | } elsif (cf::player::find_active $login) { |
|
|
1008 | $pl->message ("$login is right here on this server!", cf::NDI_UNIQUE); |
|
|
1009 | } elsif (cf::player::exists $login |
|
|
1010 | and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { |
|
|
1011 | my $time = (stat _)[9]; |
|
|
1012 | |
|
|
1013 | $pl->message ("$login was last seen here " |
|
|
1014 | . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) |
|
|
1015 | . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); |
|
|
1016 | } else { |
|
|
1017 | $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE); |
|
|
1018 | } |
|
|
1019 | } else { |
|
|
1020 | $pl->message ("Usage: seen <player>", cf::NDI_UNIQUE); |
|
|
1021 | } |
|
|
1022 | }; |
|
|
1023 | |
|
|