-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
41 lines (30 loc) · 1.06 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import asyncio
from fastapi import APIRouter
from lnbits.tasks import create_permanent_unique_task
from loguru import logger
from .crud import db
from .tasks import wait_for_paid_invoices
from .views import eightball_generic_router
from .views_api import eightball_api_router
from .views_lnurl import eightball_lnurl_router
eightball_ext: APIRouter = APIRouter(prefix="/eightball", tags=["EightBall"])
eightball_ext.include_router(eightball_generic_router)
eightball_ext.include_router(eightball_api_router)
eightball_ext.include_router(eightball_lnurl_router)
eightball_static_files = [
{
"path": "/eightball/static",
"name": "eightball_static",
}
]
scheduled_tasks: list[asyncio.Task] = []
def eightball_stop():
for task in scheduled_tasks:
try:
task.cancel()
except Exception as ex:
logger.warning(ex)
def eightball_start():
task = create_permanent_unique_task("ext_eightball", wait_for_paid_invoices)
scheduled_tasks.append(task)
__all__ = ["db", "eightball_ext", "eightball_static_files"]