mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
Fix auto-rejoin channels when reconnecting
This commit is contained in:
parent
4809341e0f
commit
85fd8397c2
@ -20,6 +20,14 @@ sub initialize {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$self->{storage}->load;
|
$self->{storage}->load;
|
||||||
|
|
||||||
|
# reset joined_channels flag when disconnected
|
||||||
|
$self->{pbot}->{event_dispatcher}->register_handler(
|
||||||
|
'pbot.disconnect',
|
||||||
|
sub {
|
||||||
|
$self->{pbot}->{joined_channels} = 0;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub join {
|
sub join {
|
||||||
@ -59,6 +67,7 @@ sub autojoin {
|
|||||||
|
|
||||||
$self->{pbot}->{logger}->log("Joining channels: $channels\n");
|
$self->{pbot}->{logger}->log("Joining channels: $channels\n");
|
||||||
$self->join($channels);
|
$self->join($channels);
|
||||||
|
|
||||||
$self->{pbot}->{joined_channels} = 1;
|
$self->{pbot}->{joined_channels} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,11 @@ sub on_disconnect {
|
|||||||
$self->{pbot}->{logger}->log("Disconnected...\n");
|
$self->{pbot}->{logger}->log("Disconnected...\n");
|
||||||
$self->{pbot}->{connected} = 0;
|
$self->{pbot}->{connected} = 0;
|
||||||
|
|
||||||
|
# send pbot.disconnect to notify PBot internals
|
||||||
|
$self->{pbot}->{event_dispatcher}->dispatch_event(
|
||||||
|
'pbot.disconnect', undef
|
||||||
|
);
|
||||||
|
|
||||||
# attempt to reconnect to server
|
# attempt to reconnect to server
|
||||||
# TODO: maybe add a registry entry to control whether the bot auto-reconnects
|
# TODO: maybe add a registry entry to control whether the bot auto-reconnects
|
||||||
$self->{pbot}->connect;
|
$self->{pbot}->connect;
|
||||||
|
Loading…
Reference in New Issue
Block a user