1
0
mirror of https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git synced 2025-06-16 15:06:53 +00:00

fixed markdown parsing bug

This commit is contained in:
Anson Biggs 2021-11-07 11:35:36 -07:00
parent 579421f4ab
commit d26a3cfc78

View File

@ -70,6 +70,15 @@ class IEX_Symbol:
# Make sure API returned valid JSON # Make sure API returned valid JSON
try: try:
resp_json = resp.json() resp_json = resp.json()
print(type(resp_json))
# IEX uses backtick ` as apostrophe which breaks telegram markdown parsing
if type(resp_json) is dict:
print("Fixing format ` to '")
resp_json["companyName"] = resp_json.get("companyName", "").replace(
"`", "'"
)
return resp_json return resp_json
except r.exceptions.JSONDecodeError as e: except r.exceptions.JSONDecodeError as e:
logging.error(e) logging.error(e)
@ -108,6 +117,9 @@ class IEX_Symbol:
symbols = pd.concat([reg, otc]) symbols = pd.concat([reg, otc])
# IEX uses backtick ` as apostrophe which breaks telegram markdown parsing
symbols["name"] = symbols["name"].str.replace("`", "'")
symbols["description"] = "$" + symbols["symbol"] + ": " + symbols["name"] symbols["description"] = "$" + symbols["symbol"] + ": " + symbols["name"]
symbols["id"] = symbols["symbol"] symbols["id"] = symbols["symbol"]
symbols["type_id"] = "$" + symbols["symbol"].str.lower() symbols["type_id"] = "$" + symbols["symbol"].str.lower()