aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2018-10-02 17:03:00 +1300
committerDavid Phillips <david@yeah.nah.nz>2018-10-02 17:03:00 +1300
commit7aa9d419bc1d4a0f9e6cc369b06dd54c606df20b (patch)
tree89afcb09e4bd2074e5aae5a327c52dd81b525273
parent765205d27f19ff2b4484336b570937feaedd8643 (diff)
downloadidalius-7aa9d419bc1d4a0f9e6cc369b06dd54c606df20b.tar.xz
Add rejoin delay, reconfigure modules on reconnection
-rwxr-xr-xidalius.pl40
1 files changed, 28 insertions, 12 deletions
diff --git a/idalius.pl b/idalius.pl
index d6b0c06..031d39e 100755
--- a/idalius.pl
+++ b/idalius.pl
@@ -25,15 +25,7 @@ sub log_info {
Plugin::set_load_callback(\&module_loaded_callback);
-eval {
- for my $module (@{$config->{_}->{plugins}}) {
- Plugin::load_plugin(\&log_info, $config->{_}, $module);
- }
- 1;
-} or do {
- log_info "Error: failed to load module: $@";
- die;
-};
+load_configure_all_plugins();
$| = 1;
@@ -82,6 +74,18 @@ drop_priv();
$poe_kernel->run();
+sub load_configure_all_plugins {
+ eval {
+ for my $module (@{$config->{_}->{plugins}}) {
+ Plugin::load_plugin(\&log_info, $config->{_}, $module);
+ }
+ 1;
+ } or do {
+ log_info "Error: failed to load module: $@";
+ die;
+ };
+}
+
sub module_loaded_callback {
my ($module) = @_;
@@ -283,20 +287,32 @@ sub irc_invite {
$irc->yield(join => $where) if (grep {$_ eq $where} @{$config->{_}->{channels}});
}
+sub reconnect {
+ my $reconnect_delay = 20;
+
+ log_info("Reconnecting in $reconnect_delay seconds");
+ sleep($reconnect_delay);
+
+ $irc->yield(connect => { });
+}
+
sub irc_disconnected {
_default(@_); # Dump the message
+ my $reconnect_delay = 20;
+
$config = IdaliusConfig::parse_config($config_file);
- $irc->yield(connect => { });
+ load_configure_all_plugins();
+ reconnect();
}
sub irc_error {
_default(@_); # Dump the message
- $irc->yield(connect => { });
+ reconnect();
}
sub irc_socketerr {
_default(@_); # Dump the message
- $irc->yield(connect => { });
+ reconnect();
}
sub _default {