diff options
-rw-r--r-- | bot.conf.example | 1 | ||||
-rwxr-xr-x | idalius.pl | 13 | ||||
-rw-r--r-- | sb_config.pm | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/bot.conf.example b/bot.conf.example index 9d6a157..cd5ae2d 100644 --- a/bot.conf.example +++ b/bot.conf.example @@ -9,6 +9,7 @@ ignore = trumpetbot,abusiveuser password = pleffquiffle admins = snargle!~kleg@glarg.example.com must_id = 1 +quit_msg = "Goodbye!" user = nobody group = nobody triggers = 'sa+x' => 'π· ', 'trumpet' => 'πΊ ', 'snake' => 'π ' @@ -30,7 +30,7 @@ $irc->plugin_add('NickServID', POE::Component::IRC::Plugin::NickServID->new( POE::Session->create( package_states => [ - main => [ qw(_default _start irc_001 irc_kick irc_ctcp_action irc_public irc_msg irc_nick) ], + main => [ qw(_default _start irc_001 irc_kick irc_ctcp_action irc_public irc_msg irc_nick irc_disconnected ) ], ], heap => { irc => $irc }, ); @@ -163,9 +163,20 @@ sub irc_msg { $irc->yield(privmsg => $nick => "Syntax: say <channel> <msg>"); } } + if ($what =~ /^reconnect/) { + my ($reason) = $what =~ /^reconnect\s+(.+)$/; + if (!$reason) { + $reason = $config{quit_msg}; + } + $irc->yield(quit => $reason); + } return; } +sub irc_disconnected { + $irc->yield(connect => { }); +} + sub _default { my ($event, $args) = @_[ARG0 .. $#_]; my @output = ( "$event: " ); diff --git a/sb_config.pm b/sb_config.pm index ec3b004..ee816b0 100644 --- a/sb_config.pm +++ b/sb_config.pm @@ -8,7 +8,7 @@ use Config::Tiny; sub parse_config { - my @scalar_configs = ('nick', 'username', 'ircname', 'server', 'port', 'usessl', 'password', 'must_id', 'user', 'group'); + my @scalar_configs = ('nick', 'username', 'ircname', 'server', 'port', 'usessl', 'password', 'must_id', 'quit_msg', 'user', 'group'); my @list_configs = ('channels', 'ignore', 'admins'); my $file = $_[0]; my %built_config; |