2021-04-12 20:31:39 +01:00
|
|
|
from sqlite3 import Row
|
|
|
|
from typing import NamedTuple
|
|
|
|
import time
|
2021-04-14 23:45:28 +01:00
|
|
|
from quart import url_for
|
|
|
|
from lnurl import Lnurl, encode as lnurl_encode # type: ignore
|
|
|
|
from lnurl.types import LnurlPayMetadata # type: ignore
|
|
|
|
from lnurl.models import LnurlPaySuccessAction, UrlAction # type: ignore
|
2021-04-12 20:31:39 +01:00
|
|
|
|
2021-04-16 12:20:05 +01:00
|
|
|
|
2021-04-12 20:31:39 +01:00
|
|
|
class Copilots(NamedTuple):
|
|
|
|
id: str
|
|
|
|
user: str
|
|
|
|
title: str
|
2021-06-24 00:33:49 +01:00
|
|
|
lnurl_toggle: int
|
2021-04-14 23:45:28 +01:00
|
|
|
wallet: str
|
2021-04-12 22:05:54 +01:00
|
|
|
animation1: str
|
|
|
|
animation2: str
|
|
|
|
animation3: str
|
|
|
|
animation1threshold: int
|
|
|
|
animation2threshold: int
|
|
|
|
animation3threshold: int
|
2021-04-13 17:10:25 +01:00
|
|
|
animation1webhook: str
|
|
|
|
animation2webhook: str
|
|
|
|
animation3webhook: str
|
2021-04-12 20:31:39 +01:00
|
|
|
lnurl_title: str
|
2021-04-13 17:10:25 +01:00
|
|
|
show_message: int
|
|
|
|
show_ack: int
|
2021-06-24 00:33:49 +01:00
|
|
|
show_price: int
|
2021-04-13 17:10:25 +01:00
|
|
|
amount_made: int
|
2021-04-13 19:20:12 +01:00
|
|
|
timestamp: int
|
|
|
|
fullscreen_cam: int
|
|
|
|
iframe_url: str
|
2021-04-12 20:31:39 +01:00
|
|
|
|
|
|
|
@classmethod
|
2021-04-12 22:05:54 +01:00
|
|
|
def from_row(cls, row: Row) -> "Copilots":
|
2021-04-12 20:31:39 +01:00
|
|
|
return cls(**dict(row))
|
2021-04-14 23:45:28 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def lnurl(self) -> Lnurl:
|
|
|
|
url = url_for("copilot.lnurl_response", cp_id=self.id, _external=True)
|
2021-04-16 12:20:05 +01:00
|
|
|
return lnurl_encode(url)
|