All functions fixed for markdown bug
This commit is contained in:
parent
c6352c5f75
commit
ed26c6969d
@ -226,7 +226,6 @@ def update_for_user(message):
|
||||
|
||||
share_symbols = []
|
||||
share_amounts = []
|
||||
share_courses = []
|
||||
|
||||
my_portfolio = p_my_handler.get_user_portfolio(p_user_id)
|
||||
|
||||
@ -235,15 +234,15 @@ def update_for_user(message):
|
||||
print(element["count"], element["isin"])
|
||||
share_symbols.append(element["isin"])
|
||||
share_amounts.append(element["count"])
|
||||
share_courses.append(element["current_price"])
|
||||
|
||||
my_user = p_my_handler.get_user(p_user_id)
|
||||
send_to_user("Hello %s this is your share update:"%str(my_user["username"]), pUser_id=p_user_id)
|
||||
|
||||
if len(share_symbols) != 0:
|
||||
for i in range(len(share_symbols)):
|
||||
my_update_message = f'Symbol: {share_symbols[i]}\nCurrent Price per Share: {share_courses[i]}\nAmount owned: {share_amounts[i]}\nTotal Investment: {float(share_courses[i]) * float(share_amounts[i])}'
|
||||
send_to_user(my_update_message, pUser_id=p_user_id)
|
||||
my_price = share_fetcher.get_share_price_no_currency(share_symbols[i])
|
||||
my_update_message = f'{share_fetcher.get_share_information_markdown(share_symbols[i])}\ncount: {share_amounts[i]}\nTotal: {hf.make_markdown_proof(round(float(my_price) * float(share_amounts[i]), 2))} EUR'
|
||||
bot.send_message(chat_id=p_user_id, text=my_update_message, parse_mode="MARKDOWNV2")
|
||||
else:
|
||||
send_to_user("No shares found for your account. Check https://gruppe1.testsites.info to change your settings and add shares.", pUser_id=p_user_id)
|
||||
|
||||
@ -281,8 +280,8 @@ def send_share_update(message):
|
||||
bot.register_next_step_handler(message, send_share_price)
|
||||
|
||||
def send_share_price(message):
|
||||
str_share_price = share_fetcher.get_share_information_simple(str(message.text))
|
||||
bot.reply_to(message, str_share_price)
|
||||
str_share_price = share_fetcher.get_share_information_markdown(str(message.text))
|
||||
bot.reply_to(message, str_share_price, parse_mode="MARKDOWNV2")
|
||||
|
||||
|
||||
@bot.message_handler(commands=['allnews', 'Allnews']) # /allnews -> get all news
|
||||
@ -607,7 +606,7 @@ def send_shares(message):
|
||||
bot.send_message(chat_id=user_id, text='You do not have any shares. Add shares on https://gruppe1.testsites.info')
|
||||
else:
|
||||
for element in shares:
|
||||
bot.send_message(chat_id=user_id, text=share_fetcher.get_share_information_simple(element))
|
||||
bot.send_message(chat_id=user_id, text=share_fetcher.get_share_information_markdown(element), parse_mode="MARKDOWNV2")
|
||||
|
||||
|
||||
|
||||
|
@ -148,8 +148,8 @@ def update_for_user(p_user_id, p_my_handler):
|
||||
if len(share_symbols) != 0:
|
||||
for i in range(len(share_symbols)):
|
||||
my_price = share_fetcher.get_share_price_no_currency(share_symbols[i])
|
||||
my_update_message = f'{share_fetcher.get_share_information_simple(share_symbols[i])}\nAmount owned: {share_amounts[i]}\nTotal Investment: {round(float(my_price) * float(share_amounts[i]), 2)} EUR'
|
||||
send_to_user(my_update_message, pUser_id=p_user_id)
|
||||
my_update_message = f'{share_fetcher.get_share_information_markdown(share_symbols[i])}\ncount: {share_amounts[i]}\nTotal: {hf.make_markdown_proof(round(float(my_price) * float(share_amounts[i]), 2))} EUR'
|
||||
bot.send_message(chat_id=p_user_id, text=my_update_message, parse_mode="MARKDOWNV2")
|
||||
else:
|
||||
send_to_user("No shares found for your account. Check https://gruppe1.testsites.info to change your settings and add shares.", pUser_id=p_user_id)
|
||||
|
||||
@ -157,7 +157,7 @@ def update_for_user(p_user_id, p_my_handler):
|
||||
if len(shares)!=0: # Send updates on watchlist shares if existing
|
||||
send_to_user("Your watchlist shares:", pUser_id=p_user_id)
|
||||
for element in shares:
|
||||
send_to_user(share_fetcher.get_share_information_simple(element), pUser_id=p_user_id)
|
||||
send_to_user(share_fetcher.get_share_information_markdown(element), pUser_id=p_user_id, md_mode=True)
|
||||
|
||||
|
||||
keywords = p_my_handler.get_user_keywords(p_user_id) # get keywords as array
|
||||
|
@ -9,6 +9,7 @@ __license__ = "None"
|
||||
import investpy
|
||||
import pandas
|
||||
from currency_converter import CurrencyConverter
|
||||
import helper_functions as hf
|
||||
|
||||
def get_share_price(str_search_for):
|
||||
"""get stock price per share for company name or isin or symbol
|
||||
@ -106,7 +107,7 @@ def get_share_information_markdown(str_search_for):
|
||||
search_result = investpy.search_quotes(text=str_search_for, products=['stocks'],
|
||||
countries=['germany'], n_results=1)
|
||||
|
||||
str_return = f'*{search_result.name}*\n_{search_result.symbol}_\nworth: {get_share_price(str_search_for)}'
|
||||
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
|
||||
|
||||
def get_share_information_simple(str_search_for):
|
||||
|
Loading…
Reference in New Issue
Block a user