This commit is contained in:
Ben Arc
2021-04-20 08:50:53 +01:00
parent dd95f3e40f
commit 0946bcc1b1
7 changed files with 38 additions and 49 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "StreamerCopilot",
"short_description": "Tipping and animations for streamers",
"short_description": "Tipping, animations and webhooks for streamers",
"icon": "face",
"contributors": [
"arcbtc"

View File

@@ -30,7 +30,6 @@ class Copilots(NamedTuple):
timestamp: int
fullscreen_cam: int
iframe_url: str
notes: str
@classmethod
def from_row(cls, row: Row) -> "Copilots":

View File

@@ -10,6 +10,7 @@ from .crud import get_copilot
from .views import updater
import shortuuid
async def register_listeners():
invoice_paid_chan_send, invoice_paid_chan_recv = trio.open_memory_channel(2)
register_invoice_listener(invoice_paid_chan_send)
@@ -25,7 +26,7 @@ async def on_invoice_paid(payment: Payment) -> None:
webhook = None
data = None
if "copilot" != payment.extra.get("tag"):
# not an lnurlp invoice
# not an copilot invoice
return
if payment.extra.get("wh_status"):
@@ -39,7 +40,10 @@ async def on_invoice_paid(payment: Payment) -> None:
jsonify({"message": "Copilot link link does not exist."}),
HTTPStatus.NOT_FOUND,
)
if int(copilot.animation1threshold) and int(payment.amount) > copilot.animation1threshold:
if (
int(copilot.animation1threshold)
and int(payment.amount) > copilot.animation1threshold
):
data = copilot.animation1
webhook = copilot.animation1webhook
if (

View File

@@ -172,7 +172,7 @@
}
this.connection.addEventListener('open', function (event) {
this.connection.send('')
this.connection.send('handshake')
})
var showNotif = this.showNotif

View File

@@ -103,25 +103,6 @@
/>
</div>
</div>
<div class="column">
<div class="col">
<q-input
v-model="textareaModel"
filled
class="q-pl-sm q-pr-sm q-pb-sm"
clearable
type="textarea"
label="Notes"
></q-input>
</div>
<div class="col">
<q-btn
color="primary"
label="Save notes"
class="q-ma-sm float-right"
></q-btn>
</div>
</div>
</div>
</div>
</q-card>

View File

@@ -13,26 +13,6 @@ import trio
import shortuuid
from . import copilot_ext
connected_websockets = {}
@copilot_ext.websocket("/ws/panel/<copilot_id>")
async def ws_panel(copilot_id):
global connected_websockets
while True:
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
while True:
data = await websocket.receive()
await websocket.send(connected_websockets[copilot_id])
@copilot_ext.route("/")
@validate_uuids(["usr"], required=True)
@@ -65,8 +45,33 @@ async def panel(copilot_id):
)
return await render_template("copilot/panel.html", copilot=copilot)
##################WEBSOCKET ROUTES########################
# socket_relay is a list where the control panel or
# lnurl endpoints can leave a message for the compose window
socket_relay = {}
@copilot_ext.websocket("/ws/panel/<copilot_id>")
async def ws_panel(copilot_id):
global socket_relay
while True:
data = await websocket.receive()
if data == "handshake":
await websocket.send(f"willkommen")
socket_relay[copilot_id] = shortuuid.uuid()[:5] + "-" + data + "-" + "none"
@copilot_ext.websocket("/ws/compose/<copilot_id>")
async def ws_compose(copilot_id):
global socket_relay
while True:
data = await websocket.receive()
await websocket.send(socket_relay[copilot_id])
async def updater(data, comment, copilot):
global connected_websockets
connected_websockets[copilot] = (
shortuuid.uuid() + "-" + data + "-" + comment
)
global socket_relay
socket_relay[copilot] = shortuuid.uuid()[:5] + "-" + data + "-" + comment

View File

@@ -17,7 +17,7 @@ from .crud import (
delete_copilot,
)
#############################COPILOT##########################
#######################COPILOT##########################
@copilot_ext.route("/api/v1/copilot", methods=["POST"])