diff options
author | David Phillips <david@sighup.nz> | 2019-06-22 23:04:09 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2019-06-22 23:53:33 +1200 |
commit | 8c862af5a181a601e871cff8244d164da743a8f7 (patch) | |
tree | 61ae7d6937d042bb20c7a275b8098ec95b187ba1 | |
parent | a76c61351eabb72f5dbb5f75394850e06f558487 (diff) | |
download | idalius-8c862af5a181a601e871cff8244d164da743a8f7.tar.xz |
Evict auto-joining of channels to module
-rw-r--r-- | IdaliusConfig.pm | 2 | ||||
-rw-r--r-- | Plugin/Autojoin.pm | 23 | ||||
-rw-r--r-- | Plugin/Log.pm | 3 | ||||
-rw-r--r-- | bot.conf.example | 6 | ||||
-rwxr-xr-x | idalius.pl | 10 |
5 files changed, 35 insertions, 9 deletions
diff --git a/IdaliusConfig.pm b/IdaliusConfig.pm index 642d408..3f919b6 100644 --- a/IdaliusConfig.pm +++ b/IdaliusConfig.pm @@ -48,7 +48,7 @@ sub check_config # Lists of mandatory config variables my @scalars = qw/nick username ircname server port usessl sslcert sslkey user group prefix_nick prefix log_debug/; - my @lists = qw/plugins channels ignore/; + my @lists = qw/plugins ignore/; foreach my $name (@scalars) { assert_scalar($config->{_}, "_", $name); diff --git a/Plugin/Autojoin.pm b/Plugin/Autojoin.pm new file mode 100644 index 0000000..0620ecd --- /dev/null +++ b/Plugin/Autojoin.pm @@ -0,0 +1,23 @@ +package Plugin::Autojoin; + +use strict; +use warnings; + +my $config; + +sub configure { + my $self = shift; + shift; # cmdref + shift; # run_command + $config = shift; + shift; # root config + + return $self; +} + +sub on_001 { + my ($self, $logger, $server, $message, $irc) = @_; + $irc->yield(join => $_) for @{$config->{channels}}; + return; +} +1; diff --git a/Plugin/Log.pm b/Plugin/Log.pm index 1d69e51..135cd85 100644 --- a/Plugin/Log.pm +++ b/Plugin/Log.pm @@ -14,6 +14,7 @@ my %t = ( nick => color("cyan"), info => color("yellow"), kick => color("red"), + host => color("magenta"), channel => color("blue"), message => color("reset"), misc => color("bright_black"), @@ -33,7 +34,7 @@ sub configure { # FIXME Not triggered yet sub on_001 { my ($self, $logger, $server, $message, $irc) = @_; - $logger->("$t{info}Connected to ${host}$server$t{info} --- \"$t{message}$message$t{info}\"$t{reset}"); + $logger->("$t{info}Connected to $t{host}$server$t{info} --- \"$t{message}$message$t{info}\"$t{reset}"); } sub on_message { diff --git a/bot.conf.example b/bot.conf.example index 143ad4c..4dba20b 100644 --- a/bot.conf.example +++ b/bot.conf.example @@ -1,4 +1,4 @@ -plugins = [ Plugin::Titillate, Plugin::Admin, Plugin::Ping ] +plugins = [ Plugin::Autojoin, Plugin::Titillate, Plugin::Admin, Plugin::Ping ] nick = somebot username = bot ircname = a bot @@ -7,7 +7,6 @@ port = 6667 usessl = 1 sslcert = foo.crt sslkey = foo.key -channels = [ #saxtalk, #bot] ignore = [trumpetbot, abusiveuser] password = pleffquiffle user = nobody @@ -16,6 +15,9 @@ prefix_nick = 1 prefix = % log_debug = 0 +[Plugin::Autojoin] +channels = [ #saxtalk, #bot ] + [Plugin::Admin] admins = [ snargle!~kleg@glarg.example.com ] must_id = 1 @@ -312,13 +312,13 @@ sub _start { } sub irc_001 { - my ($irc, $sender) = @_[KERNEL, SENDER]; - my $heap = $sender->get_heap(); + my ($poek, $server, $message) = @_[KERNEL, ARG0, ARG1]; + my @empty = (); - log_info("Connected to server ", $heap->server_name()); + trigger_modules("001", undef, undef, \@empty, ($server, $message)); - $heap->yield(join => $_) for @{$config->{_}->{channels}}; - $irc->delay(custom_ping => $ping_delay); + # FIXME move to forward ping module + $poek->delay(custom_ping => $ping_delay); return; } |