#A very quick script to check a hotmail account for new mail
#could be coded better, but it works.
#207.82.250.251 is the default IP (duh)
#Coded by Justin Gentry, 9/8/98 - 9/11/98
#Feel free to hack at this all you want, credit would be cool
#but I don't really care.
#Also, this script can be modified to use any existing web-based email
#system with a couple of minor changes changes.  
&tell("Sirc hotmail script by JGentry");
&tell("Usage: hotmail username password");
sub cmd_hotmail
{
 my $HM_IP = "207.82.250.251";
 $_[0] =~ /\w+\s+(\w+)\s+(\w+)/i;
 my $hm_user = $1;
 my $hm_pass = $2;
 my @hm_sender = ();
 if ($hm_user && $hm_pass)
 {
  if(&connect($HOTMAIL, $HM_IP, 80))
  {
   my $hm_line;
   my $hm_mail;
   &tell("Connected to $HM_IP");
   &tell("Checking $hm_user\'s mail");
   #Create the magic line :)
   $hm_mail = 'GET /cgi-bin/start?login='.$hm_user.'&passwd='.$hm_pass.'&enter=Enter&frames=auto&curmbox=ACTIVE&js=yes'."\n";
   #Send the magic info
   print $HOTMAIL $hm_mail;
   #Get the magic info
   while($hm_line = <$HOTMAIL>)
   {
   # &tell($hm_line); Use this if you want to view the webpage
    if ($hm_line =~ /\">([0-9]+.+messages.+[0-9]+.+new)/i) 
    {
     &tell($1); #Should probably store this and output it at the end..
                #oh well
    }
    elsif($hm_line =~ /bgcolor=\"\#eeeecc\"><td>/i)
    {
     $hm_line = $';
     $hm_line =~ s/<img.+=0><.td>//; #remove the new mesg image
     #Clearing out a bunch of HTML crap and storing the wanted 
     #fields
     $' =~ /<input.+name=\"\w+\.\w\"><.td><td>.nbsp;<a.href=\".+len=\d+\">(.+)<.a>.nbsp;<.td><td>.nbsp;(.+)\&nbsp;<.td><td>.nbsp;(.+)\&nbsp;<.td><td.align/i;
     $hm_sender[$#hm_sender+1] = "$1\t$2\t$3";
    }
    if ($hm_line =~ /no\s+new\s+messages/i)
    { &tell("No new messages");}
   }
   my $hm_temp;
   #another improvement would be to format the output
   #correctly..  Long sender names kinda make it messy
   &tell("Sender\t\tDate\tSubject");
   foreach $hm_temp (@hm_sender)
   {&tell($hm_temp);}
   close $HOTMAIL 
   &tell("Connection to $HM_IP closed");
  }
  else {&tell("Error connecting to $HM_IP");}
 }
 else {&tell("Moron.  Usage is user pass");}
}
&addcmd("hotmail");
