Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Power Failure Notify via IRC

by mousey (Scribe)
on Aug 23, 2002 at 13:53 UTC ( #192328=CUFP: print w/replies, xml ) Need Help??

This code is the follow up to my other node that people seemed to like. Next up will be a power failure notifier via MSN.
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
    Next up will be a power failure notifier via MSN.

    Why create a separate version for each IM service? Instead of that approach, you could merge them all together into one script that includes an argument that specifies which service or services to use. Something like

    perl pwr_fail.pl -{A|I|M}

    where A uses AIM, I for IRC, M for MSN, etc, would be, in my opinion, more user-friendly than three or four separate scripts.


    dcpve - Just a noder/perl hacker
      Well, I would do this, but you probably didn't notice, but these are merely snippets, not a full program (snippets or cool use for perl? i vote cool). Although, at some point, I will incorporate an entire script that runs as a daemon that will do all of them, depending on arguments. I will post the MSN notifier soon. The reason I have not completed it sooner, is because MSN.pm only allows you to reply to IMs, not send them out. So, i'm gonna hack it up.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://192328]
Approved by Mr. Muskrat
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2022-11-29 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?