NuWeather: replace Dark Sky with Pirate Weather

Co-Authored-By: jithatsonei <me@ji.wtf>
This commit is contained in:
James Lu 2023-03-07 23:31:07 -08:00
parent 6ca827d30f
commit 1b3ce50abe
3 changed files with 12 additions and 12 deletions

View File

@ -6,7 +6,7 @@ A weather plugin for Limnoria. It supports multiple weather and geocoding backen
- [OpenWeatherMap](https://openweathermap.org/) (default, API key required)
- [WWIS](https://worldweather.wmo.int/) (**no** API key required, major cities only)
- [weatherstack](https://weatherstack.com/) (current conditions only, API key required)
- [Dark Sky](https://darksky.net) (**DEPRECATED**: API key required; new signups closed)
- [Pirate Weather](https://pirateweather.net/) (API key required)
#### Geocoding Backends
- [OpenStreetMap Nominatim](https://nominatim.openstreetmap.org/) (default, no API key required)
@ -17,9 +17,9 @@ A weather plugin for Limnoria. It supports multiple weather and geocoding backen
1) Pick your preferred weather backend: `config help plugins.NuWeather.defaultBackend`
2) Grab an API key. [OpenWeatherMap](https://openweathermap.org/appid) | [weatherstack](https://weatherstack.com/) | ~~[Dark Sky](https://darksky.net/dev)~~ (new signups no longer accepted)
2) Grab an API key. [OpenWeatherMap](https://openweathermap.org/appid) | [weatherstack](https://weatherstack.com/) | [Pirate Weather](https://pirateweather.net/getting-started)
- WWIS is another option that requires no API key, but is limited (in most countries) to major cities
- WWIS is another option that requires no API key, but is limited (in most countries) to major cities only
3) Configure it: `/msg yourbot config plugins.NuWeather.apikeys.BACKENDNAME YOUR-API-KEY`
@ -66,7 +66,7 @@ config plugins.NuWeather.DBAddressingMode nicks
## Location lookup (Geocoding) backends
* weatherstack provides weather lookup by place name directly, and does not need further configuration.
* OpenStreetMap, WWIS, and Dark Sky backends use a separate service to translate place names into GPS coordinates, a process known as **geocoding**.
* OpenStreetMap, WWIS, and Pirate Weather backends use a separate service to translate place names into GPS coordinates, a process known as **geocoding**.
The default geocoding backend is [OpenStreetMap's Nominatim](https://nominatim.openstreetmap.org/); this can be configured via the `plugins.NuWeather.geocodeBackend` option.

View File

@ -77,7 +77,7 @@ conf.registerChannelValue(NuWeather.units, 'speed',
$mi = mph, $km = km/h, $m = m/s.""")))
# List of supported backends for weather & geocode. This is reused by plugin.py
BACKENDS = ('openweathermap', 'darksky', 'weatherstack', 'wwis')
BACKENDS = ('openweathermap', 'pirateweather', 'weatherstack', 'wwis')
GEOCODE_BACKENDS = ('nominatim', 'googlemaps', 'opencage', 'weatherstack')
def backend_requires_apikey(backend):

View File

@ -372,11 +372,11 @@ class NuWeather(callbacks.Plugin):
for forecastdata in city_data['forecast']['forecastDay']]
}
def _darksky_fetcher(self, location, geobackend=None):
"""Grabs weather data from Dark Sky."""
apikey = self.registryValue('apikeys.darksky')
def _pirateweather_fetcher(self, location, geobackend=None):
"""Grabs weather data from Pirate Weather."""
apikey = self.registryValue('apikeys.pirateweather')
if not apikey:
raise callbacks.Error(_("Please configure the Dark Sky API key in plugins.nuweather.apikeys.darksky."))
raise callbacks.Error(_("Please configure the Pirate Weather API key in plugins.nuweather.apikeys.pirateweather."))
# Convert location to lat,lon first
latlon = self._geocode(location, geobackend=geobackend)
@ -386,7 +386,7 @@ class NuWeather(callbacks.Plugin):
lat, lon, display_name, geocodeid, geocode_backend = latlon
# We don't use minutely or hourly data; alerts are not supported yet
url = 'https://api.darksky.net/forecast/%s/%s,%s?units=us&exclude=minutely,hourly,alerts' % (apikey, lat, lon)
url = 'https://api.pirateweather.net/forecast/%s/%s,%s?units=us&exclude=minutely,hourly,alerts' % (apikey, lat, lon)
self.log.debug('NuWeather: using url %s', url)
f = utils.web.getUrl(url, headers=HEADERS).decode('utf-8')
@ -397,8 +397,8 @@ class NuWeather(callbacks.Plugin):
# N.B. Dark Sky docs tell to not expect any values to exist except the timestamp attached to the response
return {
'location': display_name,
'poweredby': 'Dark\xa0Sky+' + geocode_backend,
'url': 'https://darksky.net/forecast/%s,%s' % (lat, lon),
'poweredby': 'Pirate\xa0Weather+' + geocode_backend,
'url': 'https://merrysky.net/forecast/%s,%s' % (lat, lon),
'current': {
'condition': currentdata.get('summary', 'N/A'),
'temperature': self._format_tmpl_temp(f=currentdata.get('temperature')),