Advertisement
Guest User

Untitled

a guest
May 26th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.18 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. ##############
  4. # LoU-Bot     #
  5. # by Zoadian #
  6. ##############
  7.  
  8. #Irc Settings
  9. $IrcServer = 'irc.server.com';
  10. $IrcSrcPort = '1222';
  11. $IrcDstPort = '666';
  12. $IrcNick = '_BOT_';
  13. $IrcUser = 'username hostname servername :realname'; #<username> <hostname> <servername> :<realname>
  14. $IrcPass = 'password';
  15. @IrcChannel = ('##akn');
  16. $IrcAutoRejoin = 'true';#
  17. #Command Settings
  18. $CmdPrefix = '#';
  19. #Function Settings
  20.   #Help
  21.   $help         = 'true';  
  22.   #Trade - want to sell/want to buy
  23.   $wts      = 'true';
  24.   $wtb      = 'true';
  25.  
  26.  
  27.  
  28. use IO::Socket;
  29. use Switch;
  30. use Digest::MD5 qw(md5_hex);
  31.  
  32. #create connection
  33. $con = IO::Socket::INET->new(PeerAddr=>$IrcServer,
  34.               LocalPort => $IrcSrcPort,
  35.               PeerPort=>$IrcDstPort,
  36.               Proto=>'tcp',
  37.               Timeout=>'30') || print "Error: Connection";
  38. #set user
  39. print $con "PASS $IrcPass\n";
  40. print $con "USER $IrcUser\n";
  41. print $con "NICK $IrcNick\n";
  42. #join channels
  43. foreach my $channel (@IrcChannel){
  44.   print $con "JOIN $channel\n";
  45. }
  46. #get msgs
  47. while(my $answer = <$con>)
  48. {
  49.   print "$answer\n";#output all
  50.   #split msg
  51.   if($answer =~ m/^:(.*?)!(.*?)@(.*?) PRIVMSG (.*?) :(.*?)$/)
  52.   {
  53.     #just set up some variables to store information
  54.     $recvNick = $1;
  55.     $recvIdent = $2;
  56.     $recvHost = $3;
  57.     $recvChannel = $4;
  58.     $recvText = $5;
  59.     @strpart = split(" ",$recvText);  
  60.     $strpart[0] = "";
  61.     $msg = join ' ', @strpart;
  62.   }
  63.   if ($answer=~ m/^PING (.*?)$/gi) {print $con "PONG $1\n";} ;
  64.  
  65.  
  66. #############
  67. # Functions #
  68. #############
  69.  
  70.   #Print Help
  71.   if( $help         == 'true' && $answer =~ m/($CmdPrefix)help/ )
  72.   {
  73.     #Help
  74.     if($help         == 'true'){print $con "PRIVMSG $recvNick :" . $CmdPrefix . "help\n";}
  75.     #trade
  76.     if($wts         == 'true'){print $con "PRIVMSG $recvNick :" . $CmdPrefix . "wts wood 50k\n";}
  77.     if($wtb         == 'true'){print $con "PRIVMSG $recvNick :" . $CmdPrefix . "wtb stone 50k\n";}
  78.   }
  79.    
  80.   #Want to sell
  81.   if( $wts         == 'true' && $answer =~ m/($CmdPrefix)wts/ ){
  82.     #do stuff here
  83.   }
  84.  
  85.   #Want to buy
  86.   if( $wts         == 'true' && $answer =~ m/($CmdPrefix)wts/ ){
  87.     #du stuff here
  88.   }
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement