mirror of
				https://github.com/craigerl/aprsd.git
				synced 2025-11-04 05:30:27 -05:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									3dd23fa2ad
								
							
						
					
					
						commit
						bdeaf6348a
					
				@ -21,6 +21,7 @@ class LocationPlugin(plugin.APRSDPluginBase):
 | 
				
			|||||||
    def command(self, fromcall, message, ack):
 | 
					    def command(self, fromcall, message, ack):
 | 
				
			||||||
        LOG.info("Location Plugin")
 | 
					        LOG.info("Location Plugin")
 | 
				
			||||||
        # get last location of a callsign, get descriptive name from weather service
 | 
					        # get last location of a callsign, get descriptive name from weather service
 | 
				
			||||||
 | 
					        api_key = self.config["aprs.fi"]["apiKey"]
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            # optional second argument is a callsign to search
 | 
					            # optional second argument is a callsign to search
 | 
				
			||||||
            a = re.search(r"^.*\s+(.*)", message)
 | 
					            a = re.search(r"^.*\s+(.*)", message)
 | 
				
			||||||
@ -33,7 +34,7 @@ class LocationPlugin(plugin.APRSDPluginBase):
 | 
				
			|||||||
            url = (
 | 
					            url = (
 | 
				
			||||||
                "http://api.aprs.fi/api/get?name="
 | 
					                "http://api.aprs.fi/api/get?name="
 | 
				
			||||||
                + searchcall
 | 
					                + searchcall
 | 
				
			||||||
                + "&what=loc&apikey=104070.f9lE8qg34L8MZF&format=json"
 | 
					                + "&what=loc&apikey={}&format=json".format(api_key)
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            response = requests.get(url)
 | 
					            response = requests.get(url)
 | 
				
			||||||
            # aprs_data = json.loads(response.read())
 | 
					            # aprs_data = json.loads(response.read())
 | 
				
			||||||
 | 
				
			|||||||
@ -16,11 +16,12 @@ class WeatherPlugin(plugin.APRSDPluginBase):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def command(self, fromcall, message, ack):
 | 
					    def command(self, fromcall, message, ack):
 | 
				
			||||||
        LOG.info("Weather Plugin")
 | 
					        LOG.info("Weather Plugin")
 | 
				
			||||||
 | 
					        api_key = self.config["aprs.fi"]["apiKey"]
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            url = (
 | 
					            url = (
 | 
				
			||||||
                "http://api.aprs.fi/api/get?"
 | 
					                "http://api.aprs.fi/api/get?"
 | 
				
			||||||
                "&what=loc&apikey=104070.f9lE8qg34L8MZF&format=json"
 | 
					                "&what=loc&apikey={}&format=json"
 | 
				
			||||||
                "&name=%s" % fromcall
 | 
					                "&name={}".format(api_key, fromcall)
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            response = requests.get(url)
 | 
					            response = requests.get(url)
 | 
				
			||||||
            # aprs_data = json.loads(response.read())
 | 
					            # aprs_data = json.loads(response.read())
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,7 @@ DEFAULT_CONFIG_DICT = {
 | 
				
			|||||||
        "port": 14580,
 | 
					        "port": 14580,
 | 
				
			||||||
        "logfile": "/tmp/arsd.log",
 | 
					        "logfile": "/tmp/arsd.log",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    "aprs.fi": {"apiKey": "set me"},
 | 
				
			||||||
    "shortcuts": {
 | 
					    "shortcuts": {
 | 
				
			||||||
        "aa": "5551239999@vtext.com",
 | 
					        "aa": "5551239999@vtext.com",
 | 
				
			||||||
        "cl": "craiglamparter@somedomain.org",
 | 
					        "cl": "craiglamparter@somedomain.org",
 | 
				
			||||||
@ -172,6 +173,12 @@ def parse_config(config_file):
 | 
				
			|||||||
        "callsign",
 | 
					        "callsign",
 | 
				
			||||||
        default_fail=DEFAULT_CONFIG_DICT["ham"]["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", "login")
 | 
				
			||||||
    check_option(config, "aprs", "password")
 | 
					    check_option(config, "aprs", "password")
 | 
				
			||||||
    # check_option(config, "aprs", "host")
 | 
					    # check_option(config, "aprs", "host")
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user