Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How do I shut down a Bot::BasicBot?

by bingos (Vicar)
on Jul 16, 2010 at 08:29 UTC ( [id://849939]=note: print w/replies, xml ) Need Help??


in reply to How do I shut down a Bot::BasicBot?

This will perhaps work:

#!/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( @_ ); }

Replies are listed 'Best First'.
Re^2: How do I shut down a Bot::BasicBot?
by myuserid7 (Scribe) on Jul 16, 2010 at 08:43 UTC
    Still the same problem :/

      Apologies I missed something whilst looking through Bot::BasicBot's code:

      #!/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.

        After quitting IRC, it says

        ^C (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.

        This was the same error I had after running exit 0 from irc_error_state

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://849939]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-19 04:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found