Fixed error handling for unknown stations
This commit is contained in:
		
							parent
							
								
									b23a86cd90
								
							
						
					
					
						commit
						97f87cc9cc
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		
							
								
								
									
										2
									
								
								bot.py
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								bot.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -43,7 +43,7 @@ def start(update):
 | 
			
		|||
 | 
			
		||||
def search_station(query):
 | 
			
		||||
    request = requests.get("https://efa-api.asw.io/api/v1/station/?search=" + query)
 | 
			
		||||
    if request.status_code != 200 and len(request.text) > 2:
 | 
			
		||||
    if request.status_code != 200 or (request.status_code == 200 and len(request.text) <= 2):
 | 
			
		||||
        return -1
 | 
			
		||||
    else:
 | 
			
		||||
        return request.json()[0]['stationId']
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue