From bdeaf6348a5fa48c4aa65f9c8c4f9bf65d7d7689 Mon Sep 17 00:00:00 2001 From: Hemna Date: Tue, 12 Jan 2021 09:51:36 -0500 Subject: [PATCH] Added new config for aprs.fi API Key This patch adds the new required aprs.fi api key. This key is used by 2 of the core plugins, locationPlugin and weatherPlugin. You must set the apiKey in the config, or aprsd won't start. --- aprsd/plugins/location.py | 3 ++- aprsd/plugins/weather.py | 5 +++-- aprsd/utils.py | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) 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")