Guest User

Untitled

a guest
Mar 6th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #!/usr/bin/perl
  2. ##############
  3. use strict;
  4. use warnings;
  5. #use diagnostics;
  6. use IO::Socket;
  7.  
  8. my $initialized;
  9. my $botnick ="Bob";
  10. my $password="password";
  11. my $server = 'irc.hackthissite.org';
  12. my @ajoin = ('#bots', '#perl');
  13. my $authpass= "qwerty";
  14. my $owner = "!";
  15.  
  16. $server=$ARGV[0] if @ARGV;
  17. my $sock = new IO::Socket::INET(PeerAddr => $server, PeerPort => 6667, Proto => 'tcp') or die "Socket Fault: $!\n";
  18.  
  19. # Log on to the server.
  20. $sock->send("USER $botnick $botnick $botnick $botnick :$botnick\r\n");
  21. $sock->send("NICK $botnick\r\n");
  22. $sock->send("privmsg nickserv identify $password\r\n");
  23. $sock->send("join ". join(',',@ajoin) . "\r\n");
  24. while (my $input = <$sock>) {
  25. $input=~s/\r\n//;
  26. print "$input\n";
  27. my @data = split(/\s/,$input);
  28. my $username = ($data[0]=~/^(\S+?)!/);
  29. if($data[1] eq 'PRIVMSG') {
  30. my $chan = $data[2];
  31. my @text = $data[3..$#data];
  32. $text[0] = substr($text[0],1);
  33. if($text[0] eq 'die') {
  34. die;
  35. }
  36. elsif($text[0] eq '!join') {
  37. $sock->send("join ", $text[1]);
  38. }
  39. elsif($text[0] eq '!part') {
  40. $sock->send("part ", $text[1]);
  41. }
  42. elsif($text[0] eq '!say') {
  43. $sock->send("privmsg $chan :", @text[1..$#text]);
  44. }
  45. }
  46. }
  47. __DATA__
  48. Argument "" isn't numeric in array element at C:\perl\progs\ircbots\bob.pl line
  49. 31, <GEN0> line 100.
Add Comment
Please, Sign In to add comment