This commit is contained in:
Believethehype 2024-03-20 09:24:49 +01:00
parent 8f9833b0f6
commit 8a9ba97cb3
3 changed files with 11 additions and 9 deletions

View File

@ -54,16 +54,16 @@ class Subscription:
zap_filter = Filter().pubkey(pk).kinds([EventDefinitions.KIND_ZAP]).since(Timestamp.now())
cancel_subscription_filter = Filter().kinds([EventDefinitions.KIND_NIP88_STOP_SUBSCRIPTION_EVENT]).since(
Timestamp.now())
# TODO define allowed senders somewhere
dm_filter = Filter().author(
Keys.parse("ece3c0aa759c3e895ecb3c13ab3813c0f98430c6d4bd22160b9c2219efc9cf0e").public_key()).pubkey(
pk).kinds([EventDefinitions.KIND_DM]).since(Timestamp.now())
authors = []
if admin_config is not None:
for key in admin_config.USERNPUBS:
authors.append(PublicKey.parse(key))
dm_filter = Filter().authors(authors).pubkey(pk).kinds([EventDefinitions.KIND_DM]).since(Timestamp.now())
self.client.subscribe([zap_filter, dm_filter, cancel_subscription_filter], None)
create_subscription_sql_table(dvm_config.DB)
# admin_make_database_updates(adminconfig=self.admin_config, dvmconfig=self.dvm_config, client=self.client)
class NotificationHandler(HandleNotification):
client = self.client

View File

@ -16,7 +16,6 @@ class DVMConfig:
FIX_COST: float = None
PER_UNIT_COST: float = None
RELAY_LIST = ["wss://relay.damus.io", "wss://nos.lol", "wss://nostr.wine",
"wss://nostr.mom", "wss://nostr.oxtr.dev", "wss://relay.nostr.bg",
"wss://relay.f7z.io", "wss://pablof7z.nostr1.com", "wss://relay.nostr.net", "wss://140.f7z.io",
@ -24,13 +23,13 @@ class DVMConfig:
RELAY_TIMEOUT = 5
EXTERNAL_POST_PROCESS_TYPE = PostProcessFunctionType.NONE # Leave this on None, except the DVM is external
LNBITS_INVOICE_KEY = '' # Will all automatically generated by default, or read from .env
LNBITS_INVOICE_KEY = '' # Will all automatically generated by default, or read from .env
LNBITS_ADMIN_KEY = '' # In order to pay invoices, e.g. from the bot to DVMs, or reimburse users.
LNBITS_URL = 'https://lnbits.com'
LN_ADDRESS = ''
SCRIPT = ''
IDENTIFIER = ''
USE_OWN_VENV = True # Make an own venv for each dvm's process function.Disable if you want to install packages into main venv. Only recommended if you dont want to run dvms with different dependency versions
USE_OWN_VENV = True # Make an own venv for each dvm's process function.Disable if you want to install packages into main venv. Only recommended if you dont want to run dvms with different dependency versions
DB: str
NEW_USER_BALANCE: int = 0 # Free credits for new users
NIP88: NIP88Config
@ -39,6 +38,7 @@ class DVMConfig:
SHOW_RESULT_BEFORE_PAYMENT: bool = False # if this is true show results even when not paid right after autoprocess
SCHEDULE_UPDATES_SECONDS = 0
def build_default_config(identifier):
dvm_config = DVMConfig()
dvm_config.PRIVATE_KEY = check_and_set_private_key(identifier)

View File

@ -38,7 +38,9 @@ def playground():
subscription_config.LNBITS_INVOICE_KEY = invoice_key
subscription_config.LNBITS_ADMIN_KEY = admin_key # The dvm might pay failed jobs back
subscription_config.LNBITS_URL = os.getenv("LNBITS_HOST")
x = threading.Thread(target=Subscription, args=(Subscription(subscription_config),))
sub_admin_config = AdminConfig()
sub_admin_config.USERNPUBS = ["7782f93c5762538e1f7ccc5af83cd8018a528b9cd965048386ca1b75335f24c6"] #Add npubs of services that can contact the subscription handler
x = threading.Thread(target=Subscription, args=(Subscription(subscription_config, sub_admin_config),))
x.start()
#keep_alive()