From 417a2265b463f9e7a695e883b3a26036d03c0dc8 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sat, 24 Nov 2018 21:35:25 +1300 Subject: Large refactor - modularise logging, rejoin and join-on-invitation --- Plugin/Rejoin.pm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Plugin/Rejoin.pm (limited to 'Plugin/Rejoin.pm') 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; -- cgit v1.1