#!D:\Perl\bin\perl.exe # Sorry everyone, but I did a little commenting, # you should be able to get the jist of it. use Net::AIM; require 'getopts.pl'; my $username = ""; # Put your screenname here my $password = ""; # Put your password here my @to_queue; my @message_queue; my @from_queue; my @time_queue; my $total = 0; my $queue = 0; my $good = 0; ### Make starting timestamp... my ($min,$hour,$mday,$mon,$year)=(localtime)[1,2,3,4,5]; my $minc; if ($min < 10){ $minc = ('01','02','03','04','05','06','07','08','09')[$min]; } else { $minc = $min; } my $monc = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon]; my $yearc = $year + 1900; my $timestamp = "$hour:$minc on $monc $mday, $yearc"; ### my $aim = new Net::AIM; ### Connecting... $aim->newconn(Screenname => $username, Password => $password) or die "Can't connect to AIM server.\n"; my $aim_connection = $aim->getconn; ### ### Setting Handlers... $aim_connection->set_handler('config', \&on_config); $aim_connection->set_handler('error', \&on_error); $aim_connection->set_handler('im_in', \&on_im); $aim_connection->set_handler('update_buddy', \&on_update_buddy); ### $aim->start; # This happens when you sign in... sub on_config { my ($self, $evt, $from, $to) = @_; my $str = shift @{$evt->args()}; $self->set_config_str($str, 1); $self->send_config(); $aim->set_info("Welcome to DumbProxy, an AIM bot that allows you to leave messages for your AIM buddies that are not online at the moment. Feel free to use it anytime you want to leave a message for someone.
Your syntax should be:
BuddyName:Message

Since DumbProxy was started at $timestamp, it has recived $total messages. $good of which were formated corectly and have been placed in the queue. There are $queue messages left in the queue
"); } # Uh-oh, Pasgettios! sub on_error { my ($self, $evt) = @_; my ($error, @stuff) = @{$evt->args()}; my $errstr = $evt->trans($error); $errstr =~ s/\$(\d+)/$stuff[$1]/ge; print STDERR "ERROR: $errstr\n"; } # What we do when we get an instant message, sub on_im { my ($self, $evt, $from, $to) = @_; my $args = $evt->args(); my ($nick, $friend, $msg) = @$args; $total++; chomp($msg); my $stripped = $msg; $stripped =~ s/<[^>]+>//g; $stripped =~ s/^\s+//g; my ($min,$hour,$mday,$mon,$year)=(localtime)[1,2,3,4,5]; my $minc; if ($min < 10){ $minc = ('01','02','03','04','05','06','07','08','09')[$min]; } else { $minc = $min; } $monc = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon]; my $yearc=$year+1900; my $time_stamp = "$hour:$minc on $monc $mday, $yearc"; $self->{_last_msg_dest} = $from; $nick = $self->normalize($from); print "Message recieved from $nick at $time_stamp\n"; if ($stripped =~ /\w+:/){ $bud = $&; $stripped =~ s/$bud//; $bud =~ s/://; $budn= $self->normalize($bud); print " Message is good\n"; push @to_queue,$budn; push @message_queue,$stripped; push @from_queue,$nick; push @time_queue,$time_stamp; $aim_connection->send_im($nick,"You're message has been recieved and will be sent to $bud as soon as they are online. There is no guarantee that the message will get to your buddy. The server could go down, or be bounced or anything else that would prevent the message from getting to them."); $aim->add_buddy(1,'Buddies', @to_queue); $aim->set_info("Welcome to DumbProxy, an AIM bot by Sean Murphy that allows you to leave messages for your AIM buddies that are not online at the moment. Feel free to use it anytime you want to leave a message for someone.
Your syntax should be:
BuddyName:Message

Since DumbProxy was started at $timestamp, it has recived $total messages. $good of which were formatted corectly and have been placed in the queue. There are $queue messages left in the queue
"); $good++; $queue++; } else{ $aim_connection->send_im($nick,"Welcome to DumbProxy, an AIM bot by Sean Murphy that allows you to leave messages for your AIM buddies that are not online at the moment. If you were trying to send a message, your syntax was wrong otherwise feel free to use it anytime you want to leave a message for someone.
Your syntax should be:
BuddyName:Message
"); $aim->set_info("Welcome to DumbProxy, an AIM bot by Sean Murphy that allows you to leave messages for your AIM buddies that are not online at the moment. Feel free to use it anytime you want to leave a message for someone.
Your syntax should be:
BuddyName:Message

Since DumbProxy was started at $timestamp, it has recived $total messages. $good of which were formatted corectly and have been placed in the queue. There are $queue messages left in the queue
"); } } sub on_update_buddy { my ($self, $evt, $from, $to) = @_; my ($nick) = $from; my ($bud, $online, $evil, $signon_time, $idle_amount, $user_class) = @{$evt->args()}; $budn = $self->normalize($bud); if($online eq 'T'){ print "$bud has logged on\n"; $queue_num = 0; while ($queue_num <= $#to_queue){ if ($budn eq @to_queue[$queue_num]){ $aim_connection->send_im($bud,"@from_queue[$queue_num] left a message for you while you were away at @time_queue[$queue_num]. The message reads:

@message_queue[$queue_num]

Thanks for using DumbProxy, an AIM bot that allows you to leave messages for your AIM buddies that are not online at the moment. If @from_queue[$queue_num] or anyone else you want to talk to is not online at the moment please feel free to leave a message for them with it.
"); print " sending queued message to $bud\n"; splice (@to_queue,$queue_num,1); splice (@message_queue,$queue_num,1); splice (@from_queue,$queue_num,1); splice (@time_queue,$queue_num,1); $queue--; } $queue_num++; } } $aim->set_info("Welcome to DumbProxy, an AIM bot by Sean Murphy that allows you to leave messages for your AIM buddies that are not online at the moment. Feel free to use it anytime you want to leave a message for someone.
Your syntax should be:
BuddyName:Message

Since DumbProxy was started at $timestamp, it has recived $total messages. $good of which were formated corectly and have been placed in the queue. There are $queue messages left in the queue
"); }