From 104880ad315e899f07d1e3661d1e5116542ed8b1 Mon Sep 17 00:00:00 2001 From: Believethehype <1097224+believethehype@users.noreply.github.com> Date: Fri, 17 May 2024 22:29:58 +0200 Subject: [PATCH] minor fixes --- nostr_dvm/dvm.py | 8 ++++---- nostr_dvm/tasks/content_discovery_currently_popular.py | 4 ++-- .../content_discovery_currently_popular_followers.py | 4 ++-- .../tasks/content_discovery_currently_popular_topic.py | 4 ++-- nostr_dvm/utils/database_utils.py | 2 -- setup.py | 2 +- tests/discovery.py | 10 ++++++++-- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/nostr_dvm/dvm.py b/nostr_dvm/dvm.py index ea5a10b..32e922b 100644 --- a/nostr_dvm/dvm.py +++ b/nostr_dvm/dvm.py @@ -346,15 +346,15 @@ def handle_zap(zap_event): elif not anon: print("[" + self.dvm_config.NIP89.NAME + "] Note Zap received for DVM balance: " + str(invoice_amount) + " Sats from " + str(user.name)) - update_user_balance(self.dvm_config.DB, sender, invoice_amount, client=self.client, - config=self.dvm_config) + # update_user_balance(self.dvm_config.DB, sender, invoice_amount, client=self.client, + # config=self.dvm_config) # a regular note elif not anon and dvm_config.NIP88 is None: print("[" + self.dvm_config.NIP89.NAME + "] Profile Zap received for DVM balance: " + str(invoice_amount) + " Sats from " + str(user.name)) - update_user_balance(self.dvm_config.DB, sender, invoice_amount, client=self.client, - config=self.dvm_config) + # update_user_balance(self.dvm_config.DB, sender, invoice_amount, client=self.client, + # config=self.dvm_config) except Exception as e: print("[" + self.dvm_config.NIP89.NAME + "] Error during content decryption: " + str(e)) diff --git a/nostr_dvm/tasks/content_discovery_currently_popular.py b/nostr_dvm/tasks/content_discovery_currently_popular.py index cd97ad7..a297788 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular.py @@ -202,7 +202,7 @@ def sync_db(self): # We build an example here that we can call by either calling this file directly from the main directory, # or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the # playground or elsewhere -def build_example(name, identifier, admin_config, options, processing_msg=None, update_db=True): +def build_example(name, identifier, admin_config, options, cost=0, processing_msg=None, update_db=True): dvm_config = build_default_config(identifier) dvm_config.USE_OWN_VENV = False dvm_config.SHOWLOG = True @@ -211,7 +211,7 @@ def build_example(name, identifier, admin_config, options, processing_msg=None, # Activate these to use a subscription based model instead # dvm_config.SUBSCRIPTION_REQUIRED = True # dvm_config.SUBSCRIPTION_DAILY_COST = 1 - dvm_config.FIX_COST = 0 + dvm_config.FIX_COST = cost dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg admin_config.LUD16 = dvm_config.LN_ADDRESS diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py index 6a3d02f..59dca50 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py @@ -218,7 +218,7 @@ def sync_db(self): # We build an example here that we can call by either calling this file directly from the main directory, # or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the # playground or elsewhere -def build_example(name, identifier, admin_config, options, processing_msg=None, update_db=True): +def build_example(name, identifier, admin_config, options, cost=0, processing_msg=None, update_db=True): dvm_config = build_default_config(identifier) dvm_config.USE_OWN_VENV = False dvm_config.SHOWLOG = True @@ -227,7 +227,7 @@ def build_example(name, identifier, admin_config, options, processing_msg=None, # Activate these to use a subscription based model instead # dvm_config.SUBSCRIPTION_REQUIRED = True # dvm_config.SUBSCRIPTION_DAILY_COST = 1 - dvm_config.FIX_COST = 0 + dvm_config.FIX_COST = cost dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg admin_config.LUD16 = dvm_config.LN_ADDRESS diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py index 13ea6f5..9f1c554 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py @@ -233,7 +233,7 @@ def sync_db(self): # We build an example here that we can call by either calling this file directly from the main directory, # or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the # playground or elsewhere -def build_example(name, identifier, admin_config, options, image, description, processing_msg=None, update_db=True): +def build_example(name, identifier, admin_config, options, image, description, cost=0, processing_msg=None, update_db=True): dvm_config = build_default_config(identifier) dvm_config.USE_OWN_VENV = False dvm_config.SHOWLOG = True @@ -242,7 +242,7 @@ def build_example(name, identifier, admin_config, options, image, description, p # Activate these to use a subscription based model instead # dvm_config.SUBSCRIPTION_REQUIRED = True # dvm_config.SUBSCRIPTION_DAILY_COST = 1 - dvm_config.FIX_COST = 0 + dvm_config.FIX_COST = cost dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg admin_config.LUD16 = dvm_config.LN_ADDRESS diff --git a/nostr_dvm/utils/database_utils.py b/nostr_dvm/utils/database_utils.py index 4662ddd..a1faa1e 100644 --- a/nostr_dvm/utils/database_utils.py +++ b/nostr_dvm/utils/database_utils.py @@ -195,8 +195,6 @@ def update_user_balance(db, npub, additional_sats, client, config, giftwrap=Fals if giftwrap: client.send_sealed_msg(PublicKey.parse(npub), message, None) else: - - evt = EventBuilder.encrypted_direct_msg(keys, PublicKey.parse(npub), message, None).to_event(keys) send_event(evt, client=client, dvm_config=config) diff --git a/setup.py b/setup.py index f411e80..98ec34a 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -VERSION = '0.4.3' +VERSION = '0.4.4' 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') diff --git a/tests/discovery.py b/tests/discovery.py index 7ac80c6..4171dba 100644 --- a/tests/discovery.py +++ b/tests/discovery.py @@ -58,11 +58,12 @@ def playground(): custom_processing_msg = ["Finding the best notes for you.. #blooming", "Looking for some positivity.. #touchgrass", "Looking for #goodvibes.."] update_db = False + cost = 0 discovery_test_sub = content_discovery_currently_popular_topic.build_example("Garden & Growth", "discovery_content_garden", admin_config_plants, options_plants, image, - description, custom_processing_msg, + description, cost, custom_processing_msg, update_db) discovery_test_sub.run() @@ -97,12 +98,13 @@ def playground(): custom_processing_msg = ["Looking for fluffy frens...", "Let's see if we find some animals for you..", "Looking for the goodest bois and girls.."] + cost = 0 update_db = True #As this is our largerst DB we update it here, and the other dvms use it. TODO make an own scheduler that only updates the db discovery_animals = content_discovery_currently_popular_topic.build_example("Fluffy Frens", "discovery_content_fluffy", admin_config_animals, options_animal, image, - description, custom_processing_msg, + description, cost, custom_processing_msg, update_db) discovery_animals.run() @@ -118,12 +120,14 @@ def playground(): "db_name": "db/nostr_recent_notes.db", "db_since": 2 * 60 * 60, # 2h since gmt, } + cost = 0 discovery_followers = content_discovery_currently_popular_followers.build_example( "Currently Popular Notes from npubs you follow", "discovery_content_followers", admin_config=admin_config_followers, options=options_followers_popular, + cost=cost, processing_msg=custom_processing_msg, update_db=update_db) discovery_followers.run() @@ -140,10 +144,12 @@ def playground(): "db_name": "db/nostr_recent_notes.db", "db_since": 60 * 60, # 1h since gmt, } + cost = 0 discovery_global = content_discovery_currently_popular.build_example("Currently Popular Notes DVM", "discovery_content_test", admin_config=admin_config_global_popular, options=options_global_popular, + cost=cost, processing_msg=custom_processing_msg, update_db=update_db) discovery_global.run()