Re: How do I shut down a Bot::BasicBot?
by bingos (Vicar) on Jul 16, 2010 at 08:29 UTC
|
#!/usr/bin/perl
package main;
my $bot = Perlbot->new (no_run => 0, server => 'swiftco.dal.net', chan
+nels => ['#randomtestingchannel']);
$SIG{'INT'} = 'Handler';
$SIG{'TERM'} = 'Handler';
sub Handler {
$bot->{_shutdown} = 1;
$bot->shutdown('Leaving.');
};
$bot->run;
package Perlbot;
use POE;
use base qw(Bot::BasicBot);
sub irc_disconnected_state {
my $self = $_[OBJECT];
return if $self->{_shutdown};
$self->SUPER::irc_disconnected_state( @_ );
}
| [reply] [d/l] |
|
Still the same problem :/
| [reply] |
|
#!/usr/bin/perl
package main;
my $bot = Perlbot->new (no_run => 0, server => 'swiftco.dal.net', chan
+nels => ['#randomtestingchannel']);
$SIG{'INT'} = 'Handler';
$SIG{'TERM'} = 'Handler';
sub Handler {
$bot->{_shutdown} = 1;
$bot->shutdown('Leaving.');
};
$bot->run;
package Perlbot;
use strict;
use warnings;
use POE;
use base qw(Bot::BasicBot);
sub irc_disconnected_state {
my $self = $_[OBJECT];
if ( $self->{_shutdown} ) {
$poe_kernel->alarm_remove_all();
$poe_kernel->alias_remove($_) for $poe_kernel->alias_list();
return;
}
$self->SUPER::irc_disconnected_state( @_ );
}
sub irc_error_state {
my $self = $_[OBJECT];
if ( $self->{_shutdown} ) {
$poe_kernel->alarm_remove_all();
$poe_kernel->alias_remove($_) for $poe_kernel->alias_list();
return;
}
$self->SUPER::irc_error_state( @_ );
}
It is icky nasty though. | [reply] [d/l] |
|
Re: How do I shut down a Bot::BasicBot?
by repellent (Priest) on Jul 16, 2010 at 03:52 UTC
|
$poe_kernel->signal($poe_kernel, 'POCOIRC_SHUTDOWN');
| [reply] [d/l] |
|
#!/usr/bin/perl
use POE;
use warnings;
use strict;
my $bot = Perlbot->new (server => 'swiftco.dal.net', channels => ['#ra
+ndomtestingchannel']);
$SIG{'INT'} = 'Handler';
$SIG{'TERM'} = 'Handler';
sub Handler {
$poe_kernel->signal($poe_kernel,'POCOIRC_SHUTDOWN');
};
$bot->run;
package Perlbot;
use base qw(Bot::BasicBot);
It still stays there after disconnecting and then reconnects back to IRC. | [reply] [d/l] |
Re: How do I shut down a Bot::BasicBot?
by SuicideJunkie (Vicar) on Jul 15, 2010 at 14:33 UTC
|
| [reply] [d/l] |
|
exit 0 doesn't send a quit message, and I get the error: (in cleanup) Can't call method "post" on an undefined value at /usr/local/lib/perl5/site_perl/5.10.0/Bot/BasicBot.pm line 1500 during global destruction.
I'm looking for a way to shut it down cleanly.
| [reply] |
|
| [reply] |
|
|
Re: How do I shut down a Bot::BasicBot?
by SuicideJunkie (Vicar) on Jul 16, 2010 at 13:52 UTC
|
Something to consider:
If you're shutting it down anyways, does it really really matter if it shuts down quietly or not?
Worst case, you could (copy locally and then) edit the source, and hack in a terminate flag that will avoid reconnect attempts during the shutdown.
| [reply] |
Re: How do I shut down a Bot::BasicBot?
by Hinrik (Novice) on Mar 26, 2011 at 23:03 UTC
|
As of Bot::BasicBot 0.82, you can shut it down properly with $bot->shutdown($quit_message). That will take care of sending a QUIT message to the IRC server, waiting until the server disconnects you, as well as killing any subprocesses you may have started with the forkit() method. | [reply] [d/l] [select] |