… | |
… | |
54 | cf::player->attach ( |
54 | cf::player->attach ( |
55 | prio => -1000, |
55 | prio => -1000, |
56 | on_login => sub { |
56 | on_login => sub { |
57 | my ($pl) = @_; |
57 | my ($pl) = @_; |
58 | |
58 | |
|
|
59 | cf::async { |
59 | clean_timeouts $pl->ob; |
60 | clean_timeouts $pl->ob; |
|
|
61 | }; |
60 | |
62 | |
61 | $pl->send_msg ($cf::SAY_CHANNEL); |
63 | $pl->send_msg ($cf::SAY_CHANNEL); |
62 | $pl->send_msg ($cf::CHAT_CHANNEL); |
64 | $pl->send_msg ($cf::CHAT_CHANNEL); |
63 | }, |
65 | }, |
64 | ); |
66 | ); |
… | |
… | |
803 | my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; |
805 | my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; |
804 | my ($reply, @kw) = $dialog->tell ($msg); |
806 | my ($reply, @kw) = $dialog->tell ($msg); |
805 | |
807 | |
806 | if (defined $reply) { |
808 | if (defined $reply) { |
807 | if ($npc->type == cf::MAGIC_EAR) { |
809 | if ($npc->type == cf::MAGIC_EAR) { |
808 | if (length $reply) { |
|
|
809 | send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" |
810 | send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" |
810 | for @plonmap; |
811 | for @plonmap; |
811 | } |
|
|
812 | $npc->use_trigger; |
|
|
813 | } else { |
812 | } else { |
814 | if (length $reply) { |
|
|
815 | send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" |
813 | send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" |
816 | for @plonmap; |
814 | for @plonmap; |
817 | } |
|
|
818 | } |
815 | } |
819 | } |
816 | } |
820 | |
817 | |
821 | if (@kw) { |
818 | if (@kw) { |
822 | $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
819 | $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
… | |
… | |
923 | |
920 | |
924 | cf::register_command ignore => sub { |
921 | cf::register_command ignore => sub { |
925 | my ($pl, $args) = @_; |
922 | my ($pl, $args) = @_; |
926 | my ($target, $type, $timeout) = split /\s+/, $args; |
923 | my ($target, $type, $timeout) = split /\s+/, $args; |
927 | |
924 | |
|
|
925 | cf::async { |
928 | if ($args eq "list") { |
926 | if ($args eq "list") { |
929 | clean_timeouts $pl; |
927 | clean_timeouts $pl; |
930 | |
928 | |
931 | if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) |
929 | if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) |
932 | + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { |
930 | + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { |
933 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
931 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
934 | $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); |
932 | $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); |
935 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
933 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
936 | $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); |
934 | $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); |
937 | $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); |
935 | $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); |
|
|
936 | } else { |
|
|
937 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
|
|
938 | } |
|
|
939 | |
|
|
940 | } elsif ($target && $type) { |
|
|
941 | $timeout ne "" or $timeout = 24; |
|
|
942 | my $absolute_timeout = time + $timeout * 3600; |
|
|
943 | |
|
|
944 | if (cf::player::exists $target) { |
|
|
945 | if ($type eq "tell") { |
|
|
946 | $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
947 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
948 | } elsif ($type eq "shout") { |
|
|
949 | $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
950 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
951 | } elsif ($type eq "all") { |
|
|
952 | $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
953 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
954 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
955 | } else { |
|
|
956 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
|
|
957 | } |
|
|
958 | } else { |
|
|
959 | $pl->message ("No such player: $target", cf::NDI_REPLY); |
|
|
960 | } |
|
|
961 | |
938 | } else { |
962 | } else { |
939 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
963 | $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
|
|
964 | . "will ignore a player for <timeout> hours.\n" |
|
|
965 | . "Usage: ignore list\n" |
|
|
966 | . "will show you a list of players currently ignored.", cf::NDI_REPLY); |
940 | } |
967 | } |
941 | |
|
|
942 | } elsif ($target && $type) { |
|
|
943 | |
|
|
944 | $timeout ne "" or $timeout = 24; |
|
|
945 | my $absolute_timeout = time + $timeout * 3600; |
|
|
946 | |
|
|
947 | if (cf::player::exists $target) { |
|
|
948 | if ($type eq "tell") { |
|
|
949 | $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
950 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
951 | } elsif ($type eq "shout") { |
|
|
952 | $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
953 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
954 | } elsif ($type eq "all") { |
|
|
955 | $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
956 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
957 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
958 | } else { |
|
|
959 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
|
|
960 | } |
|
|
961 | } else { |
|
|
962 | $pl->message ("No such player: $target", cf::NDI_REPLY); |
|
|
963 | } |
|
|
964 | |
|
|
965 | } else { |
|
|
966 | $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
|
|
967 | . "will ignore a player for <timeout> hours.\n" |
|
|
968 | . "Usage: ignore list\n" |
|
|
969 | . "will show you a list of players currently ignored.", cf::NDI_REPLY); |
|
|
970 | } |
968 | }; |
971 | }; |
969 | }; |
972 | |
970 | |
973 | cf::register_command unignore => sub { |
971 | cf::register_command unignore => sub { |
974 | my ($pl, $args) = @_; |
972 | my ($pl, $args) = @_; |
975 | my ($target, $type) = split /\s+/, $args; |
973 | my ($target, $type) = split /\s+/, $args; |
976 | |
974 | |
|
|
975 | cf::async { |
977 | if ($args eq "") { |
976 | if ($args eq "") { |
978 | if ($pl->{ext_ignore_tell}) { |
977 | if ($pl->{ext_ignore_tell}) { |
979 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
978 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
980 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); |
979 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); |
981 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
980 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
982 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); |
981 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); |
983 | } else { |
|
|
984 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
|
|
985 | } |
|
|
986 | } else { |
|
|
987 | if (cf::player::exists $target) { |
|
|
988 | if ($type eq "tell") { |
|
|
989 | $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY); |
|
|
990 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
991 | } elsif ($type eq "shout") { |
|
|
992 | $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY); |
|
|
993 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
994 | } elsif ($type eq "all") { |
|
|
995 | $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY); |
|
|
996 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
997 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
998 | } else { |
982 | } else { |
999 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
983 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
1000 | } |
984 | } |
1001 | } else { |
985 | } else { |
|
|
986 | if (cf::player::exists $target) { |
|
|
987 | if ($type eq "tell") { |
|
|
988 | $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY); |
|
|
989 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
990 | } elsif ($type eq "shout") { |
|
|
991 | $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY); |
|
|
992 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
993 | } elsif ($type eq "all") { |
|
|
994 | $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY); |
|
|
995 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
996 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
997 | } else { |
|
|
998 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
|
|
999 | } |
|
|
1000 | } else { |
1002 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); |
1001 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); |
|
|
1002 | } |
1003 | } |
1003 | } |
1004 | } |
1004 | }; |
1005 | }; |
1005 | }; |
1006 | |
1006 | |