User Control Panel
Advertisements

HELP US, HELP YOU!

A problem with a weather command

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
JTW
God Like
God Like


Joined: 07 Mar 2004
Posts: 582
Location: Maidstone
Reputation: 73.3
votes: 4

PostPosted: Tue Jun 21, 2005 3:55 pm    Post subject: A problem with a weather command Reply with quote

Hey, A while ago someone (forgotten who now) placed a weather command on here it worked world wide till weather.com change their page designs. Anyway i have edited it so it will work but it gives me a strange output (see pic below) does anyone have any code i could use to fix this, or replace it with or a way to make it work?

Code:
use LWP::Simple;

sub weather {
my ($bot,$self, $user, $name, $msg, $color) = @_;
my $field = {};
my $deg = decode_base64("wrA=");



$field->{query} = "Please wait while I get the information."
  .                 "\nProvided by http://www.weather.com";
$field->{error} = "Sorry there's no state/zip code with '$msg' according to weather.com";

unless($msg) {
$self->sendMessage( "-error- The command is in the wrong format. it should be !weather <City Name>", Color => b23ce);
return;
}

  $self->sendMessage($field->{query}, Color => c4285f);
  $field->{XML} = get( "http://xoap.weather.com/search/search?where=$msg" );

if(!$field->{XML}) {
$self->sendMessage("Sorry the server seems to be down", Color => b23ce);
return;
}

if($field->{XML} =~ m,<loc id="(.*?)",mgo) { $field->{LOCID} = $1; }   
  print "Got LOCATION ID. ($field->{LOCID})" . "\n" . "Getting Weather.";
 
  $field->{HTML} = get("http://www.w3.weather.com/outlook/travel/local/$field->{LOCID}");
  $field->{HTML} =~ s/\n//g;
 
while($field->{HTML} =~ m,<B STYLE="color:#3A5B29;">(.*?)</B>,mgo)
{ $field->{conditions} = $1; }

while($field->{HTML} =~ m,<TD VALIGN="top" align="left"  STYLE="padding:0px 0px 0px 10px;">(.*?)<TD colspan="3" valign="top">,mgo)
{ $field->{Results} = $1; }
 
  $field->{Results} =~ s/<\/TD><\/TR>|<B CLASS=obsTextA>/\n/g;
  $field->{Results} =~ s/<\/TD>|<BR>|&nbsp;//g;
  $field->{Results} =~ s/<(.|\n)+?>//g;
  $field->{Results} =~ s/&deg;/$deg/g;
  $field->{Results} =~ s/UV Index:/UV Index:/g;
  $field->{Results} =~ s/\s+$//g;
   
unless($field->{Results})
{ $self->sendMessage($field->{error}, Color => b23ce); return;
  }
  print "$field->{conditions}\n\n$field->{Results}\n";
    $self->sendMessage("Weather results for $msg.\n$field->{Results}", Color => 0);

};




Soz about the image if i copied and pasted the ouput it would not appear the same
Back to top
JTW
God Like
God Like


Joined: 07 Mar 2004
Posts: 582
Location: Maidstone
Reputation: 73.3
votes: 4

PostPosted: Sun Jun 26, 2005 2:37 am    Post subject: Reply with quote

sorry but 5 days no replies

*Bump*
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Sun Jun 26, 2005 10:53 am    Post subject: Reply with quote

http://www.bot-depot.com/forums/index.php?showtopic=37

Stop asking stupid you-could-google-it questions.

_________________
~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group