diff --git a/aprsd/plugins/location.py b/aprsd/plugins/location.py index be75e34..a2fba84 100644 --- a/aprsd/plugins/location.py +++ b/aprsd/plugins/location.py @@ -21,6 +21,7 @@ class LocationPlugin(plugin.APRSDPluginBase): def command(self, fromcall, message, ack): LOG.info("Location Plugin") # get last location of a callsign, get descriptive name from weather service + api_key = self.config["aprs.fi"]["apiKey"] try: # optional second argument is a callsign to search a = re.search(r"^.*\s+(.*)", message) @@ -33,7 +34,7 @@ class LocationPlugin(plugin.APRSDPluginBase): url = ( "http://api.aprs.fi/api/get?name=" + searchcall - + "&what=loc&apikey=104070.f9lE8qg34L8MZF&format=json" + + "&what=loc&apikey={}&format=json".format(api_key) ) response = requests.get(url) # aprs_data = json.loads(response.read()) diff --git a/aprsd/plugins/weather.py b/aprsd/plugins/weather.py index 6071c1e..19accc6 100644 --- a/aprsd/plugins/weather.py +++ b/aprsd/plugins/weather.py @@ -16,11 +16,12 @@ class WeatherPlugin(plugin.APRSDPluginBase): def command(self, fromcall, message, ack): LOG.info("Weather Plugin") + api_key = self.config["aprs.fi"]["apiKey"] try: url = ( "http://api.aprs.fi/api/get?" - "&what=loc&apikey=104070.f9lE8qg34L8MZF&format=json" - "&name=%s" % fromcall + "&what=loc&apikey={}&format=json" + "&name={}".format(api_key, fromcall) ) response = requests.get(url) # aprs_data = json.loads(response.read()) diff --git a/aprsd/utils.py b/aprsd/utils.py index d8bf573..a690871 100644 --- a/aprsd/utils.py +++ b/aprsd/utils.py @@ -21,6 +21,7 @@ DEFAULT_CONFIG_DICT = { "port": 14580, "logfile": "/tmp/arsd.log", }, + "aprs.fi": {"apiKey": "set me"}, "shortcuts": { "aa": "5551239999@vtext.com", "cl": "craiglamparter@somedomain.org", @@ -172,6 +173,12 @@ def parse_config(config_file): "callsign", default_fail=DEFAULT_CONFIG_DICT["ham"]["callsign"], ) + check_option( + config, + "aprs.fi", + "apiKey", + default_fail=DEFAULT_CONFIG_DICT["aprs.fi"]["apiKey"], + ) check_option(config, "aprs", "login") check_option(config, "aprs", "password") # check_option(config, "aprs", "host")