#!/usr/local/bin/perl ## ircnotice.pl [a client to tell the channel an 1-line-message] ## version: 0.02 (last modified at 02/03/06) ## Copyright (C) 2002, Ichikawa Hiromitsu (h-i@bigfoot.com) # ############# use IO::Socket; ############################ ## user settings ## $ircserver="irc.server.domain"; # irc server $ircport='6666'; # irc port $ircnick="robot"; # irc nickname for this robot $ircpasswd=""; # irc password for connection (option) $ircrealname="Version Robot"; # irc realname $ircchannel="#mychannel"; # join the channel and watch it $leavechannel="NO"; # "YES" if you leave the channel after sending the message ## ## end of setting ############################# ################ don't change after this ########## if($#ARGV<0){ print "usage: perl ircnotice.pl \"MESSAGE\"\n"; exit(); } $message=$ARGV[0]; undef $sock; for($i=0;$i<5;$i++){ print "*** Connecting... ***\n"; $sock= IO::Socket::INET->new(PeerAddr => $ircserver, PeerPort => $ircport, Proto => 'tcp'); last if(defined $sock); sleep(2); } if(!defined $sock){ print "---- Cannot Connect ----\n"; exit(); } print "++++ Connected ++++\n"; # send nickname $buf="nick $ircnick\r\n"; $sock->send($buf); # send password to connect (option) if($ircpasswd ne ""){ $buf="pass $ircpasswd\r\n"; $sock->send($buf); } # send user $buf="user $ircnick hostname $ircserver: $ircrealname\r\n"; $sock->send($buf); $sock->recv($buf,10000); print "++++ sending request ++++\n"; # send join to join the target channel $buf="join $ircchannel\r\n"; $sock->send($buf); #$sock->recv($buf,10000); # send message $buf="PRIVMSG $ircchannel :$message\r\n"; $sock->send($buf); #$sock->recv($buf,10000); print "++++ request sent ++++\n"; # leave the channel if($leavechannel eq "YES"){ $buf="part $ircchannel\r\n"; $sock->send($buf); $sock->recv($buf,10000); } # quit $buf="quit :bye\r\n"; $sock->send($buf); #$sock->recv($buf,10000); # close the socket $sock->close(); # exit print "++++ Connection Closed ++++\n"; exit(); #########################EOF################