Added Pieter Wuille facts

This commit is contained in:
Black Coffee
2022-09-29 16:44:56 +01:00
parent 84b48eac60
commit b9f8a8b4b8
2 changed files with 32 additions and 5 deletions
+18 -5
View File
@@ -85,15 +85,20 @@ async def api_gerty_delete(
#######################
with open(os.path.join(LNBITS_PATH, 'extensions/gerty/static/satoshi.json')) as fd:
satoshiQuotes = json.load(fd)
@gerty_ext.get("/api/v1/gerty/satoshiquote", status_code=HTTPStatus.OK)
async def api_gerty_satoshi():
with open(os.path.join(LNBITS_PATH, 'extensions/gerty/static/satoshi.json')) as fd:
satoshiQuotes = json.load(fd)
return satoshiQuotes[random.randint(0, 100)]
@gerty_ext.get("/api/v1/gerty/pieterwielliequote", status_code=HTTPStatus.OK)
async def api_gerty_wuille():
with open(os.path.join(LNBITS_PATH, 'extensions/gerty/static/pieter_wuille.json')) as fd:
data = json.load(fd)
return data['facts'][random.randint(0, (len(data['facts']) - 1))]
@gerty_ext.get("/api/v1/gerty/{gerty_id}")
async def api_gerty_json(
gerty_id: str,
@@ -191,7 +196,7 @@ async def get_screen_text(screen_num: int, screens_list: dict, gerty):
elif screen_slug == "fun_satoshi_quotes":
text = await get_satoshi_quotes()
elif screen_slug == "fun_pieter_wuille_facts":
text = await get_placeholder_text()
text = await get_pieter_wuille_fact()
elif screen_slug == "fun_exchange_market_rate":
text = await get_placeholder_text()
elif screen_slug == "onchain_difficulty_epoch_progress":
@@ -254,7 +259,15 @@ async def get_satoshi_quotes():
text.append(get_text_item_dict(quote['text'], 16))
if quote['date']:
text.append(get_text_item_dict(quote['date'], 12))
return text
async def get_pieter_wuille_fact():
text = []
quote = await api_gerty_wuille()
if quote:
text.append(get_text_item_dict(quote, 16))
text.append(get_text_item_dict("Pieter Wuille facts", 12))
return text
# A helper function get a nicely formated dict for the text