enhanced /share

This commit is contained in:
Rripped 2022-05-11 17:01:46 +02:00
parent f87f8cbf4c
commit 11e856db24

View File

@ -106,8 +106,16 @@ def get_share_information(str_search_for):
return str_return
def get_share_information_markdown(str_search_for):
search_result = investpy.search_quotes(text=str_search_for, products=['stocks'],
countries=['germany'], n_results=1)
try:
search_result = investpy.search_quotes(text=str_search_for, products=['stocks'],
countries=['germany'], n_results=1)
except RuntimeError as e:
return hf.make_markdown_proof(f"no shares found for \"{str_search_for}\"") # if no shares are found, make error message markdown proof and return
except ConnectionError as e:
return hf.make_markdown_proof(f"connection not possible. Try again later.") # if no connection, make error message markdown proof and return
str_return = f'*{hf.make_markdown_proof(search_result.name)}*\n_{hf.make_markdown_proof(search_result.symbol)}_\nworth: {hf.make_markdown_proof(get_share_price(str_search_for))}'
return str_return