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

34 lines
870 B
Python
Raw Normal View History

2021-10-12 20:24:00 +01:00
import asyncio
2021-10-28 17:01:49 +01:00
from fastapi import APIRouter
2021-10-12 20:24:00 +01:00
from fastapi.staticfiles import StaticFiles
2021-10-28 17:01:49 +01:00
2021-10-12 19:54:35 +01:00
from lnbits.db import Database
2021-10-12 20:24:00 +01:00
from lnbits.helpers import template_renderer
from lnbits.tasks import catch_everything_and_restart
2021-10-12 19:54:35 +01:00
db = Database("ext_copilot")
2021-10-12 20:24:00 +01:00
copilot_static_files = [
{
"path": "/copilot/static",
"app": StaticFiles(directory="lnbits/extensions/copilot/static"),
"name": "copilot_static",
}
]
copilot_ext: APIRouter = APIRouter(prefix="/copilot", tags=["copilot"])
2021-10-12 19:54:35 +01:00
2021-10-12 20:24:00 +01:00
def copilot_renderer():
2021-10-17 18:33:29 +01:00
return template_renderer(["lnbits/extensions/copilot/templates"])
2021-10-12 20:24:00 +01:00
2021-10-12 19:54:35 +01:00
from .lnurl import * # noqa
2021-10-28 17:01:49 +01:00
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
2021-10-12 19:54:35 +01:00
2021-10-12 20:24:00 +01:00
def copilot_start():
loop = asyncio.get_event_loop()
2021-11-04 11:11:56 +00:00
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))