Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- ##############
- use strict;
- use warnings;
- #use diagnostics;
- use IO::Socket;
- my $initialized;
- my $botnick ="Bob";
- my $password="password";
- my $server = 'irc.hackthissite.org';
- my @ajoin = ('#bots', '#perl');
- my $authpass= "qwerty";
- my $owner = "!";
- $server=$ARGV[0] if @ARGV;
- my $sock = new IO::Socket::INET(PeerAddr => $server, PeerPort => 6667, Proto => 'tcp') or die "Socket Fault: $!\n";
- # Log on to the server.
- $sock->send("USER $botnick $botnick $botnick $botnick :$botnick\r\n");
- $sock->send("NICK $botnick\r\n");
- $sock->send("privmsg nickserv identify $password\r\n");
- $sock->send("join ". join(',',@ajoin) . "\r\n");
- while (my $input = <$sock>) {
- $input=~s/\r\n//;
- print "$input\n";
- my @data = split(/\s/,$input);
- my $username = ($data[0]=~/^(\S+?)!/);
- if($data[1] eq 'PRIVMSG') {
- my $chan = $data[2];
- my @text = $data[3..$#data];
- $text[0] = substr($text[0],1);
- if($text[0] eq 'die') {
- die;
- }
- elsif($text[0] eq '!join') {
- $sock->send("join ", $text[1]);
- }
- elsif($text[0] eq '!part') {
- $sock->send("part ", $text[1]);
- }
- elsif($text[0] eq '!say') {
- $sock->send("privmsg $chan :", @text[1..$#text]);
- }
- }
- }
- __DATA__
- Argument "" isn't numeric in array element at C:\perl\progs\ircbots\bob.pl line
- 31, <GEN0> line 100.
Add Comment
Please, Sign In to add comment