minor fixes

This commit is contained in:
Believethehype 2024-05-17 22:29:58 +02:00
parent 947ed3c146
commit 104880ad31
7 changed files with 19 additions and 15 deletions

View File

@ -346,15 +346,15 @@ class DVM:
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))

View File

@ -202,7 +202,7 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
# 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

View File

@ -218,7 +218,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
# 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

View File

@ -233,7 +233,7 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
# 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

View File

@ -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)

View File

@ -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')

View File

@ -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()