lnbits-legend/lnbits/extensions/copilot/models.py

65 lines
2.1 KiB
Python
Raw Normal View History

2021-10-12 20:24:00 +01:00
from urllib.parse import urlparse, urlunparse, parse_qs, urlencode, ParseResult
from starlette.requests import Request
from fastapi.param_functions import Query
from typing import Optional, Dict
from lnbits.lnurl import encode as lnurl_encode # type: ignore
2021-10-12 19:54:35 +01:00
from lnurl.types import LnurlPayMetadata # type: ignore
2021-10-12 20:24:00 +01:00
from pydantic import BaseModel
2021-10-17 23:19:42 +01:00
import json
from sqlite3 import Row
2021-10-12 20:24:00 +01:00
class CreateCopilotData(BaseModel):
2021-10-13 11:20:40 +01:00
user: str = Query(None)
title: str = Query(None)
2021-10-13 12:37:10 +01:00
lnurl_toggle: int = Query(0)
2021-10-13 11:20:40 +01:00
wallet: str = Query(None)
animation1: str = Query(None)
animation2: str = Query(None)
animation3: str = Query(None)
animation1threshold: int = Query(None)
animation2threshold: int = Query(None)
animation3threshold: int = Query(None)
animation1webhook: str = Query(None)
animation2webhook: str = Query(None)
animation3webhook: str = Query(None)
lnurl_title: str = Query(None)
2021-10-13 12:37:10 +01:00
show_message: int = Query(0)
show_ack: int = Query(0)
2021-10-13 11:20:40 +01:00
show_price: str = Query(None)
2021-10-13 12:37:10 +01:00
amount_made: int = Query(0)
timestamp: int = Query(0)
fullscreen_cam: int = Query(0)
iframe_url: str = Query(None)
2021-10-13 11:20:40 +01:00
success_url: str = Query(None)
2021-10-12 19:54:35 +01:00
2021-10-12 20:24:00 +01:00
class Copilots(BaseModel):
2021-10-12 19:54:35 +01:00
id: str
2021-10-13 12:37:10 +01:00
user: str = Query(None)
title: str = Query(None)
lnurl_toggle: int = Query(0)
wallet: str = Query(None)
animation1: str = Query(None)
animation2: str = Query(None)
animation3: str = Query(None)
animation1threshold: int = Query(None)
animation2threshold: int = Query(None)
animation3threshold: int = Query(None)
animation1webhook: str = Query(None)
animation2webhook: str = Query(None)
animation3webhook: str = Query(None)
lnurl_title: str = Query(None)
show_message: int = Query(0)
show_ack: int = Query(0)
show_price: str = Query(None)
amount_made: int = Query(0)
timestamp: int = Query(0)
fullscreen_cam: int = Query(0)
iframe_url: str = Query(None)
success_url: str = Query(None)
2021-10-12 19:54:35 +01:00
2021-10-12 20:24:00 +01:00
def lnurl(self, req: Request) -> str:
2021-10-17 23:19:42 +01:00
url = req.url_for("copilot.lnurl_response", cp_id=self.id)
2021-10-12 19:54:35 +01:00
return lnurl_encode(url)