Satsdice working

This commit is contained in:
Ben Arc
2021-10-20 04:52:33 +01:00
parent 19df2f888b
commit 37b14e3d6d
2 changed files with 17 additions and 4 deletions

View File

@@ -37,7 +37,16 @@ class satsdiceLink(BaseModel):
@property
def lnurlpay_metadata(self) -> LnurlPayMetadata:
return LnurlPayMetadata(json.dumps([["text/plain", self.title]]))
return LnurlPayMetadata(
json.dumps(
[
[
"text/plain",
f"{self.title} (Chance: {self.chance}%, Multiplier: {self.multiplier})",
]
]
)
)
def success_action(self, payment_hash: str, req: Request) -> Optional[Dict]:
url = req.url_for(

View File

@@ -91,14 +91,13 @@ async def displaywin(
HTTPStatus.NOT_FOUND, "satsdice link does not exist."
)
if payment.pending == 1:
print("cunt")
return satsdice_renderer().TemplateResponse(
"satsdice/error.html",
{
"request": request,
"link": satsdicelink.id,
"paid": False,
"lost": False,
"lost": True,
},
)
@@ -115,7 +114,12 @@ async def displaywin(
"lost": True,
},
)
rand = random.randint(0, 100)
rand1 = random.randint(0, 100)
rand2 = random.randint(0, 100)
rand3 = random.randint(0, 100)
rand4 = random.randint(0, 100)
rand = (rand1 + rand2 + rand3 + rand4) / 4
print(rand)
chance = satsdicelink.chance
if rand > chance:
await update_satsdice_payment(payment_hash, lost=1)