Satsdice loading, needs finishing
This commit is contained in:
parent
a8451e6f50
commit
b9ff95a9cf
6 changed files with 25 additions and 24 deletions
|
|
@ -6,7 +6,7 @@ from lnbits.db import Database
|
||||||
from lnbits.helpers import template_renderer
|
from lnbits.helpers import template_renderer
|
||||||
from lnbits.tasks import catch_everything_and_restart
|
from lnbits.tasks import catch_everything_and_restart
|
||||||
|
|
||||||
db = Database("satsdice_ext")
|
db = Database("ext_satsdice")
|
||||||
|
|
||||||
satsdice_ext: APIRouter = APIRouter(prefix="/satsdice", tags=["satsdice"])
|
satsdice_ext: APIRouter = APIRouter(prefix="/satsdice", tags=["satsdice"])
|
||||||
|
|
||||||
|
|
@ -22,9 +22,8 @@ def satsdice_renderer():
|
||||||
from .views_api import * # noqa
|
from .views_api import * # noqa
|
||||||
from .views import * # noqa
|
from .views import * # noqa
|
||||||
from .lnurl import * # noqa
|
from .lnurl import * # noqa
|
||||||
from .tasks import wait_for_paid_invoices
|
|
||||||
|
|
||||||
|
|
||||||
def satsdice_start():
|
# def satsdice_start():
|
||||||
loop = asyncio.get_event_loop()
|
# loop = asyncio.get_event_loop()
|
||||||
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|
# loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ from .models import (
|
||||||
satsdiceLink,
|
satsdiceLink,
|
||||||
satsdicePayment,
|
satsdicePayment,
|
||||||
CreateSatsDiceLink,
|
CreateSatsDiceLink,
|
||||||
|
CreateSatsDicePayment,
|
||||||
|
CreateSatsDiceWithdraw,
|
||||||
)
|
)
|
||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
<code
|
<code
|
||||||
>curl -X GET {{ request.url_root }}api/v1/links -H "X-Api-Key: {{
|
>curl -X GET {{ request.url_root }}api/v1/links -H "X-Api-Key: {{
|
||||||
g.user.wallets[0].inkey }}"
|
user.wallets[0].inkey }}"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
<code
|
<code
|
||||||
>curl -X GET {{ request.url_root }}api/v1/links/<satsdice_id> -H
|
>curl -X GET {{ request.url_root }}api/v1/links/<satsdice_id> -H
|
||||||
"X-Api-Key: {{ g.user.wallets[0].inkey }}"
|
"X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
"max_satsdiceable": <integer>, "uses": <integer>,
|
"max_satsdiceable": <integer>, "uses": <integer>,
|
||||||
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
||||||
"Content-type: application/json" -H "X-Api-Key: {{
|
"Content-type: application/json" -H "X-Api-Key: {{
|
||||||
g.user.wallets[0].adminkey }}"
|
user.wallets[0].adminkey }}"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
"max_satsdiceable": <integer>, "uses": <integer>,
|
"max_satsdiceable": <integer>, "uses": <integer>,
|
||||||
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
||||||
"Content-type: application/json" -H "X-Api-Key: {{
|
"Content-type: application/json" -H "X-Api-Key: {{
|
||||||
g.user.wallets[0].adminkey }}"
|
user.wallets[0].adminkey }}"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
@ -138,7 +138,7 @@
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
<code
|
<code
|
||||||
>curl -X DELETE {{ request.url_root }}api/v1/links/<satsdice_id>
|
>curl -X DELETE {{ request.url_root }}api/v1/links/<satsdice_id>
|
||||||
-H "X-Api-Key: {{ g.user.wallets[0].adminkey }}"
|
-H "X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
@ -166,7 +166,7 @@
|
||||||
<code
|
<code
|
||||||
>curl -X GET {{ request.url_root
|
>curl -X GET {{ request.url_root
|
||||||
}}api/v1/links/<the_hash>/<lnurl_id> -H "X-Api-Key: {{
|
}}api/v1/links/<the_hash>/<lnurl_id> -H "X-Api-Key: {{
|
||||||
g.user.wallets[0].inkey }}"
|
user.wallets[0].inkey }}"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
|
||||||
|
|
@ -92,9 +92,9 @@
|
||||||
<q-card-section class="q-pa-none">
|
<q-card-section class="q-pa-none">
|
||||||
<q-separator></q-separator>
|
<q-separator></q-separator>
|
||||||
<q-list>
|
<q-list>
|
||||||
{% include "lnurlp/_api_docs.html" %}
|
{% include "satsdice/_api_docs.html" %}
|
||||||
<q-separator></q-separator>
|
<q-separator></q-separator>
|
||||||
{% include "lnurlp/_lnurl.html" %}
|
{% include "satsdice/_lnurl.html" %}
|
||||||
</q-list>
|
</q-list>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,9 @@ from fastapi.templating import Jinja2Templates
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
from starlette.responses import HTMLResponse
|
from starlette.responses import HTMLResponse
|
||||||
from lnbits.core.models import User, Payment
|
from lnbits.core.models import User, Payment
|
||||||
from .views_api import api_get_jukebox_device_check
|
|
||||||
|
|
||||||
|
from fastapi.params import Depends
|
||||||
|
from fastapi.param_functions import Query
|
||||||
|
|
||||||
templates = Jinja2Templates(directory="templates")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|
||||||
|
|
@ -38,7 +39,7 @@ async def display(link_id):
|
||||||
chance=link.chance,
|
chance=link.chance,
|
||||||
multiplier=link.multiplier,
|
multiplier=link.multiplier,
|
||||||
lnurl=link.lnurl,
|
lnurl=link.lnurl,
|
||||||
unique=True,{"request": request, "user": user.dict()}
|
unique=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -57,7 +58,7 @@ async def displaywin(link_id, payment_hash):
|
||||||
multiplier=satsdicelink.multiplier,
|
multiplier=satsdicelink.multiplier,
|
||||||
lnurl=withdrawLink.lnurl,
|
lnurl=withdrawLink.lnurl,
|
||||||
paid=False,
|
paid=False,
|
||||||
lost=False
|
lost=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
payment = await get_standalone_payment(payment_hash) or abort(
|
payment = await get_standalone_payment(payment_hash) or abort(
|
||||||
|
|
@ -72,8 +73,7 @@ async def displaywin(link_id, payment_hash):
|
||||||
if payment.pending == 1:
|
if payment.pending == 1:
|
||||||
print("pending")
|
print("pending")
|
||||||
return satsdice_renderer().TemplateResponse(
|
return satsdice_renderer().TemplateResponse(
|
||||||
"satsdice/error.html",
|
"satsdice/error.html", link=satsdicelink.id, paid=False, lost=False
|
||||||
link=satsdicelink.id, paid=False, lost=False
|
|
||||||
)
|
)
|
||||||
|
|
||||||
await update_satsdice_payment(payment_hash, paid=1)
|
await update_satsdice_payment(payment_hash, paid=1)
|
||||||
|
|
@ -85,8 +85,7 @@ async def displaywin(link_id, payment_hash):
|
||||||
if paylink.lost == 1:
|
if paylink.lost == 1:
|
||||||
print("lost")
|
print("lost")
|
||||||
return satsdice_renderer().TemplateResponse(
|
return satsdice_renderer().TemplateResponse(
|
||||||
"satsdice/error.html",
|
"satsdice/error.html", link=satsdicelink.id, paid=False, lost=True
|
||||||
link=satsdicelink.id, paid=False, lost=True
|
|
||||||
)
|
)
|
||||||
rand = random.randint(0, 100)
|
rand = random.randint(0, 100)
|
||||||
chance = satsdicelink.chance
|
chance = satsdicelink.chance
|
||||||
|
|
@ -94,8 +93,7 @@ async def displaywin(link_id, payment_hash):
|
||||||
await update_satsdice_payment(payment_hash, lost=1)
|
await update_satsdice_payment(payment_hash, lost=1)
|
||||||
|
|
||||||
return satsdice_renderer().TemplateResponse(
|
return satsdice_renderer().TemplateResponse(
|
||||||
"satsdice/error.html",
|
"satsdice/error.html", link=satsdicelink.id, paid=False, lost=True
|
||||||
link=satsdicelink.id, paid=False, lost=True
|
|
||||||
)
|
)
|
||||||
|
|
||||||
withdrawLink = await create_satsdice_withdraw(
|
withdrawLink = await create_satsdice_withdraw(
|
||||||
|
|
@ -131,5 +129,5 @@ async def img(link_id):
|
||||||
"Cache-Control": "no-cache, no-store, must-revalidate",
|
"Cache-Control": "no-cache, no-store, must-revalidate",
|
||||||
"Pragma": "no-cache",
|
"Pragma": "no-cache",
|
||||||
"Expires": "0",
|
"Expires": "0",
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,12 @@ from starlette.exceptions import HTTPException
|
||||||
from starlette.responses import HTMLResponse, JSONResponse # type: ignore
|
from starlette.responses import HTMLResponse, JSONResponse # type: ignore
|
||||||
from lnbits.core.crud import get_user
|
from lnbits.core.crud import get_user
|
||||||
from lnbits.decorators import api_validate_post_request
|
from lnbits.decorators import api_validate_post_request
|
||||||
from .models import CreateSatsDiceLink, CreateSatsDiceWithdraws
|
from .models import CreateSatsDiceLink, CreateSatsDiceWithdraws, CreateSatsDicePayment
|
||||||
from . import satsdice_ext
|
from . import satsdice_ext
|
||||||
from fastapi import FastAPI, Request
|
from fastapi import FastAPI, Request
|
||||||
from fastapi.params import Depends
|
from fastapi.params import Depends
|
||||||
|
from typing import Optional
|
||||||
|
from fastapi.param_functions import Query
|
||||||
from .crud import (
|
from .crud import (
|
||||||
create_satsdice_pay,
|
create_satsdice_pay,
|
||||||
get_satsdice_pay,
|
get_satsdice_pay,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue