* refactor: clean-up * refactor: extra logs plus try-catch * refactor: do not use bare `except` * refactor: clean-up redundant fields * chore: pass code checks * chore: code format * refactor: code clean-up * fix: refactoring stuff * refactor: remove un-used file * chore: code clean-up * chore: code clean-up * chore: code-format fix * refactor: remove nostr.client wrapper * refactor: code clean-up * chore: code format * refactor: remove `RelayList` class * refactor: extract smaller methods with try-catch * fix: better exception handling * fix: remove redundant filters * fix: simplify event * chore: code format * fix: code check * fix: code check * fix: simplify `REQ` * fix: more clean-ups * refactor: use simpler method * refactor: re-order and rename * fix: stop logic * fix: subscription close before disconnect * chore: play commit
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
import asyncio
|
|
from typing import List
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from lnbits.db import Database
|
|
from lnbits.helpers import template_renderer
|
|
from lnbits.tasks import catch_everything_and_restart
|
|
|
|
from .nostr.client.client import NostrClient
|
|
|
|
db = Database("ext_nostrclient")
|
|
|
|
nostrclient_static_files = [
|
|
{
|
|
"path": "/nostrclient/static",
|
|
"name": "nostrclient_static",
|
|
}
|
|
]
|
|
|
|
nostrclient_ext: APIRouter = APIRouter(prefix="/nostrclient", tags=["nostrclient"])
|
|
|
|
scheduled_tasks: List[asyncio.Task] = []
|
|
|
|
nostr_client = NostrClient()
|
|
|
|
|
|
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
|
|
|
|
|
|
def nostrclient_start():
|
|
loop = asyncio.get_event_loop()
|
|
task1 = loop.create_task(catch_everything_and_restart(init_relays))
|
|
scheduled_tasks.append(task1)
|
|
task2 = loop.create_task(catch_everything_and_restart(subscribe_events))
|
|
scheduled_tasks.append(task2)
|
|
task3 = loop.create_task(catch_everything_and_restart(check_relays))
|
|
scheduled_tasks.append(task3)
|