Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #############################################################
- #IRC Bot: receives and sends input to and fro the IRC server.
- #############################################################
- #!/usr/bin/perl
- use warnings;
- use threads;
- use IO::Socket::INET;
- $serv = "your.server.here";
- $chan = "#yourChannel";
- $ident = "yourIdent";
- $nick = "yourNick";
- $IRC = new IO::Socket::INET(
- PeerAddr => $serv,
- PeerPort => '6667',
- Proto => 'tcp')
- or die "Could not establish connection to IRC server: $!\n";
- print $IRC "USER $ident $ident $ident $ident : $nick\n";
- print $IRC "NICK $nick\n";
- print $IRC "JOIN $chan\n";
- $thread = threads->new(\&getInput); #Start thread (get input)
- $in;
- ##########MAIN LOOP START#################
- while($in = <$IRC> ) {
- print "$in\n";
- if($in =~ /PING(.*)/) {
- print $IRC "PONG $1\n";
- }
- }
- ###########MAIN LOOP END##################
- sub getInput {
- while(true) {
- $input = <STDIN>;
- if($input =~ /QUIT\b/) {
- print "Quiting!";
- close($IRC);
- die "Quit on user command.";
- }
- print $IRC "PRIVMSG $chan : $input";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement