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,
|
wallet_id=cp.wallet,
|
||||||
amount=int(amount_received / 1000),
|
amount=int(amount_received / 1000),
|
||||||
memo=cp.lnurl_title,
|
memo=cp.lnurl_title,
|
||||||
webhook=url_for("copilot.api_copilot_hooker", copilot_id=cp_id, amount=int(amount_received / 1000), _external=True),
|
webhook=url_for(
|
||||||
description_hash=hashlib.sha256((LnurlPayMetadata(json.dumps([["text/plain", str(cp.lnurl_title)]]))).encode("utf-8")).digest(),
|
"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},
|
extra={"tag": "copilot", "comment": comment},
|
||||||
)
|
)
|
||||||
resp = LnurlPayActionResponse(
|
resp = LnurlPayActionResponse(
|
||||||
|
|
@ -77,5 +86,12 @@ async def lnurl_callback(cp_id):
|
||||||
disposable=False,
|
disposable=False,
|
||||||
routes=[],
|
routes=[],
|
||||||
)
|
)
|
||||||
print(url_for("copilot.api_copilot_hooker", copilot_id=cp_id, amount=int(amount_received / 1000), _external=True))
|
print(
|
||||||
return jsonify(resp.dict())
|
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()
|
data = await websocket.receive()
|
||||||
connected_websockets[copilot_id] = shortuuid.uuid() + "-" + data
|
connected_websockets[copilot_id] = shortuuid.uuid() + "-" + data
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.websocket("/ws/compose/<copilot_id>")
|
@copilot_ext.websocket("/ws/compose/<copilot_id>")
|
||||||
async def ws_compose(copilot_id):
|
async def ws_compose(copilot_id):
|
||||||
global connected_websockets
|
global connected_websockets
|
||||||
print("poo")
|
|
||||||
while True:
|
while True:
|
||||||
print("poo")
|
|
||||||
data = await websocket.receive()
|
data = await websocket.receive()
|
||||||
await websocket.send(connected_websockets[copilot_id])
|
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"])
|
@copilot_ext.route("/api/v1/copilot/hook/<copilot_id>/<amount>/", methods=["GET"])
|
||||||
async def api_copilot_hooker(copilot_id, amount):
|
async def api_copilot_hooker(copilot_id, amount):
|
||||||
print("amount")
|
|
||||||
data = ""
|
data = ""
|
||||||
copilot = await get_copilot(copilot_id)
|
copilot = await get_copilot(copilot_id)
|
||||||
print("amount")
|
|
||||||
if not copilot:
|
if not copilot:
|
||||||
return (
|
return (
|
||||||
jsonify({"message": "Copilot link link does not exist."}),
|
jsonify({"message": "Copilot link link does not exist."}),
|
||||||
HTTPStatus.NOT_FOUND,
|
HTTPStatus.NOT_FOUND,
|
||||||
)
|
)
|
||||||
print(amount)
|
|
||||||
if (
|
if copilot.animation1threshold and int(amount) > copilot.animation1threshold:
|
||||||
copilot.animation1threshold
|
|
||||||
and int(amount) > copilot.animation1threshold
|
|
||||||
):
|
|
||||||
data = copilot.animation1
|
data = copilot.animation1
|
||||||
if (
|
if copilot.animation2threshold and int(amount) > copilot.animation2threshold:
|
||||||
copilot.animation2threshold
|
|
||||||
and int(amount) > copilot.animation2threshold
|
|
||||||
):
|
|
||||||
data = copilot.animation2
|
data = copilot.animation2
|
||||||
if (
|
if (
|
||||||
copilot.animation3threshold
|
copilot.animation3threshold
|
||||||
|
|
@ -92,6 +87,7 @@ async def api_copilot_hooker(copilot_id, amount):
|
||||||
):
|
):
|
||||||
data = copilot.animation3
|
data = copilot.animation3
|
||||||
global connected_websockets
|
global connected_websockets
|
||||||
connected_websockets[copilot_id.id] = shortuuid.uuid() + "-" + data
|
print(connected_websockets)
|
||||||
|
connected_websockets[copilot.id] = shortuuid.uuid() + "-" + data
|
||||||
return "", HTTPStatus.OK
|
|
||||||
|
return "", HTTPStatus.OK
|
||||||
|
|
|
||||||
|
|
@ -90,4 +90,4 @@ async def api_copilot_delete(copilot_id):
|
||||||
|
|
||||||
await delete_copilot(copilot_id)
|
await delete_copilot(copilot_id)
|
||||||
|
|
||||||
return "", HTTPStatus.NO_CONTENT
|
return "", HTTPStatus.NO_CONTENT
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue