Search code examples
perlircbotspoe

How do I correctly shutdown a Bot::BasicBot bot (based on POE::Component::IRC)?


This is a sample script. When I hit Ctrl+C, the bot quits IRC but it reconnects back after some time. How do I shut down the bot correctly?

#!/usr/bin/perl

package main;

my $bot = Perlbot->new (server => 'irc.dal.net');

$SIG{'INT'} = 'Handler';
$SIG{'TERM'} = 'Handler';

sub Handler {
print "\nShutting down bot...\n";
$bot->shutdown('Killed.');
};

$bot->run;

package Perlbot;
use base qw(Bot::BasicBot);

sub connected {
my $self = shift;
$self->join('#codetestchan');
}

Solution

  • I've taken over maintainership of Bot::BasicBot, and as of version 0.82, you can shut it down properly with $bot->shutdown($quit_message).