Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use IO::Socket::INET6;
- our $server = "irc.freenode.net";
- our $port = "6667";
- our $channel = "#ubuntu";
- our $nick = "GaryNiger";
- our $phrases = "autism.txt";
- our $chatdelay = 500; #base chat delay, modified by "chattiness" of a channel
- our $delaymodifier = 10; #time subtracted from chatdelay every time a line is chatted
- open FILE, "<$phrases" or die "Could not open $phrases: $!\n";
- our @chats=<FILE>;
- close FILE;
- print "*** Connecting to ".$server.":".$port."...\r\n";
- our $sock = IO::Socket::INET6->new(PeerAddr => $server,
- PeerPort => $port,
- Proto => 'tcp');
- print "*** Connected!\r\n";
- print "*** Registering as ".$nick."...\r\n";
- print $sock "NICK ".$nick."\r\n";
- print $sock "USER ".$nick." 8 * :".$nick.".\r\n";
- while ( my $input = <$sock> ) {
- if ( $input =~ /004/ ) {
- last;
- }
- elsif ( $input =~ /433/ ) {
- die "Nickname is already in use.";
- }
- }
- print "*** Joining ".$channel." and resetting timers...\r\n";
- print $sock "JOIN $channel\r\n";
- our $lastchat = time();
- while ( my $input = <$sock> ) {
- chop $input;
- our $interval = ($chatdelay-(time()-$lastchat));
- our $Hours = int($interval/3600);
- our $Minutes = int(($interval - $Hours * 3600) / 60);
- our $Seconds = $interval % 60;
- print "-> [Delay: ".$Hours."h".$Minutes."m".$Seconds."s] ".$input."\n";
- if ( $input =~ /^PING(.*)$/i ) {
- print $sock "PONG $1\r\n";
- print "<- PONG ".$1." \r\n";
- }
- if ( $input =~ /bot.do/ ) {
- chop $input;
- our @dongmax = split('bot.do ', $input);
- print $sock $dongmax[1]."\r\n";
- print "<- ".$dongmax[1]."\r\n";
- }
- if ( $input !~ /freenode\/staff/ ) {
- if ( $input =~ /PRIVMSG/ ) {
- if ( time()-$lastchat > $chatdelay ) {
- our @loljews = split(':', $input);
- our @chatter = split('!',$loljews[1]);
- our $delay = int(rand(15)+5);
- our $randomline=$chats[rand @chats];
- chop $randomline;
- print "*** Replying to ".$chatter[0]." in ".$delay." seconds with '".$randomline."'.\r\n";
- sleep $delay;
- print $sock "PRIVMSG ".$channel." :".$chatter[0].": ".$randomline."\r\n";
- print "<- PRIVMSG ".$channel." :".$chatter[0].": ".$randomline."\r\n";
- $lastchat = time();
- } else {
- $lastchat = $lastchat-$delaymodifier;
- }
- }
- }
- if ( $input =~ /bot.fire/ ) {
- $lastchat = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement