bigger fixes
This commit is contained in:
parent
d5c245856b
commit
b83653bc42
@ -579,9 +579,20 @@ def send_transactions(message):
|
||||
else:
|
||||
|
||||
for transaction in transactions:
|
||||
comment = hf.make_markdown_proof(transaction['comment'])
|
||||
comment = hf.make_markdown_proof(transaction['comment']) or "\(no desc\)" # if comment is empty, make it "no desc"
|
||||
isin = hf.make_markdown_proof(transaction['isin'])
|
||||
bot.send_message(chat_id=user_id, text=f'_{comment}_\n{isin}\namount: {transaction["count"]}\nprice: {transaction["price"]}\ntime: {transaction["time"]}', parse_mode="MARKDOWNV2")
|
||||
amount = hf.make_markdown_proof(transaction['count'])
|
||||
price = hf.make_markdown_proof(transaction['price'])
|
||||
time = hf.make_markdown_proof(transaction['time'])
|
||||
"""
|
||||
comment = transaction['comment']
|
||||
isin = transaction['isin']
|
||||
amount = transaction['count']
|
||||
price = transaction['price']
|
||||
time = transaction['time']
|
||||
"""
|
||||
print(f'_{comment}_\n{isin}\namount: {amount}\nprice: {price}\ntime: {time}')
|
||||
bot.send_message(chat_id=user_id, text=f'_{comment}_\n{isin}\namount: {amount}\nprice: {price}\ntime: {time}', parse_mode="MARKDOWNV2")
|
||||
|
||||
|
||||
@bot.message_handler(commands=['shares', 'Shares'])
|
||||
|
@ -32,6 +32,7 @@ def make_markdown_proof(text): # used to avoid errors related to markdown parsem
|
||||
|
||||
:rtype: string
|
||||
"""
|
||||
text = str(text)
|
||||
|
||||
text = text.replace("_", "\\_")
|
||||
text = text.replace("*", "\\*")
|
||||
|
@ -20,14 +20,16 @@ load_dotenv() # loads environment vars
|
||||
# Init
|
||||
api_key = os.getenv('NEWS_API_KEY') # get API Key from .env file
|
||||
newsapi = NewsApiClient(api_key=api_key) # news api from https://newsapi.org/
|
||||
|
||||
try:
|
||||
# get all available news sources (e.g BBC, New York Times, etc.)
|
||||
source_json = requests.get(f"https://newsapi.org/v2/top-headlines/sources?apiKey={api_key}&language=en").json()
|
||||
sources = source_json["sources"]
|
||||
str_sources = ",".join([source["id"] for source in sources])
|
||||
|
||||
except KeyError:
|
||||
print("Error: Could not get sources")
|
||||
sys.exit(1)
|
||||
print("Error: Could not get sources, may be blocked because of too many requests (free newsapi is limited to 100 reqs per day)")
|
||||
str_sources = str("Reuters, bbc, cnn, fox-news, google-news, hacker-news, nytimes, the-huffington-post, the-new-york-times, business-insider, bbc-news, cbc-news, ESPN, fox-sports, google-news-uk, independent, the-wall-street-journal, the-washington-times, time, usa-today")
|
||||
|
||||
|
||||
def get_all_news_by_keyword(keyword, from_date="2000-01-01"):
|
||||
|
Loading…
Reference in New Issue
Block a user