diff --git a/nostr_dvm/subscription.py b/nostr_dvm/subscription.py index 30c3aaf..624a227 100644 --- a/nostr_dvm/subscription.py +++ b/nostr_dvm/subscription.py @@ -222,9 +222,10 @@ class Subscription: for relay in dvmconfig.RELAY_LIST: await client.add_relay(relay) await client.connect() - recipeid = await client.send_event(event) + recipe = await client.send_event(event) + recipe_id = recipe.id await client.shutdown() - recipe = recipeid.to_hex() + recipe = recipe_id.to_hex() return recipe async def handle_nwc_request(nostr_event): diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py index 224cae3..b3a7fc1 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py @@ -103,9 +103,8 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface): database = await NostrDatabase.sqlite(self.db_name) cli = ClientBuilder().database(database).signer(signer).opts(opts).build() - await cli.add_relay("wss://relay.damus.io") - await cli.add_relay("wss://nostr.oxtr.dev") - await cli.add_relay("wss://nostr.mom") + for relay in self.dvm_config.RECONCILE_DB_RELAY_LIST: + await cli.add_relay(relay) #ropts = RelayOptions().ping(False) #cli.add_relay_with_opts("wss://nostr.band", ropts) diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py b/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py index 8d410cf..8b23a8c 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py @@ -159,9 +159,8 @@ class DicoverContentCurrentlyPopularGallery(DVMTaskInterface): for relay in relays: await cli.add_relay(relay) - await cli.add_relay("wss://relay.damus.io") - await cli.add_relay("wss://relay.primal.net") - await cli.add_relay("wss://nostr.mom") + for relay in self.dvm_config.RECONCILE_DB_RELAY_LIST: + await cli.add_relay(relay) await cli.connect() diff --git a/nostr_dvm/utils/definitions.py b/nostr_dvm/utils/definitions.py index 3a0ede8..5100d15 100644 --- a/nostr_dvm/utils/definitions.py +++ b/nostr_dvm/utils/definitions.py @@ -5,7 +5,9 @@ from nostr_sdk import Event, Kind class EventDefinitions: + KIND_PROFILE = Kind(0) KIND_NOTE = Kind(1) + KIND_FOLLOW_LIST = Kind(3) KIND_DM = Kind(4) KIND_REPOST = Kind(6) KIND_REACTION = Kind(7) diff --git a/nostr_dvm/utils/nip65_utils.py b/nostr_dvm/utils/nip65_utils.py index a956c0a..ffa737f 100644 --- a/nostr_dvm/utils/nip65_utils.py +++ b/nostr_dvm/utils/nip65_utils.py @@ -17,5 +17,9 @@ async def nip65_announce_relays(dvm_config, client): event = EventBuilder(EventDefinitions.KIND_RELAY_ANNOUNCEMENT, content, tags).to_event(keys) eventid = await send_event(event, client=client, dvm_config=dvm_config, blastr=True) + if(eventid is not None): + print(bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced NIP 65 for " + dvm_config.NIP89.NAME +" (EventID: " + str(eventid.to_hex()) +")" + bcolors.ENDC) + else: + print( + bcolors.RED + "[" + dvm_config.NIP89.NAME + "] Could not announce NIP 65 for " + dvm_config.NIP89.NAME + bcolors.ENDC) - print(bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced NIP 65 for " + dvm_config.NIP89.NAME +" (EventID: " + str(eventid.to_hex()) +")" + bcolors.ENDC) diff --git a/nostr_dvm/utils/nostr_utils.py b/nostr_dvm/utils/nostr_utils.py index 4fd0751..57a4e5c 100644 --- a/nostr_dvm/utils/nostr_utils.py +++ b/nostr_dvm/utils/nostr_utils.py @@ -223,7 +223,8 @@ async def send_event(event: Event, client: Client, dvm_config, blastr=False): #if blastr: # client.add_relay("wss://nostr.mutinywallet.com") try: - event_id = await client.send_event(event) + output = await client.send_event(event) + event_id = output.id except Exception as e: print(e) event_id = None diff --git a/setup.py b/setup.py index 21d765e..632bb7c 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -VERSION = '0.7.5' +VERSION = '0.7.6' DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines' LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information') @@ -14,7 +14,7 @@ setup( long_description=LONG_DESCRIPTION, packages=find_packages(include=['nostr_dvm', 'nostr_dvm.*']), - install_requires=["nostr-sdk==0.32.2", + install_requires=["nostr-sdk==0.33.0", "bech32==1.2.0", "pycryptodome==3.20.0", "yt-dlp==2024.5.27", diff --git a/tests/discovery_gallery.py b/tests/discovery_gallery.py index e8c8bc5..465ab56 100644 --- a/tests/discovery_gallery.py +++ b/tests/discovery_gallery.py @@ -19,8 +19,6 @@ update_profile = True global_update_rate = 1200 # set this high on first sync so db can fully sync before another process trys to. use_logger = True -RECONCILE_DB_RELAY_LIST = ["wss://relay.damus.io", "wss://nostr.mom"] # , "wss://relay.snort.social"] - if use_logger: init_logger(LogLevel.INFO) @@ -33,7 +31,6 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0 # dvm_config.SHOWLOG = True dvm_config.SCHEDULE_UPDATES_SECONDS = update_rate # Every 10 minutes dvm_config.UPDATE_DATABASE = update_db - dvm_config.RECONCILE_DB_RELAY_LIST = RECONCILE_DB_RELAY_LIST dvm_config.LOGLEVEL = LogLevel.DEBUG dvm_config.FIX_COST = cost # dvm_config.RELAY_LIST = ["wss://dvms.f7z.io", "wss://nostr.oxtr.dev", "wss://relay.nostr.bg", diff --git a/tests/test_dvm_client.py b/tests/test_dvm_client.py index c1a71ba..cad51b2 100644 --- a/tests/test_dvm_client.py +++ b/tests/test_dvm_client.py @@ -326,8 +326,8 @@ async def nostr_client(): # await nostr_client_test_image("a beautiful purple ostrich watching the sunset") # await nostr_client_test_search_profile("dontbelieve") wot = ["99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64"] - #await nostr_client_test_discovery("99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64", "3553867e9376c1611367b5ad0488d7d0b6bfc3fca2010282cc0dc4666da4e7fb") - await nostr_client_test_discovery_gallery("99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64", "4add3944eb596a27a650f9b954f5ed8dfefeec6ca50473605b0fbb058dd11306") + await nostr_client_test_discovery("99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64", "ab6cdf12ca3ae5109416295b8cd8a53fdec3a9d54beb7a9aee0ebfb67cb4edf7") + #await nostr_client_test_discovery_gallery("99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64", "4add3944eb596a27a650f9b954f5ed8dfefeec6ca50473605b0fbb058dd11306") #await nostr_client_test_disovery_user("99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64", # "58c52fdca7593dffea63ba6f758779d8251c6732f54e9dc0e56d7a1afe1bb1b6")