DaWolf has asked for the wisdom of the Perl Monks concerning the following question:
This is the "on_connect" sub:sub start_it { my $irc = new Net::IRC; my $conn = $irc->newconn ( Server => shift || $server, Port => shift || $port, Nick => $botnick, Password => $pass, Ircname => 'My IRC Bot', Username => $botnick ); $conn->{channel} = shift || '#'.$canal; $conn->add_handler('376', \&on_connect); $conn->add_handler('quit', \&on_quit); # Lots of other handlers here, and below the one who should do wha +t I want: $conn->add_handler('disconnect', \&on_disconnect); $irc->start() || die("Impossible to start."); }
and finally this is the on_disconnect sub:sub on_connect { my $conn = shift; $conn->join($conn->{channel}); $conn->{connected} = 1; }
It doesn't log anything, so there are two possibilities here:sub on_disconnect { sleep 30; # Waits for 30 seconds do_runlog(4,""); # Logs that it lost the connection start_it(); # Start over }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Preventing disconnections of an IRC Bot made with Net::IRC
by Anonymous Monk on Dec 07, 2003 at 08:30 UTC | |
by DaWolf (Curate) on Dec 07, 2003 at 08:52 UTC | |
by Anonymous Monk on Dec 07, 2003 at 10:14 UTC | |
|
Re: Preventing disconnections of an IRC Bot made with Net::IRC
by zengargoyle (Deacon) on Dec 07, 2003 at 11:31 UTC |