mirror of
				https://github.com/pragma-/pbot.git
				synced 2025-11-04 08:37:24 +01:00 
			
		
		
		
	Plugins: Weather and Wttr now use LWPUserAgentCached
This commit is contained in:
		
							parent
							
								
									609523fd67
								
							
						
					
					
						commit
						96fbf4c420
					
				@ -14,7 +14,7 @@ use strict;
 | 
			
		||||
 | 
			
		||||
use feature 'unicode_strings';
 | 
			
		||||
 | 
			
		||||
use LWP::UserAgent::WithCache;
 | 
			
		||||
use PBot::Utils::LWPUserAgentCached;
 | 
			
		||||
use XML::LibXML;
 | 
			
		||||
use Getopt::Long qw(GetOptionsFromString);
 | 
			
		||||
use Carp ();
 | 
			
		||||
@ -83,7 +83,7 @@ sub get_weather {
 | 
			
		||||
    'default_expires_in' => 3600
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  my $ua = LWP::UserAgent::WithCache->new(\%cache_opt, timeout => 10);
 | 
			
		||||
  my $ua = PBot::Utils::LWPUserAgentCached->new(\%cache_opt, timeout => 10);
 | 
			
		||||
  my $response = $ua->get("http://rss.accuweather.com/rss/liveweather_rss.asp?metric=0&locCode=$location");
 | 
			
		||||
 | 
			
		||||
  my $xml;
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ use utf8;
 | 
			
		||||
use feature 'switch';
 | 
			
		||||
no if $] >= 5.018, warnings => "experimental::smartmatch";
 | 
			
		||||
 | 
			
		||||
use LWP::UserAgent::WithCache;
 | 
			
		||||
use PBot::Utils::LWPUserAgentCached;
 | 
			
		||||
use JSON;
 | 
			
		||||
use Getopt::Long qw(GetOptionsFromString);
 | 
			
		||||
use URI::Escape qw/uri_escape_utf8/;
 | 
			
		||||
@ -121,7 +121,7 @@ sub get_wttr {
 | 
			
		||||
 | 
			
		||||
  my $location_uri = uri_escape_utf8 $location;
 | 
			
		||||
 | 
			
		||||
  my $ua = LWP::UserAgent::WithCache->new(\%cache_opt, timeout => 10);
 | 
			
		||||
  my $ua = PBot::Utils::LWPUserAgentCached->new(\%cache_opt, timeout => 10);
 | 
			
		||||
  my $response = $ua->get("http://wttr.in/$location_uri?format=j1&m");
 | 
			
		||||
 | 
			
		||||
  my $json;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user