-
Notifications
You must be signed in to change notification settings - Fork 9
/
__init__.py
44 lines (30 loc) · 1.13 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
42
43
44
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)