parent
d656d41b90
commit
a8eb139360
25 changed files with 3192 additions and 237 deletions
45
__init__.py
45
__init__.py
|
|
@ -1,17 +1,13 @@
|
|||
import asyncio
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter
|
||||
from loguru import logger
|
||||
|
||||
from lnbits.db import Database
|
||||
from lnbits.helpers import template_renderer
|
||||
from lnbits.tasks import create_permanent_unique_task
|
||||
|
||||
from .nostr.client.client import NostrClient
|
||||
from .router import NostrRouter
|
||||
|
||||
db = Database("ext_nostrclient")
|
||||
from .crud import db
|
||||
from .nostr_client import all_routers, nostr_client
|
||||
from .tasks import check_relays, init_relays, subscribe_events
|
||||
from .views import nostrclient_generic_router
|
||||
from .views_api import nostrclient_api_router
|
||||
|
||||
nostrclient_static_files = [
|
||||
{
|
||||
|
|
@ -21,23 +17,11 @@ nostrclient_static_files = [
|
|||
]
|
||||
|
||||
nostrclient_ext: APIRouter = APIRouter(prefix="/nostrclient", tags=["nostrclient"])
|
||||
|
||||
nostr_client: NostrClient = NostrClient()
|
||||
|
||||
# we keep this in
|
||||
all_routers: list[NostrRouter] = []
|
||||
nostrclient_ext.include_router(nostrclient_generic_router)
|
||||
nostrclient_ext.include_router(nostrclient_api_router)
|
||||
scheduled_tasks: list[asyncio.Task] = []
|
||||
|
||||
|
||||
def nostr_renderer():
|
||||
return template_renderer(["nostrclient/templates"])
|
||||
|
||||
|
||||
from .tasks import check_relays, init_relays, subscribe_events # noqa
|
||||
from .views import * # noqa
|
||||
from .views_api import * # noqa
|
||||
|
||||
|
||||
async def nostrclient_stop():
|
||||
for task in scheduled_tasks:
|
||||
try:
|
||||
|
|
@ -56,7 +40,20 @@ async def nostrclient_stop():
|
|||
|
||||
|
||||
def nostrclient_start():
|
||||
from lnbits.tasks import create_permanent_unique_task
|
||||
|
||||
task1 = create_permanent_unique_task("ext_nostrclient_init_relays", init_relays)
|
||||
task2 = create_permanent_unique_task("ext_nostrclient_subscrive_events", subscribe_events)
|
||||
task2 = create_permanent_unique_task(
|
||||
"ext_nostrclient_subscrive_events", subscribe_events
|
||||
)
|
||||
task3 = create_permanent_unique_task("ext_nostrclient_check_relays", check_relays)
|
||||
scheduled_tasks.extend([task1, task2, task3])
|
||||
|
||||
|
||||
__all__ = [
|
||||
"db",
|
||||
"nostrclient_ext",
|
||||
"nostrclient_static_files",
|
||||
"nostrclient_stop",
|
||||
"nostrclient_start",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue