… | |
… | |
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 | ); |
… | |
… | |
923 | |
925 | |
924 | cf::register_command ignore => sub { |
926 | cf::register_command ignore => sub { |
925 | my ($pl, $args) = @_; |
927 | my ($pl, $args) = @_; |
926 | my ($target, $type, $timeout) = split /\s+/, $args; |
928 | my ($target, $type, $timeout) = split /\s+/, $args; |
927 | |
929 | |
|
|
930 | cf::async { |
928 | if ($args eq "list") { |
931 | if ($args eq "list") { |
929 | clean_timeouts $pl; |
932 | clean_timeouts $pl; |
930 | |
933 | |
931 | if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) |
934 | if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) |
932 | + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { |
935 | + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { |
933 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
936 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
934 | $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); |
937 | $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); |
935 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
938 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
936 | $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); |
939 | $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); |
937 | $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); |
940 | $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); |
|
|
941 | } else { |
|
|
942 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
|
|
943 | } |
|
|
944 | |
|
|
945 | } elsif ($target && $type) { |
|
|
946 | $timeout ne "" or $timeout = 24; |
|
|
947 | my $absolute_timeout = time + $timeout * 3600; |
|
|
948 | |
|
|
949 | if (cf::player::exists $target) { |
|
|
950 | if ($type eq "tell") { |
|
|
951 | $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
952 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
953 | } elsif ($type eq "shout") { |
|
|
954 | $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
955 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
956 | } elsif ($type eq "all") { |
|
|
957 | $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
958 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
959 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
960 | } else { |
|
|
961 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
|
|
962 | } |
|
|
963 | } else { |
|
|
964 | $pl->message ("No such player: $target", cf::NDI_REPLY); |
|
|
965 | } |
|
|
966 | |
938 | } else { |
967 | } else { |
939 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
968 | $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
|
|
969 | . "will ignore a player for <timeout> hours.\n" |
|
|
970 | . "Usage: ignore list\n" |
|
|
971 | . "will show you a list of players currently ignored.", cf::NDI_REPLY); |
940 | } |
972 | } |
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 | } |
973 | }; |
971 | }; |
974 | }; |
972 | |
975 | |
973 | cf::register_command unignore => sub { |
976 | cf::register_command unignore => sub { |
974 | my ($pl, $args) = @_; |
977 | my ($pl, $args) = @_; |
975 | my ($target, $type) = split /\s+/, $args; |
978 | my ($target, $type) = split /\s+/, $args; |
976 | |
979 | |
|
|
980 | cf::async { |
977 | if ($args eq "") { |
981 | if ($args eq "") { |
978 | if ($pl->{ext_ignore_tell}) { |
982 | if ($pl->{ext_ignore_tell}) { |
979 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
983 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
980 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); |
984 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); |
981 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
985 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
982 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); |
986 | $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 { |
987 | } else { |
999 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
988 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
1000 | } |
989 | } |
1001 | } else { |
990 | } else { |
|
|
991 | if (cf::player::exists $target) { |
|
|
992 | if ($type eq "tell") { |
|
|
993 | $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY); |
|
|
994 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
995 | } elsif ($type eq "shout") { |
|
|
996 | $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY); |
|
|
997 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
998 | } elsif ($type eq "all") { |
|
|
999 | $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY); |
|
|
1000 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
1001 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
1002 | } else { |
|
|
1003 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
|
|
1004 | } |
|
|
1005 | } else { |
1002 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); |
1006 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); |
|
|
1007 | } |
1003 | } |
1008 | } |
1004 | } |
1009 | }; |
1005 | }; |
1010 | }; |
1006 | |
1011 | |