Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "Streamer Copilot",
"version": "1.0.4",
"short_description": "Video tips/animations/webhooks",
"tile": "/copilot/static/bitcoin-streaming.png",
"min_lnbits_version": "1.0.0",
"min_lnbits_version": "1.7.0",
"contributors": [
{
"name": "Ben Arc",
Expand Down
2 changes: 1 addition & 1 deletion crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

async def create_copilot(data: CreateCopilotData) -> Copilot:
copilot_id = urlsafe_short_hash()
copilot = Copilot(id=copilot_id, **data.dict())
copilot = Copilot(id=copilot_id, **data.model_dump())
await db.insert("copilot.newer_copilots", copilot)
return copilot

Expand Down
46 changes: 23 additions & 23 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,52 @@


class CreateCopilotData(BaseModel):
user: str = Query(None)
title: str = Query(None)
user: str | None = Query(None)
title: str | None = Query(None)
lnurl_toggle: int = Query(0)
wallet: str = Query(None)
animation1: str = Query(None)
animation2: str = Query(None)
animation3: str = Query(None)
wallet: str | None = Query(None)
animation1: str | None = Query(None)
animation2: str | None = Query(None)
animation3: str | None = Query(None)
animation1threshold: int = Query(0)
animation2threshold: int = Query(0)
animation3threshold: int = Query(0)
animation1webhook: str = Query(None)
animation2webhook: str = Query(None)
animation3webhook: str = Query(None)
lnurl_title: str = Query(None)
animation1webhook: str | None = Query(None)
animation2webhook: str | None = Query(None)
animation3webhook: str | None = Query(None)
lnurl_title: str | None = Query(None)
show_message: int = Query(0)
show_ack: int = Query(0)
show_price: str = Query(None)
show_price: str | None = Query(None)
amount_made: int = Query(0)
timestamp: int = Query(0)
fullscreen_cam: int = Query(0)
iframe_url: str = Query(None)
iframe_url: str | None = Query(None)


class Copilot(BaseModel):
id: str
user: str | None
user: str | None = None
title: str
lnurl_toggle: int
wallet: str | None
animation1: str | None
animation2: str | None
animation3: str | None
wallet: str | None = None
animation1: str | None = None
animation2: str | None = None
animation3: str | None = None
animation1threshold: int
animation2threshold: int
animation3threshold: int
animation1webhook: str | None
animation2webhook: str | None
animation3webhook: str | None
lnurl_title: str | None
animation1webhook: str | None = None
animation2webhook: str | None = None
animation3webhook: str | None = None
lnurl_title: str | None = None
show_message: int
show_ack: int
show_price: str | None
show_price: str | None = None
amount_made: int
timestamp: int
fullscreen_cam: int
iframe_url: str | None
iframe_url: str | None = None

def lnurl(self, req: Request) -> str:
url = str(req.url_for("copilot.lnurl_response", cp_id=self.id))
Expand Down
2 changes: 1 addition & 1 deletion static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ window.app = Vue.createApp({
data: null
},
options: ['bitcoin', 'confetti', 'rocket', 'face', 'martijn', 'rick'],
currencyOptions: ['sat', ...window.currencies]
currencyOptions: ['sat', ...CURRENCIES]
}
},
methods: {
Expand Down
6 changes: 5 additions & 1 deletion views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ def copilot_renderer():
async def index(request: Request, user: User = Depends(check_user_exists)):
return copilot_renderer().TemplateResponse(
"copilot/index.html",
{"request": request, "user": user.json(), "currencies": allowed_currencies()},
{
"request": request,
"user": user.model_dump_json(),
"currencies": allowed_currencies(),
},
)


Expand Down
4 changes: 2 additions & 2 deletions views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def api_copilot_retrieve(
)
if not copilot.lnurl_toggle:
return copilot
return {**copilot.dict(), **{"lnurl": copilot.lnurl(req)}}
return {**copilot.model_dump(), **{"lnurl": copilot.lnurl(req)}}


@copilot_api_router.post("/api/v1/copilot")
Expand All @@ -66,7 +66,7 @@ async def api_copilot_update(

data.user = wallet.wallet.user
data.wallet = wallet.wallet.id
for key, value in data.dict().items():
for key, value in data.model_dump().items():
if value:
setattr(copilot, key, value)
return await update_copilot(copilot)
Expand Down
Loading