]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/Exchange.pl
ws
[infobot.git] / src / Modules / Exchange.pl
index 5cba512fb0d1ed6c3df5f157d5079ae63f9d48d3..ae8470f3e85f2f8cf74796793ab3e01385d1f97a 100644 (file)
@@ -277,7 +277,7 @@ sub exchange {
     my ($message) = @_;
     &::DEBUG("exchange(@_)");
 
-    return "Exchange.pl needs LWP::UserAgent and HTTP::Request::Common" 
+    return "Exchange.pl needs LWP::UserAgent and HTTP::Request::Common"
        if ($no_exchange);
 
     my ($From, $To, $Amount, $Country);
@@ -293,7 +293,9 @@ sub exchange {
     }
 
     my $ua = new LWP::UserAgent;
-    $ua->agent("Mozilla/4.5 " . $ua->agent);        # Let's pretend
+    # Let's pretend
+    #$ua->agent("Mozilla/5.0 " . $ua->agent);
+    $ua->agent("Mozilla/5.0");
     $ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy"));
     $ua->timeout(10);
 
@@ -315,7 +317,7 @@ sub exchange {
 
     if ($Country) {
        # Country lookup
-       # crysflame++ for the space fix. 
+       # crysflame++ for the space fix.
        $retval = '';
        foreach my $Found (grep /$Country/i, keys %CurrLookup){
            $Found =~ s/,/ uses/g;
@@ -354,9 +356,11 @@ sub exchange {
            # Falsify where we came from
            $req->referer($Referer);
 
-           my $res = $ua->request($req);                   # Submit request
+           # Submit request
+           my $res = $ua->request($req);
 
-           if ($res->is_success) {                         # Went through ok
+           if ($res->is_success) {
+               # Went through ok
                my $html = $res->as_string;
                # parse each one to avoid undefined warnings
                my ($When) = ($html =~ m/ as of (\d{4}\.\d\d.\d\d\s\d\d:\d\d:\d\d\s\S+)/gi);
@@ -366,12 +370,13 @@ sub exchange {
                #    grep /\S+/, ($html =~ m/ as of (\d{4}\.\d\d.\d\d\s\d\d:\d\d:\d\d\s\S+)|(\d[\d,.]+)\s*$From|(\d[\d,.]+)\s* $To/gi);
 
                if ($When) {
-                   return "http://www.xe.com/ $Cfrom $Currencies{$From} makes ".
-                       "$Cto $Currencies{$To}"; # ." ($When)\n";
+                   return "$Cfrom $Currencies{$From} makes ".
+                       "$Cto $Currencies{$To} (from http://www.xe.com/)"; # ." ($When)\n";
                } else {
                    return "i got some error trying that";
                }
-           } else {                                        # Oh dear.
+           } else {
+               # Oh dear.
                return "EXCHANGE: ". $res->status_line;
            }
        } else {