use Net::IRC; $server = ''; # What IRC server to connect to $nick = ''; # What nick to use when connecting $yournick = ''; # The nick that is to be messaged with the notice $SIG{PWR} = \&PWR_HANDLER; sub PWR_Handler { my $irc = new Net::IRC; my $conn = $irc->newconn(Server=>$server, Port=>6667, Nick=>$nick, I +rcname=>'PerlMonks.org', Username=>'Power Failure') or warn "Can't connect to IRC server.\n"; $conn->add_handler('join', \&on_join); $conn->add_global_handler('disconnect', \&on_disconnect); $conn->add_global_handler(376, \&on_connect); $conn->add_global_handler(433, \&on_nick_taken); $irc->start; } sub on_connect { my $self = shift; $self->privmsg($yournick, "Help me, My power is failing!"); } sub on_disconnect { my ($self, $event) = @_; $self->connect(); } sub on_nick_taken { my $self = shift; $self->nick($nick.int(rand(1302))); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Power Failure Notify via IRC
by dcpve (Sexton) on Aug 25, 2002 at 03:33 UTC | |
by mousey (Scribe) on Aug 25, 2002 at 07:13 UTC |