Skip to content

Commit a437ee0

Browse files
authored
Merge branch 'main' into remove-unused
2 parents 588ab40 + add87f8 commit a437ee0

File tree

16 files changed

+414
-105
lines changed

16 files changed

+414
-105
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: release github version
2+
on:
3+
push:
4+
tags:
5+
- "[0-9]+.[0-9]+.[0-9]+"
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Create GitHub Release
11+
id: create_release
12+
uses: actions/create-release@v1
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
with:
16+
tag_name: ${{ github.ref }}
17+
release_name: ${{ github.ref }}
18+
draft: false
19+
prerelease: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# StreamerCopilot
1+
# StreamerCopilot - <small>[LNbits](https://github.com/lnbits/lnbits) extension</small>
2+
<small>For more about LNBits extension check [this tutorial](https://github.com/lnbits/lnbits/wiki/LNbits-Extensions)</small>
23

34
Tool to help streamers accept sats for tips
45

@@ -7,6 +8,3 @@ Tool to help streamers accept sats for tips
78
![image](https://user-images.githubusercontent.com/33088785/214897589-e51e4948-d6cf-4c3b-a0ee-b4581e873b6c.png)
89

910
![image](https://user-images.githubusercontent.com/33088785/214898501-193c0f04-9738-4039-b178-ea0068a61685.png)
10-
11-
12-

config.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "Streamer Copilot",
33
"short_description": "Video tips/animations/webhooks",
4-
"tile": "/copilot/static/bitcoin-streaming.png",
5-
"contributors": [
6-
"arcbtc"
7-
]
4+
"tile": "/copilot/static/bitcoin-streaming.png",
5+
"contributors": ["arcbtc"],
6+
"is_installed": true
87
}

crud.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from lnbits.helpers import urlsafe_short_hash
44

55
from . import db
6-
from .models import Copilots, CreateCopilotData
6+
from .models import Copilot, CreateCopilotData
77

88
###############COPILOTS##########################
99

1010

1111
async def create_copilot(
1212
data: CreateCopilotData, inkey: Optional[str] = ""
13-
) -> Optional[Copilots]:
13+
) -> Copilot:
1414
copilot_id = urlsafe_short_hash()
1515
await db.execute(
1616
"""
@@ -63,34 +63,37 @@ async def create_copilot(
6363
0,
6464
),
6565
)
66-
return await get_copilot(copilot_id)
66+
copilot = await get_copilot(copilot_id)
67+
assert copilot, "Newly created copilot couldn't be retrieved"
68+
return copilot
6769

6870

6971
async def update_copilot(
7072
data: CreateCopilotData, copilot_id: str
71-
) -> Optional[Copilots]:
73+
) -> Copilot:
7274
q = ", ".join([f"{field[0]} = ?" for field in data])
7375
items = [f"{field[1]}" for field in data]
7476
items.append(copilot_id)
7577
await db.execute(f"UPDATE copilot.newer_copilots SET {q} WHERE id = ?", (items,))
7678
row = await db.fetchone(
7779
"SELECT * FROM copilot.newer_copilots WHERE id = ?", (copilot_id,)
7880
)
79-
return Copilots(**row) if row else None
81+
assert row, "Updated copilot couldn't be retrieved"
82+
return Copilot(**row)
8083

8184

82-
async def get_copilot(copilot_id: str) -> Optional[Copilots]:
85+
async def get_copilot(copilot_id: str) -> Optional[Copilot]:
8386
row = await db.fetchone(
8487
"SELECT * FROM copilot.newer_copilots WHERE id = ?", (copilot_id,)
8588
)
86-
return Copilots(**row) if row else None
89+
return Copilot(**row) if row else None
8790

8891

89-
async def get_copilots(user: str) -> List[Copilots]:
92+
async def get_copilots(user: str) -> List[Copilot]:
9093
rows = await db.fetchall(
9194
'SELECT * FROM copilot.newer_copilots WHERE "user" = ?', (user,)
9295
)
93-
return [Copilots(**row) for row in rows]
96+
return [Copilot(**row) for row in rows]
9497

9598

9699
async def delete_copilot(copilot_id: str) -> None:

lnurl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from fastapi import Request
55
from fastapi.param_functions import Query
66
from lnurl.types import LnurlPayMetadata
7-
from starlette.exceptions import HTTPException
8-
from starlette.responses import HTMLResponse
7+
from fastapi.exceptions import HTTPException
8+
from fastapi.responses import HTMLResponse
99

1010
from lnbits.core.services import create_invoice
1111

@@ -16,7 +16,7 @@
1616
@copilot_ext.get(
1717
"/lnurl/{cp_id}", response_class=HTMLResponse, name="copilot.lnurl_response"
1818
)
19-
async def lnurl_response(req: Request, cp_id: str = Query(None)):
19+
async def lnurl_response(req: Request, cp_id: str):
2020
cp = await get_copilot(cp_id)
2121
if not cp:
2222
raise HTTPException(
@@ -40,7 +40,7 @@ async def lnurl_response(req: Request, cp_id: str = Query(None)):
4040
"/lnurl/cb/{cp_id}", response_class=HTMLResponse, name="copilot.lnurl_callback"
4141
)
4242
async def lnurl_callback(
43-
cp_id: str = Query(None), amount: str = Query(None), comment: str = Query(None)
43+
cp_id: str, amount: str = Query(None), comment: str = Query(None)
4444
):
4545
cp = await get_copilot(cp_id)
4646
if not cp:

manifest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"repos": [
3+
{
4+
"id": "copilot",
5+
"organisation": "lnbits",
6+
"repository": "copilot"
7+
}
8+
]
9+
}

migrations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ async def m003_fix_data_types(db):
7676

7777
await db.execute(
7878
"INSERT INTO copilot.newer_copilots SELECT * FROM copilot.copilots"
79-
)
79+
)

models.py

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from fastapi.param_functions import Query
1+
from fastapi import Query, Reuqest
2+
from lnurl.types import LnurlPayMetadata
23
from pydantic import BaseModel
3-
from starlette.requests import Request
44

55
from lnbits.lnurl import encode as lnurl_encode
66

@@ -13,9 +13,9 @@ class CreateCopilotData(BaseModel):
1313
animation1: str = Query(None)
1414
animation2: str = Query(None)
1515
animation3: str = Query(None)
16-
animation1threshold: int = Query(None)
17-
animation2threshold: int = Query(None)
18-
animation3threshold: int = Query(None)
16+
animation1threshold: int = Query(0)
17+
animation2threshold: int = Query(0)
18+
animation3threshold: int = Query(0)
1919
animation1webhook: str = Query(None)
2020
animation2webhook: str = Query(None)
2121
animation3webhook: str = Query(None)
@@ -27,33 +27,31 @@ class CreateCopilotData(BaseModel):
2727
timestamp: int = Query(0)
2828
fullscreen_cam: int = Query(0)
2929
iframe_url: str = Query(None)
30-
success_url: str = Query(None)
3130

3231

33-
class Copilots(BaseModel):
32+
class Copilot(BaseModel):
3433
id: str
35-
user: str = Query(None)
36-
title: str = Query(None)
37-
lnurl_toggle: int = Query(0)
38-
wallet: str = Query(None)
39-
animation1: str = Query(None)
40-
animation2: str = Query(None)
41-
animation3: str = Query(None)
42-
animation1threshold: int = Query(None)
43-
animation2threshold: int = Query(None)
44-
animation3threshold: int = Query(None)
45-
animation1webhook: str = Query(None)
46-
animation2webhook: str = Query(None)
47-
animation3webhook: str = Query(None)
48-
lnurl_title: str = Query(None)
49-
show_message: int = Query(0)
50-
show_ack: int = Query(0)
51-
show_price: str = Query(None)
52-
amount_made: int = Query(0)
53-
timestamp: int = Query(0)
54-
fullscreen_cam: int = Query(0)
55-
iframe_url: str = Query(None)
56-
success_url: str = Query(None)
34+
user: Optional[str]
35+
title: str
36+
lnurl_toggle: int
37+
wallet: Optional[str]
38+
animation1: Optional[str]
39+
animation2: Optional[str]
40+
animation3: Optional[str]
41+
animation1threshold: int
42+
animation2threshold: int
43+
animation3threshold: int
44+
animation1webhook: Optional[str]
45+
animation2webhook: Optional[str]
46+
animation3webhook: Optional[str]
47+
lnurl_title: Optional[str]
48+
show_message: int
49+
show_ack: int
50+
show_price: Optional[str]
51+
amount_made: int
52+
timestamp: int
53+
fullscreen_cam: int
54+
iframe_url: Optional[str]
5755

5856
def lnurl(self, req: Request) -> str:
5957
url = req.url_for("copilot.lnurl_response", cp_id=self.id)

tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from http import HTTPStatus
44

55
import httpx
6-
from starlette.exceptions import HTTPException
6+
from fastapi.exceptions import HTTPException
77

88
from lnbits.core import db as core_db
99
from lnbits.core.models import Payment

0 commit comments

Comments
 (0)