Handle exception when trying to connect to SPB
This commit is contained in:
		
							parent
							
								
									3f04d08d1b
								
							
						
					
					
						commit
						179e6c5455
					
				| 
						 | 
					@ -174,11 +174,13 @@ async def get_cas(entity):
 | 
				
			||||||
    return f'- <b>XXX:</b> {html.escape(json.get("description", "XXX"))}'
 | 
					    return f'- <b>XXX:</b> {html.escape(json.get("description", "XXX"))}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async def get_spam_protection(entity):
 | 
					async def get_spam_protection(entity):
 | 
				
			||||||
    async with session.get(f'https://api.intellivoid.net/spamprotection/v1/lookup?query={entity}') as resp:
 | 
					    status = 500
 | 
				
			||||||
        try:
 | 
					    try:
 | 
				
			||||||
 | 
					        async with session.get(f'https://api.intellivoid.net/spamprotection/v1/lookup?query={entity}') as resp:
 | 
				
			||||||
 | 
					            status = resp.staus
 | 
				
			||||||
            json = await resp.json()
 | 
					            json = await resp.json()
 | 
				
			||||||
        except BaseException as ex:
 | 
					    except BaseException as ex:
 | 
				
			||||||
            return f'- <b>{resp.status}:</b> {html.escape(type(ex).__name__)}: {html.escape(str(ex))}'
 | 
					        return f'- <b>{status}:</b> {html.escape(type(ex).__name__)}: {html.escape(str(ex))}'
 | 
				
			||||||
    if json['success']:
 | 
					    if json['success']:
 | 
				
			||||||
        text = ''
 | 
					        text = ''
 | 
				
			||||||
        if json['results']['private_telegram_id']:
 | 
					        if json['results']['private_telegram_id']:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue