aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-03-24 11:49:06 +1300
committerDavid Phillips <david@sighup.nz>2017-03-24 12:17:04 +1300
commit28cd332aa9778f95f8965599d12cbbc252c4424a (patch)
treec858db85959b05c90f3804b4a16c4b77b826d5fc
parent91858f8ac33fc7f61c225b210378f28b85445876 (diff)
downloadidalius-28cd332aa9778f95f8965599d12cbbc252c4424a.tar.xz
Add reconnect command
-rw-r--r--bot.conf.example1
-rwxr-xr-xidalius.pl13
-rw-r--r--sb_config.pm2
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' => '🐍 '
diff --git a/idalius.pl b/idalius.pl
index d998b97..e620ff7 100755
--- a/idalius.pl
+++ b/idalius.pl
@@ -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;