diff --git a/lnbits/extensions/copilot/__init__.py b/lnbits/extensions/copilot/__init__.py index 3b41c4c91..1f227d660 100644 --- a/lnbits/extensions/copilot/__init__.py +++ b/lnbits/extensions/copilot/__init__.py @@ -3,11 +3,9 @@ from lnbits.db import Database db = Database("ext_copilot") - copilot_ext: Blueprint = Blueprint( "copilot", __name__, static_folder="static", template_folder="templates" ) - from .views_api import * # noqa from .views import * # noqa diff --git a/lnbits/extensions/copilot/crud.py b/lnbits/extensions/copilot/crud.py index 67f9b92e5..f209a0a9c 100644 --- a/lnbits/extensions/copilot/crud.py +++ b/lnbits/extensions/copilot/crud.py @@ -15,9 +15,14 @@ from quart import jsonify async def create_copilot( title: str, user: str, - animation: str = None, + animation1: Optional[str] = None, + animation2: Optional[str] = None, + animation3: Optional[str] = None, + animation1threshold: Optional[int] = None, + animation2threshold: Optional[int] = None, + animation3threshold: Optional[int] = None, show_message: Optional[str] = None, - amount: Optional[str] = None, + amount: Optional[int] = None, lnurl_title: Optional[str] = None, ) -> Copilots: copilot_id = urlsafe_short_hash() @@ -28,18 +33,28 @@ async def create_copilot( id, user, title, - animation, + animation1, + animation2, + animation3, + animation1threshold, + animation2threshold, + animation3threshold, show_message, amount, lnurl_title ) - VALUES (?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, ( copilot_id, user, title, - animation, + animation1, + animation2, + animation3, + animation1threshold, + animation2threshold, + animation3threshold, show_message, amount, lnurl_title diff --git a/lnbits/extensions/copilot/migrations.py b/lnbits/extensions/copilot/migrations.py index 6f46bf218..d0ef2d5c8 100644 --- a/lnbits/extensions/copilot/migrations.py +++ b/lnbits/extensions/copilot/migrations.py @@ -9,7 +9,12 @@ async def m001_initial(db): id TEXT NOT NULL PRIMARY KEY, user TEXT, title TEXT, - animation INTEGER, + animation1 TEXT, + animation2 TEXT, + animation3 TEXT, + animation1threshold INTEGER, + animation2threshold INTEGER, + animation3threshold INTEGER, show_message TEXT, amount INTEGER, lnurl_title TEXT, diff --git a/lnbits/extensions/copilot/models.py b/lnbits/extensions/copilot/models.py index b9d3325f7..f083f0d38 100644 --- a/lnbits/extensions/copilot/models.py +++ b/lnbits/extensions/copilot/models.py @@ -7,13 +7,18 @@ class Copilots(NamedTuple): id: str user: str title: str - animation: str + animation1: str + animation2: str + animation3: str + animation1threshold: int + animation2threshold: int + animation3threshold: int show_message: bool amount: int lnurl_title: str @classmethod - def from_row(cls, row: Row) -> "Charges": + def from_row(cls, row: Row) -> "Copilots": return cls(**dict(row)) @property diff --git a/lnbits/extensions/copilot/templates/copilot/_api_docs.html b/lnbits/extensions/copilot/templates/copilot/_api_docs.html index 85527ce8e..1914ed1eb 100644 --- a/lnbits/extensions/copilot/templates/copilot/_api_docs.html +++ b/lnbits/extensions/copilot/templates/copilot/_api_docs.html @@ -1,7 +1,7 @@

- StreamCopilot: get tips and show an animation
+ StreamCopilot: get tips via static QR (lnurl-pay) and show an animation
Created by, Ben Arc diff --git a/lnbits/extensions/copilot/templates/copilot/index.html b/lnbits/extensions/copilot/templates/copilot/index.html index a9be0591a..70ce91924 100644 --- a/lnbits/extensions/copilot/templates/copilot/index.html +++ b/lnbits/extensions/copilot/templates/copilot/index.html @@ -131,11 +131,78 @@ +

+
+ +
+ +
+ + +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ + +
+
+ - - - - - - - - - -
-
-
- -
-
- - - Watch-Only extension MUST be activated and have a wallet - - -
-
-
-
- -
-
-
- -
- +
- - -
Create Copilot diff --git a/lnbits/extensions/copilot/views_api.py b/lnbits/extensions/copilot/views_api.py index 18eb41520..69cdff7f2 100644 --- a/lnbits/extensions/copilot/views_api.py +++ b/lnbits/extensions/copilot/views_api.py @@ -24,7 +24,12 @@ from .crud import ( @api_validate_post_request( schema={ "title": {"type": "string", "empty": False, "required": True}, - "animation": {"type": "string", "empty": False, "required": True}, + "animation1": {"type": "string"}, + "animation2": {"type": "string"}, + "animation3": {"type": "string"}, + "animation1threshold": {"type": "integer"}, + "animation2threshold": {"type": "integer"}, + "animation3threshold": {"type": "integer"}, "show_message": {"type": "integer", "empty": False, "required": True}, "amount": {"type": "integer", "empty": False, "required": True}, } @@ -40,7 +45,7 @@ async def api_copilot_create_or_update(copilot_id=None): @copilot_ext.route("/api/v1/copilot", methods=["GET"]) @api_check_wallet_key("invoice") -async def api_copilot_retrieve(copilot_id): +async def api_copilots_retrieve(copilot_id): copilots = await get_copilots(user=g.wallet.user) if not copilots: