mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-05 03:29:33 +01:00
Plugins/Battleship: attempt to improve board rendering speed: disable IRC pacing, use NOTICE instead of PRIVMSG
This commit is contained in:
parent
20134def36
commit
38985e1ac7
@ -148,7 +148,7 @@ sub cmd_battleship {
|
|||||||
push @{$self->{state_data}->{players}}, $player;
|
push @{$self->{state_data}->{players}}, $player;
|
||||||
|
|
||||||
$self->{pbot}->{event_queue}->enqueue_event(sub {
|
$self->{pbot}->{event_queue}->enqueue_event(sub {
|
||||||
$self->battleship_loop;
|
$self->run_one_state;
|
||||||
}, 1, 'battleship loop', 1
|
}, 1, 'battleship loop', 1
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -372,7 +372,11 @@ sub player_left {
|
|||||||
|
|
||||||
sub send_message {
|
sub send_message {
|
||||||
my ($self, $to, $text, $delay) = @_;
|
my ($self, $to, $text, $delay) = @_;
|
||||||
$delay = 0 if not defined $delay;
|
|
||||||
|
$self->{pbot}->{conn}->notice($to, $text);
|
||||||
|
|
||||||
|
=cut
|
||||||
|
$delay //= 0 if not defined $delay;
|
||||||
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||||
my $message = {
|
my $message = {
|
||||||
nick => $botnick,
|
nick => $botnick,
|
||||||
@ -384,6 +388,7 @@ sub send_message {
|
|||||||
message => $text
|
message => $text
|
||||||
};
|
};
|
||||||
$self->{pbot}->{interpreter}->add_message_to_output_queue($to, $message, $delay);
|
$self->{pbot}->{interpreter}->add_message_to_output_queue($to, $message, $delay);
|
||||||
|
=cut
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run_one_state {
|
sub run_one_state {
|
||||||
@ -916,6 +921,8 @@ sub show_battlefield {
|
|||||||
my $player1 = $self->{player}->[0]->{nick};
|
my $player1 = $self->{player}->[0]->{nick};
|
||||||
my $player2 = $self->{player}->[1]->{nick};
|
my $player2 = $self->{player}->[1]->{nick};
|
||||||
|
|
||||||
|
$self->{pbot}->{conn}->pacing(0);
|
||||||
|
|
||||||
if ($player == 0) {
|
if ($player == 0) {
|
||||||
$self->send_message(
|
$self->send_message(
|
||||||
$self->{player}->[$player]->{nick},
|
$self->{player}->[$player]->{nick},
|
||||||
@ -958,6 +965,9 @@ sub show_battlefield {
|
|||||||
elsif ($player == 2 || $player == 3) { $self->send_message($self->{channel}, $line); }
|
elsif ($player == 2 || $player == 3) { $self->send_message($self->{channel}, $line); }
|
||||||
else { $self->send_message($nick, $line); }
|
else { $self->send_message($nick, $line); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{pbot}->{conn}->pacing(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# state subroutines
|
# state subroutines
|
||||||
|
Loading…
Reference in New Issue
Block a user