mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-20 10:39:59 +01:00
24 lines
507 B
Python
24 lines
507 B
Python
|
import json
|
||
|
|
||
|
from sqlite3 import Row
|
||
|
from typing import NamedTuple, Optional
|
||
|
|
||
|
|
||
|
class Captcha(NamedTuple):
|
||
|
id: str
|
||
|
wallet: str
|
||
|
url: str
|
||
|
memo: str
|
||
|
description: str
|
||
|
amount: int
|
||
|
time: int
|
||
|
remembers: bool
|
||
|
extras: Optional[dict]
|
||
|
|
||
|
@classmethod
|
||
|
def from_row(cls, row: Row) -> "Captcha":
|
||
|
data = dict(row)
|
||
|
data["remembers"] = bool(data["remembers"])
|
||
|
data["extras"] = json.loads(data["extras"]) if data["extras"] else None
|
||
|
return cls(**data)
|