diff options
author | David Phillips <david@yeah.nah.nz> | 2018-11-24 21:35:25 +1300 |
---|---|---|
committer | David Phillips <david@yeah.nah.nz> | 2018-11-24 21:56:03 +1300 |
commit | 417a2265b463f9e7a695e883b3a26036d03c0dc8 (patch) | |
tree | a5b93e62b1ec64957191bf79187d569653eb8ea4 /Plugin/Rejoin.pm | |
parent | 7f2403aa647e72d83ec00ac596dfbef778945ff0 (diff) | |
download | idalius-417a2265b463f9e7a695e883b3a26036d03c0dc8.tar.xz |
Large refactor - modularise logging, rejoin and join-on-invitation
Diffstat (limited to 'Plugin/Rejoin.pm')
-rw-r--r-- | Plugin/Rejoin.pm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Plugin/Rejoin.pm b/Plugin/Rejoin.pm new file mode 100644 index 0000000..127f5bc --- /dev/null +++ b/Plugin/Rejoin.pm @@ -0,0 +1,34 @@ +package Plugin::Rejoin; + +use strict; +use warnings; + +my $config; +my $root_config; + +sub configure { + my $self = shift; + shift; # cmdref + shift; # run_command + $config = shift; + $root_config = shift; + + return $self; +} + +sub on_kick { + my ($self, $logger, $kicker, $where, $kickee, $why, $irc) = @_; + if ($kickee eq $irc->nick_name) { + $logger->("I was kicked from $where. Rejoining now..."); + $irc->yield(join => $where); + } + return; +} + +sub on_invite { + my ($self, $logger, $who, $where, $irc) = @_; + + $irc->yield(join => $where) if (grep {$_ eq $where} @{$root_config->{channels}}); + return; +} +1; |