mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-26 04:51:08 -05:00
NuWeather: replace Dark Sky with Pirate Weather
Co-Authored-By: jithatsonei <me@ji.wtf>
This commit is contained in:
parent
6ca827d30f
commit
1b3ce50abe
@ -6,7 +6,7 @@ A weather plugin for Limnoria. It supports multiple weather and geocoding backen
|
|||||||
- [OpenWeatherMap](https://openweathermap.org/) (default, API key required)
|
- [OpenWeatherMap](https://openweathermap.org/) (default, API key required)
|
||||||
- [WWIS](https://worldweather.wmo.int/) (**no** API key required, major cities only)
|
- [WWIS](https://worldweather.wmo.int/) (**no** API key required, major cities only)
|
||||||
- [weatherstack](https://weatherstack.com/) (current conditions only, API key required)
|
- [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
|
#### Geocoding Backends
|
||||||
- [OpenStreetMap Nominatim](https://nominatim.openstreetmap.org/) (default, no API key required)
|
- [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`
|
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`
|
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
|
## Location lookup (Geocoding) backends
|
||||||
|
|
||||||
* weatherstack provides weather lookup by place name directly, and does not need further configuration.
|
* 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.
|
The default geocoding backend is [OpenStreetMap's Nominatim](https://nominatim.openstreetmap.org/); this can be configured via the `plugins.NuWeather.geocodeBackend` option.
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ conf.registerChannelValue(NuWeather.units, 'speed',
|
|||||||
$mi = mph, $km = km/h, $m = m/s.""")))
|
$mi = mph, $km = km/h, $m = m/s.""")))
|
||||||
|
|
||||||
# List of supported backends for weather & geocode. This is reused by plugin.py
|
# 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')
|
GEOCODE_BACKENDS = ('nominatim', 'googlemaps', 'opencage', 'weatherstack')
|
||||||
|
|
||||||
def backend_requires_apikey(backend):
|
def backend_requires_apikey(backend):
|
||||||
|
@ -372,11 +372,11 @@ class NuWeather(callbacks.Plugin):
|
|||||||
for forecastdata in city_data['forecast']['forecastDay']]
|
for forecastdata in city_data['forecast']['forecastDay']]
|
||||||
}
|
}
|
||||||
|
|
||||||
def _darksky_fetcher(self, location, geobackend=None):
|
def _pirateweather_fetcher(self, location, geobackend=None):
|
||||||
"""Grabs weather data from Dark Sky."""
|
"""Grabs weather data from Pirate Weather."""
|
||||||
apikey = self.registryValue('apikeys.darksky')
|
apikey = self.registryValue('apikeys.pirateweather')
|
||||||
if not apikey:
|
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
|
# Convert location to lat,lon first
|
||||||
latlon = self._geocode(location, geobackend=geobackend)
|
latlon = self._geocode(location, geobackend=geobackend)
|
||||||
@ -386,7 +386,7 @@ class NuWeather(callbacks.Plugin):
|
|||||||
lat, lon, display_name, geocodeid, geocode_backend = latlon
|
lat, lon, display_name, geocodeid, geocode_backend = latlon
|
||||||
|
|
||||||
# We don't use minutely or hourly data; alerts are not supported yet
|
# 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)
|
self.log.debug('NuWeather: using url %s', url)
|
||||||
|
|
||||||
f = utils.web.getUrl(url, headers=HEADERS).decode('utf-8')
|
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
|
# N.B. Dark Sky docs tell to not expect any values to exist except the timestamp attached to the response
|
||||||
return {
|
return {
|
||||||
'location': display_name,
|
'location': display_name,
|
||||||
'poweredby': 'Dark\xa0Sky+' + geocode_backend,
|
'poweredby': 'Pirate\xa0Weather+' + geocode_backend,
|
||||||
'url': 'https://darksky.net/forecast/%s,%s' % (lat, lon),
|
'url': 'https://merrysky.net/forecast/%s,%s' % (lat, lon),
|
||||||
'current': {
|
'current': {
|
||||||
'condition': currentdata.get('summary', 'N/A'),
|
'condition': currentdata.get('summary', 'N/A'),
|
||||||
'temperature': self._format_tmpl_temp(f=currentdata.get('temperature')),
|
'temperature': self._format_tmpl_temp(f=currentdata.get('temperature')),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user