Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
believethehype committed May 17, 2024
1 parent 947ed3c commit 104880a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
8 changes: 4 additions & 4 deletions nostr_dvm/dvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions nostr_dvm/tasks/content_discovery_currently_popular.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions nostr_dvm/tasks/content_discovery_currently_popular_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 0 additions & 2 deletions nostr_dvm/utils/database_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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')

Expand Down
10 changes: 8 additions & 2 deletions tests/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 104880a

Please sign in to comment.