mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-24 06:48:02 +01:00
black
This commit is contained in:
parent
dfc8dfc426
commit
b500a02f02
3 changed files with 33 additions and 21 deletions
|
@ -67,8 +67,17 @@ async def lnurl_callback(cp_id):
|
|||
wallet_id=cp.wallet,
|
||||
amount=int(amount_received / 1000),
|
||||
memo=cp.lnurl_title,
|
||||
webhook=url_for("copilot.api_copilot_hooker", copilot_id=cp_id, amount=int(amount_received / 1000), _external=True),
|
||||
description_hash=hashlib.sha256((LnurlPayMetadata(json.dumps([["text/plain", str(cp.lnurl_title)]]))).encode("utf-8")).digest(),
|
||||
webhook=url_for(
|
||||
"copilot.api_copilot_hooker",
|
||||
copilot_id=cp_id,
|
||||
amount=int(amount_received / 1000),
|
||||
_external=True,
|
||||
),
|
||||
description_hash=hashlib.sha256(
|
||||
(
|
||||
LnurlPayMetadata(json.dumps([["text/plain", str(cp.lnurl_title)]]))
|
||||
).encode("utf-8")
|
||||
).digest(),
|
||||
extra={"tag": "copilot", "comment": comment},
|
||||
)
|
||||
resp = LnurlPayActionResponse(
|
||||
|
@ -77,5 +86,12 @@ async def lnurl_callback(cp_id):
|
|||
disposable=False,
|
||||
routes=[],
|
||||
)
|
||||
print(url_for("copilot.api_copilot_hooker", copilot_id=cp_id, amount=int(amount_received / 1000), _external=True))
|
||||
return jsonify(resp.dict())
|
||||
print(
|
||||
url_for(
|
||||
"copilot.api_copilot_hooker",
|
||||
copilot_id=cp_id,
|
||||
amount=int(amount_received / 1000),
|
||||
_external=True,
|
||||
)
|
||||
)
|
||||
return jsonify(resp.dict())
|
||||
|
|
|
@ -22,12 +22,13 @@ async def ws_panel(copilot_id):
|
|||
data = await websocket.receive()
|
||||
connected_websockets[copilot_id] = shortuuid.uuid() + "-" + data
|
||||
|
||||
|
||||
@copilot_ext.websocket("/ws/compose/<copilot_id>")
|
||||
async def ws_compose(copilot_id):
|
||||
global connected_websockets
|
||||
print("poo")
|
||||
|
||||
while True:
|
||||
print("poo")
|
||||
|
||||
data = await websocket.receive()
|
||||
await websocket.send(connected_websockets[copilot_id])
|
||||
|
||||
|
@ -66,25 +67,19 @@ async def panel(copilot_id):
|
|||
|
||||
@copilot_ext.route("/api/v1/copilot/hook/<copilot_id>/<amount>/", methods=["GET"])
|
||||
async def api_copilot_hooker(copilot_id, amount):
|
||||
print("amount")
|
||||
|
||||
data = ""
|
||||
copilot = await get_copilot(copilot_id)
|
||||
print("amount")
|
||||
|
||||
if not copilot:
|
||||
return (
|
||||
jsonify({"message": "Copilot link link does not exist."}),
|
||||
HTTPStatus.NOT_FOUND,
|
||||
)
|
||||
print(amount)
|
||||
if (
|
||||
copilot.animation1threshold
|
||||
and int(amount) > copilot.animation1threshold
|
||||
):
|
||||
|
||||
if copilot.animation1threshold and int(amount) > copilot.animation1threshold:
|
||||
data = copilot.animation1
|
||||
if (
|
||||
copilot.animation2threshold
|
||||
and int(amount) > copilot.animation2threshold
|
||||
):
|
||||
if copilot.animation2threshold and int(amount) > copilot.animation2threshold:
|
||||
data = copilot.animation2
|
||||
if (
|
||||
copilot.animation3threshold
|
||||
|
@ -92,6 +87,7 @@ async def api_copilot_hooker(copilot_id, amount):
|
|||
):
|
||||
data = copilot.animation3
|
||||
global connected_websockets
|
||||
connected_websockets[copilot_id.id] = shortuuid.uuid() + "-" + data
|
||||
|
||||
return "", HTTPStatus.OK
|
||||
print(connected_websockets)
|
||||
connected_websockets[copilot.id] = shortuuid.uuid() + "-" + data
|
||||
|
||||
return "", HTTPStatus.OK
|
||||
|
|
|
@ -90,4 +90,4 @@ async def api_copilot_delete(copilot_id):
|
|||
|
||||
await delete_copilot(copilot_id)
|
||||
|
||||
return "", HTTPStatus.NO_CONTENT
|
||||
return "", HTTPStatus.NO_CONTENT
|
||||
|
|
Loading…
Add table
Reference in a new issue