nip89 announce relays, revert some changes to content dvms

This commit is contained in:
Believethehype
2024-06-01 23:46:00 +02:00
parent a2107eb335
commit 0ad44f2917
6 changed files with 221 additions and 198 deletions

View File

@@ -33,7 +33,6 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
min_reactions = 2 min_reactions = 2
personalized = False personalized = False
result = "" result = ""
logger = False
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None, def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
admin_config: AdminConfig = None, options=None): admin_config: AdminConfig = None, options=None):
@@ -48,32 +47,16 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
self.request_form['options'] = json.dumps(opts) self.request_form['options'] = json.dumps(opts)
self.last_schedule = Timestamp.now().as_secs() self.last_schedule = Timestamp.now().as_secs()
if self.options is not None:
if self.options.get("db_name"):
self.db_name = self.options.get("db_name")
if self.options.get("db_since"):
self.db_since = int(self.options.get("db_since"))
if self.options.get("logger"):
self.logger = bool(self.options.get("logger"))
if self.logger: if self.options.get("db_name"):
init_logger(LogLevel.DEBUG) self.db_name = self.options.get("db_name")
if self.options.get("db_since"):
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_LONG_TIMEOUT))) self.db_since = int(self.options.get("db_since"))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
self.client = ClientBuilder().signer(signer).database(database).opts(opts).build()
ropts = RelayOptions().ping(False)
self.client.add_relay_with_opts("wss://relay.damus.io", ropts)
self.client.add_relay_with_opts("wss://nostr.oxtr.dev", ropts)
self.client.add_relay_with_opts("wss://nostr21.com", ropts)
self.client.connect()
use_logger = False
if use_logger:
init_logger(LogLevel.DEBUG)
if self.dvm_config.UPDATE_DATABASE: if self.dvm_config.UPDATE_DATABASE:
self.sync_db() self.sync_db()
@@ -97,7 +80,7 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
# default values # default values
search = "" search = ""
max_results = 100 max_results = 200
for tag in event.tags(): for tag in event.tags():
if tag.as_vec()[0] == 'i': if tag.as_vec()[0] == 'i':
@@ -128,32 +111,45 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
options = self.set_options(request_form) options = self.set_options(request_form)
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
cli = ClientBuilder().database(database).signer(signer).opts(opts).build()
cli.connect()
# Negentropy reconciliation
# Query events from database
timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since
since = Timestamp.from_secs(timestamp_hour_ago) since = Timestamp.from_secs(timestamp_hour_ago)
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since) filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since)
events = self.client.database().query([filter1]) events = cli.database().query([filter1])
print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events") print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
ns.finallist = {} ns.finallist = {}
for event in events: for event in events:
if event.created_at().as_secs() > timestamp_hour_ago: if event.created_at().as_secs() > timestamp_hour_ago:
filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REPOST, filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REPOST,
definitions.EventDefinitions.KIND_REACTION, definitions.EventDefinitions.KIND_REACTION,
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since) definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = self.client.database().query([filt]) reactions = cli.database().query([filt])
if len(reactions) >= self.min_reactions: if len(reactions) >= self.min_reactions:
ns.finallist[event.id().to_hex()] = len(reactions) ns.finallist[event.id().to_hex()] = len(reactions)
if len(ns.finallist) == 0: if len(ns.finallist) == 0:
cli.disconnect()
cli.shutdown()
return self.result return self.result
result_list = [] result_list = []
finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[:int(options["max_results"])] finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[:int(options["max_results"])]
for entry in finallist_sorted: for entry in finallist_sorted:
# print(EventId.parse(entry[0]).to_bech32() + "/" + EventId.parse(entry[0]).to_hex() + ": " + str(entry[1]))
e_tag = Tag.parse(["e", entry[0]]) e_tag = Tag.parse(["e", entry[0]])
result_list.append(e_tag.as_vec()) result_list.append(e_tag.as_vec())
cli.disconnect()
cli.shutdown()
return json.dumps(result_list) return json.dumps(result_list)
def post_process(self, result, event): def post_process(self, result, event):
@@ -175,14 +171,22 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
if self.dvm_config.UPDATE_DATABASE: if self.dvm_config.UPDATE_DATABASE:
self.sync_db() self.sync_db()
self.last_schedule = Timestamp.now().as_secs() self.last_schedule = Timestamp.now().as_secs()
if not self.personalized: self.result = self.calculate_result(self.request_form)
try:
self.result = self.calculate_result(self.request_form)
except Exception as e:
print("EXCEPTION: " + str(e))
return 1 return 1
def sync_db(self): def sync_db(self):
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
cli = ClientBuilder().signer(signer).database(database).opts(opts).build()
ropts = RelayOptions().ping(True)
cli.add_relay_with_opts("wss://relay.damus.io", ropts)
cli.add_relay_with_opts("wss://nostr.oxtr.dev", ropts)
cli.add_relay_with_opts("wss://nostr21.com", ropts)
cli.connect()
timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since
lasthour = Timestamp.from_secs(timestamp_hour_ago) lasthour = Timestamp.from_secs(timestamp_hour_ago)
@@ -191,22 +195,21 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
definitions.EventDefinitions.KIND_ZAP]).since(lasthour) # Notes, reactions, zaps definitions.EventDefinitions.KIND_ZAP]).since(lasthour) # Notes, reactions, zaps
# filter = Filter().author(keys.public_key()) # filter = Filter().author(keys.public_key())
print("[" + self.dvm_config.NIP89.NAME + "] Syncing notes of the last " + str( print("[" + self.dvm_config.IDENTIFIER + "] Syncing notes of the last " + str(
self.db_since) + " seconds.. this might take a while..") self.db_since) + " seconds.. this might take a while..")
dbopts = NegentropyOptions().direction(NegentropyDirection.DOWN) dbopts = NegentropyOptions().direction(NegentropyDirection.DOWN)
self.client.reconcile(filter1, dbopts) cli.reconcile(filter1, dbopts)
filter_delete = Filter().until(Timestamp.from_secs(Timestamp.now().as_secs() - self.db_since)) database.delete(Filter().until(Timestamp.from_secs(
self.client.database().delete(filter_delete) # Clear old events so db doesn't get too full. Timestamp.now().as_secs() - self.db_since))) # Clear old events so db doesnt get too full.
print( print(
"[" + self.dvm_config.NIP89.NAME + "] Done Syncing Notes of the last " + str(self.db_since) + " seconds..") "[" + self.dvm_config.IDENTIFIER + "] Done Syncing Notes of the last " + str(self.db_since) + " seconds..")
# We build an example here that we can call by either calling this file directly from the main directory, # 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 # 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 # playground or elsewhere
def build_example(name, identifier, admin_config, options, cost=0, update_rate=180, processing_msg=None, def build_example(name, identifier, admin_config, options, cost=0, update_rate=180, processing_msg=None, update_db=True):
update_db=True):
dvm_config = build_default_config(identifier) dvm_config = build_default_config(identifier)
dvm_config.USE_OWN_VENV = False dvm_config.USE_OWN_VENV = False
dvm_config.SHOWLOG = True dvm_config.SHOWLOG = True
@@ -245,15 +248,14 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"]) nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
nip89config.CONTENT = json.dumps(nip89info) nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False #admin_config.UPDATE_PROFILE = False
# admin_config.REBROADCAST_NIP89 = False #admin_config.REBROADCAST_NIP89 = False
return DicoverContentCurrentlyPopular(name=name, dvm_config=dvm_config, nip89config=nip89config, return DicoverContentCurrentlyPopular(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options) admin_config=admin_config, options=options)
def build_example_subscription(name, identifier, admin_config, options, update_rate=180, processing_msg=None, def build_example_subscription(name, identifier, admin_config, options, update_rate=180, processing_msg=None, update_db=True):
update_db=True):
dvm_config = build_default_config(identifier) dvm_config = build_default_config(identifier)
dvm_config.USE_OWN_VENV = False dvm_config.USE_OWN_VENV = False
dvm_config.SHOWLOG = True dvm_config.SHOWLOG = True
@@ -303,9 +305,9 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
nip88config.PERK2DESC = "Support NostrDVM & NostrSDK development" nip88config.PERK2DESC = "Support NostrDVM & NostrSDK development"
nip88config.PAYMENT_VERIFIER_PUBKEY = "5b5c045ecdf66fb540bdf2049fe0ef7f1a566fa427a4fe50d400a011b65a3a7e" nip88config.PAYMENT_VERIFIER_PUBKEY = "5b5c045ecdf66fb540bdf2049fe0ef7f1a566fa427a4fe50d400a011b65a3a7e"
# admin_config.UPDATE_PROFILE = False #admin_config.UPDATE_PROFILE = False
# admin_config.REBROADCAST_NIP89 = False #admin_config.REBROADCAST_NIP89 = False
# admin_config.REBROADCAST_NIP88 = False #admin_config.REBROADCAST_NIP88 = False
# admin_config.FETCH_NIP88 = True # admin_config.FETCH_NIP88 = True
# admin_config.EVENTID = "" # admin_config.EVENTID = ""
@@ -317,4 +319,4 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
if __name__ == '__main__': if __name__ == '__main__':
process_venv(DicoverContentCurrentlyPopular) process_venv(DicoverContentCurrentlyPopular)

View File

@@ -60,19 +60,6 @@ class DicoverContentCurrentlyPopularZaps(DVMTaskInterface):
if self.logger: if self.logger:
init_logger(LogLevel.DEBUG) init_logger(LogLevel.DEBUG)
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_LONG_TIMEOUT)))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
self.client = ClientBuilder().signer(signer).database(database).opts(opts).build()
ropts = RelayOptions().ping(False)
self.client.add_relay_with_opts("wss://relay.damus.io", ropts)
self.client.add_relay_with_opts("wss://nostr.oxtr.dev", ropts)
self.client.add_relay_with_opts("wss://nostr21.com", ropts)
self.client.connect()
if self.dvm_config.UPDATE_DATABASE: if self.dvm_config.UPDATE_DATABASE:
self.sync_db() self.sync_db()
@@ -126,6 +113,15 @@ class DicoverContentCurrentlyPopularZaps(DVMTaskInterface):
options = self.set_options(request_form) options = self.set_options(request_form)
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
cli = ClientBuilder().database(database).signer(signer).opts(opts).build()
cli.connect()
# Negentropy reconciliation # Negentropy reconciliation
# Query events from database # Query events from database
@@ -133,14 +129,14 @@ class DicoverContentCurrentlyPopularZaps(DVMTaskInterface):
since = Timestamp.from_secs(timestamp_hour_ago) since = Timestamp.from_secs(timestamp_hour_ago)
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since) filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since)
events = self.client.database().query([filter1]) events = cli.database().query([filter1])
print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events") print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
ns.finallist = {} ns.finallist = {}
for event in events: for event in events:
if event.created_at().as_secs() > timestamp_hour_ago: if event.created_at().as_secs() > timestamp_hour_ago:
filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP]).event(event.id()).since(since) filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP]).event(event.id()).since(since)
reactions = self.client.database().query([filt]) reactions = cli.database().query([filt])
invoice_amount = 0 invoice_amount = 0
haspreimage = False haspreimage = False
if len(reactions) >= self.min_reactions: if len(reactions) >= self.min_reactions:
@@ -165,6 +161,9 @@ class DicoverContentCurrentlyPopularZaps(DVMTaskInterface):
e_tag = Tag.parse(["e", entry[0]]) e_tag = Tag.parse(["e", entry[0]])
result_list.append(e_tag.as_vec()) result_list.append(e_tag.as_vec())
cli.disconnect()
cli.shutdown()
return json.dumps(result_list) return json.dumps(result_list)
def post_process(self, result, event): def post_process(self, result, event):

View File

@@ -31,7 +31,6 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
db_since = 2 * 3600 db_since = 2 * 3600
db_name = "db/nostr_recent_notes2.db" db_name = "db/nostr_recent_notes2.db"
min_reactions = 2 min_reactions = 2
logger = False
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None, def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
admin_config: AdminConfig = None, options=None): admin_config: AdminConfig = None, options=None):
@@ -40,33 +39,15 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
admin_config=admin_config, options=options) admin_config=admin_config, options=options)
self.last_schedule = Timestamp.now().as_secs() self.last_schedule = Timestamp.now().as_secs()
if self.options is not None:
if self.options.get("db_name"):
self.db_name = self.options.get("db_name")
if self.options.get("db_since"):
self.db_since = int(self.options.get("db_since"))
if self.options.get("logger"):
self.logger = bool(self.options.get("logger"))
if self.logger: if self.options.get("db_name"):
init_logger(LogLevel.DEBUG) self.db_name = self.options.get("db_name")
if self.options.get("db_since"):
self.db_since = int(self.options.get("db_since"))
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT))) use_logger = False
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY) if use_logger:
keys = Keys.parse(sk.to_hex()) init_logger(LogLevel.DEBUG)
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
self.client = ClientBuilder().signer(signer).database(database).opts(opts).build()
ropts = RelayOptions().ping(False)
self.client.add_relay_with_opts("wss://relay.damus.io", ropts)
self.client.add_relay_with_opts("wss://nostr.oxtr.dev", ropts)
self.client.add_relay_with_opts("wss://nostr21.com", ropts)
#ropts = RelayOptions().ping(False)
#self.client.add_relay_with_opts("wss://nostr.band", ropts)
self.client.connect()
if self.dvm_config.UPDATE_DATABASE: if self.dvm_config.UPDATE_DATABASE:
self.sync_db() self.sync_db()
@@ -89,6 +70,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
user = event.author().to_hex() user = event.author().to_hex()
max_results = 100 max_results = 100
for tag in event.tags(): for tag in event.tags():
if tag.as_vec()[0] == 'i': if tag.as_vec()[0] == 'i':
input_type = tag.as_vec()[2] input_type = tag.as_vec()[2]
@@ -99,6 +81,8 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
elif param == "user": # check for param type elif param == "user": # check for param type
user = tag.as_vec()[2] user = tag.as_vec()[2]
options = { options = {
"max_results": max_results, "max_results": max_results,
"user": user, "user": user,
@@ -112,21 +96,34 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
ns = SimpleNamespace() ns = SimpleNamespace()
options = self.set_options(request_form) options = self.set_options(request_form)
relaylimits = RelayLimits.disable() relaylimits = RelayLimits.disable()
opts = ( opts = (Options().wait_for_send(True).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)).relay_limits(relaylimits))
Options().wait_for_send(True).send_timeout(timedelta(seconds=self.dvm_config.RELAY_LONG_TIMEOUT)).relay_limits( sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
relaylimits)) keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
cli = ClientBuilder().database(database).signer(signer).opts(opts).build()
cli.add_relay("wss://relay.damus.io")
cli.add_relay("wss://nostr.oxtr.dev")
cli.add_relay("wss://nostr.mom")
#ropts = RelayOptions().ping(False)
#cli.add_relay_with_opts("wss://nostr.band", ropts)
cli.connect()
user = PublicKey.parse(options["user"]) user = PublicKey.parse(options["user"])
followers_filter = Filter().author(user).kinds([Kind(3)]) followers_filter = Filter().author(user).kinds([Kind(3)])
followers = self.client.get_events_of([followers_filter], timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)) followers = cli.get_events_of([followers_filter], timedelta(seconds=self.dvm_config.RELAY_TIMEOUT))
#print(followers)
# Negentropy reconciliation # Negentropy reconciliation
# Query events from database # Query events from database
timestamp_since = Timestamp.now().as_secs() - self.db_since timestamp_since = Timestamp.now().as_secs() - self.db_since
since = Timestamp.from_secs(timestamp_since) since = Timestamp.from_secs(timestamp_since)
result_list = [] result_list = []
if len(followers) > 0: if len(followers) > 0:
@@ -137,32 +134,36 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
newest = entry.created_at().as_secs() newest = entry.created_at().as_secs()
best_entry = entry best_entry = entry
# print(best_entry.as_json()) #print(best_entry.as_json())
followings = [] followings = []
for tag in best_entry.tags(): for tag in best_entry.tags():
if tag.as_vec()[0] == "p": if tag.as_vec()[0] == "p":
following = PublicKey.parse(tag.as_vec()[1]) following = PublicKey.parse(tag.as_vec()[1])
followings.append(following) followings.append(following)
print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(followings)) + " Followers")
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).authors(followings).since(since) filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).authors(followings).since(since)
events = self.client.database().query([filter1]) events = cli.database().query([filter1])
print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events") print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
ns.finallist = {} ns.finallist = {}
for event in events: for event in events:
# if event.created_at().as_secs() > timestamp_since: #if event.created_at().as_secs() > timestamp_since:
filt = Filter().kinds( filt = Filter().kinds(
[EventDefinitions.KIND_ZAP, EventDefinitions.KIND_REACTION, EventDefinitions.KIND_REPOST, [definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION, definitions.EventDefinitions.KIND_REPOST,
EventDefinitions.KIND_NOTE]).event(event.id()).since(since) definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = self.client.database().query([filt]) reactions = cli.database().query([filt])
if len(reactions) >= self.min_reactions: if len(reactions) >= self.min_reactions:
ns.finallist[event.id().to_hex()] = len(reactions) ns.finallist[event.id().to_hex()] = len(reactions)
finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[
:int(options["max_results"])]
finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[:int(options["max_results"])]
for entry in finallist_sorted: for entry in finallist_sorted:
# print(EventId.parse(entry[0]).to_bech32() + "/" + EventId.parse(entry[0]).to_hex() + ": " + str(entry[1]))
e_tag = Tag.parse(["e", entry[0]]) e_tag = Tag.parse(["e", entry[0]])
result_list.append(e_tag.as_vec()) result_list.append(e_tag.as_vec())
cli.connect()
cli.shutdown()
return json.dumps(result_list) return json.dumps(result_list)
@@ -187,34 +188,39 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
if self.dvm_config.UPDATE_DATABASE: if self.dvm_config.UPDATE_DATABASE:
self.sync_db() self.sync_db()
self.last_schedule = Timestamp.now().as_secs() self.last_schedule = Timestamp.now().as_secs()
return 1 return 1
def sync_db(self): def sync_db(self):
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
cli = ClientBuilder().signer(signer).database(database).opts(opts).build()
cli.add_relay("wss://relay.damus.io")
cli.connect()
timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since
lasthour = Timestamp.from_secs(timestamp_hour_ago) lasthour = Timestamp.from_secs(timestamp_hour_ago)
filter1 = Filter().kinds([definitions.EventDefinitions.KIND_NOTE, definitions.EventDefinitions.KIND_REACTION, filter1 = Filter().kinds([definitions.EventDefinitions.KIND_NOTE, definitions.EventDefinitions.KIND_REACTION,
definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REPOST]).since(lasthour) # Notes, reactions, zaps definitions.EventDefinitions.KIND_ZAP]).since(lasthour) # Notes, reactions, zaps
# filter = Filter().author(keys.public_key()) # filter = Filter().author(keys.public_key())
print("[" + self.dvm_config.NIP89.NAME + "] Syncing notes of the last " + str( print("[" + self.dvm_config.IDENTIFIER + "] Syncing notes of the last " + str(self.db_since) + " seconds.. this might take a while..")
self.db_since) + " seconds.. this might take a while..")
dbopts = NegentropyOptions().direction(NegentropyDirection.DOWN) dbopts = NegentropyOptions().direction(NegentropyDirection.DOWN)
self.client.reconcile(filter1, dbopts) cli.reconcile(filter1, dbopts)
filter_delete = Filter().until(Timestamp.from_secs(Timestamp.now().as_secs() - self.db_since)) database.delete(Filter().until(Timestamp.from_secs(
self.client.database().delete(filter_delete) # Clear old events so db doesn't get too full. Timestamp.now().as_secs() - self.db_since))) # Clear old events so db doesnt get too full.
print(
"[" + self.dvm_config.NIP89.NAME + "] Done Syncing Notes of the last " + str(self.db_since) + " seconds..") print("[" + self.dvm_config.IDENTIFIER + "] Done Syncing Notes of the last " + str(self.db_since) + " seconds..")
# We build an example here that we can call by either calling this file directly from the main directory, # 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 # 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 # playground or elsewhere
def build_example(name, identifier, admin_config, options, cost=0, update_rate=300, processing_msg=None, def build_example(name, identifier, admin_config, options, cost=0, update_rate=300, processing_msg=None, update_db=True):
update_db=True):
dvm_config = build_default_config(identifier) dvm_config = build_default_config(identifier)
dvm_config.USE_OWN_VENV = False dvm_config.USE_OWN_VENV = False
dvm_config.SHOWLOG = True dvm_config.SHOWLOG = True
@@ -255,8 +261,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=3
# admin_config.UPDATE_PROFILE = False # admin_config.UPDATE_PROFILE = False
# admin_config.REBROADCAST_NIP89 = False # admin_config.REBROADCAST_NIP89 = False
return DicoverContentCurrentlyPopularFollowers(name=name, dvm_config=dvm_config, nip89config=nip89config, return DicoverContentCurrentlyPopularFollowers(name=name, dvm_config=dvm_config, nip89config=nip89config, options=options,
options=options,
admin_config=admin_config) admin_config=admin_config)
@@ -319,4 +324,4 @@ def build_example_subscription(name, identifier, admin_config, options, processi
if __name__ == '__main__': if __name__ == '__main__':
process_venv(DicoverContentCurrentlyPopularFollowers) process_venv(DicoverContentCurrentlyPopularFollowers)

View File

@@ -2,8 +2,7 @@ import json
import os import os
from datetime import timedelta from datetime import timedelta
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, NostrDatabase, \ from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, NostrDatabase, \
ClientBuilder, Filter, NegentropyOptions, NegentropyDirection, init_logger, LogLevel, Event, EventId, Kind, \ ClientBuilder, Filter, NegentropyOptions, NegentropyDirection, init_logger, LogLevel, Event, EventId, Kind
RelayLimits, RelayOptions
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils import definitions from nostr_dvm.utils import definitions
@@ -15,7 +14,7 @@ from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag, create
from nostr_dvm.utils.output_utils import post_process_list_to_events from nostr_dvm.utils.output_utils import post_process_list_to_events
""" """
This File contains a Module to discover popular notes by topic This File contains a Module to discover popular notes by topics
Accepted Inputs: none Accepted Inputs: none
Outputs: A list of events Outputs: A list of events
Params: None Params: None
@@ -29,18 +28,18 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
dvm_config: DVMConfig dvm_config: DVMConfig
last_schedule: int last_schedule: int
min_reactions = 2 min_reactions = 2
db_since = 10 * 3600 db_since = 10*3600
db_name = "db/nostr_default_recent_notes.db" db_name = "db/nostr_default_recent_notes.db"
search_list = [] search_list = []
avoid_list = [] avoid_list = []
must_list = [] must_list = []
personalized = False personalized = False
result = "" result = ""
logger = False
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None, def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
admin_config: AdminConfig = None, options=None): admin_config: AdminConfig = None, options=None):
super().__init__(name=name, dvm_config=dvm_config, nip89config=nip89config, nip88config=nip88config, super().__init__(name=name, dvm_config=dvm_config, nip89config=nip89config, nip88config=nip88config,
admin_config=admin_config, options=options) admin_config=admin_config, options=options)
@@ -53,45 +52,26 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
self.request_form['options'] = json.dumps(opts) self.request_form['options'] = json.dumps(opts)
dvm_config.SCRIPT = os.path.abspath(__file__) dvm_config.SCRIPT = os.path.abspath(__file__)
if self.options is not None:
if self.options.get("personalized"):
self.personalized = bool(self.options.get("personalized"))
self.last_schedule = Timestamp.now().as_secs()
if self.options.get("search_list"):
self.search_list = self.options.get("search_list")
# print(self.search_list)
if self.options.get("avoid_list"):
self.avoid_list = self.options.get("avoid_list")
if self.options.get("must_list"):
self.must_list = self.options.get("must_list")
if self.options.get("db_name"):
self.db_name = self.options.get("db_name")
if self.options.get("db_since"):
self.db_since = int(self.options.get("db_since"))
if self.options.get("logger"):
self.logger = bool(self.options.get("logger"))
if self.logger: if self.options.get("personalized"):
init_logger(LogLevel.DEBUG) self.personalized = bool(self.options.get("personalized"))
self.last_schedule = Timestamp.now().as_secs()
if self.options.get("search_list"):
self.search_list = self.options.get("search_list")
#print(self.search_list)
if self.options.get("avoid_list"):
self.avoid_list = self.options.get("avoid_list")
if self.options.get("must_list"):
self.must_list = self.options.get("must_list")
if self.options.get("db_name"):
self.db_name = self.options.get("db_name")
if self.options.get("db_since"):
self.db_since = int(self.options.get("db_since"))
relaylimits = RelayLimits.disable()
opts = (Options().wait_for_send(True).send_timeout(timedelta(seconds=dvm_config.RELAY_LONG_TIMEOUT))
.relay_limits(relaylimits))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
self.client = ClientBuilder().signer(signer).database(database).opts(opts).build()
#self.client.add_relay("wss://relay.damus.io") use_logger = False
#self.client.add_relay("wss://nostr.oxtr.dev") if use_logger:
init_logger(LogLevel.DEBUG)
ropts = RelayOptions().ping(False)
self.client.add_relay_with_opts("wss://relay.damus.io", ropts)
self.client.add_relay_with_opts("wss://nostr.oxtr.dev", ropts)
self.client.add_relay_with_opts("wss://nostr21.com", ropts)
self.client.connect()
if self.dvm_config.UPDATE_DATABASE: if self.dvm_config.UPDATE_DATABASE:
self.sync_db() self.sync_db()
@@ -109,6 +89,7 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
def create_request_from_nostr_event(self, event, client=None, dvm_config=None): def create_request_from_nostr_event(self, event, client=None, dvm_config=None):
self.dvm_config = dvm_config self.dvm_config = dvm_config
request_form = {"jobID": event.id().to_hex()} request_form = {"jobID": event.id().to_hex()}
# default values # default values
@@ -133,10 +114,11 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
# if the dvm supports individual results, recalculate it every time for the request # if the dvm supports individual results, recalculate it every time for the request
if self.personalized: if self.personalized:
return self.calculate_result(request_form) return self.calculate_result(request_form)
# else return the result that gets updated once every schenduled update. In this case on database update. #else return the result that gets updated once every schenduled update. In this case on database update.
else: else:
return self.result return self.result
def post_process(self, result, event): def post_process(self, result, event):
"""Overwrite the interface function to return a social client readable format, if requested""" """Overwrite the interface function to return a social client readable format, if requested"""
for tag in event.tags(): for tag in event.tags():
@@ -147,7 +129,6 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
# if not text/plain, don't post-process # if not text/plain, don't post-process
return result return result
def calculate_result(self, request_form): def calculate_result(self, request_form):
from nostr_sdk import Filter from nostr_sdk import Filter
from types import SimpleNamespace from types import SimpleNamespace
@@ -155,16 +136,26 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
options = self.set_options(request_form) options = self.set_options(request_form)
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
cli = ClientBuilder().database(database).signer(signer).opts(opts).build()
cli.connect()
# Negentropy reconciliation
# Query events from database
timestamp_since = Timestamp.now().as_secs() - self.db_since timestamp_since = Timestamp.now().as_secs() - self.db_since
since = Timestamp.from_secs(timestamp_since) since = Timestamp.from_secs(timestamp_since)
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since) filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since)
events = self.client.database().query([filter1]) events = cli.database().query([filter1])
print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events") print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
ns.finallist = {}
ns.final_list = {}
for event in events: for event in events:
if all(ele in event.content().lower() for ele in self.must_list): if all(ele in event.content().lower() for ele in self.must_list):
@@ -175,61 +166,75 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
[definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION, [definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION,
definitions.EventDefinitions.KIND_REPOST, definitions.EventDefinitions.KIND_REPOST,
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since) definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = self.client.database().query([filt]) reactions = cli.database().query([filt])
if len(reactions) >= self.min_reactions: if len(reactions) >= self.min_reactions:
ns.final_list[event.id().to_hex()] = len(reactions) ns.finallist[event.id().to_hex()] = len(reactions)
result_list = [] result_list = []
finallist_sorted = sorted(ns.final_list.items(), key=lambda x: x[1], reverse=True)[:int(options["max_results"])] finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[:int(options["max_results"])]
for entry in finallist_sorted: for entry in finallist_sorted:
# print(EventId.parse(entry[0]).to_bech32() + "/" + EventId.parse(entry[0]).to_hex() + ": " + str(entry[1])) # print(EventId.parse(entry[0]).to_bech32() + "/" + EventId.parse(entry[0]).to_hex() + ": " + str(entry[1]))
e_tag = Tag.parse(["e", entry[0]]) e_tag = Tag.parse(["e", entry[0]])
result_list.append(e_tag.as_vec()) result_list.append(e_tag.as_vec())
print(len(result_list))
cli.disconnect()
cli.shutdown()
return json.dumps(result_list) return json.dumps(result_list)
def schedule(self, dvm_config): def schedule(self, dvm_config):
if dvm_config.SCHEDULE_UPDATES_SECONDS == 0: if dvm_config.SCHEDULE_UPDATES_SECONDS == 0:
return 0 return 0
else: else:
if Timestamp.now().as_secs() >= self.last_schedule + dvm_config.SCHEDULE_UPDATES_SECONDS: if Timestamp.now().as_secs() >= self.last_schedule + dvm_config.SCHEDULE_UPDATES_SECONDS:
try: if self.dvm_config.UPDATE_DATABASE:
if self.dvm_config.UPDATE_DATABASE: self.sync_db()
self.sync_db() self.last_schedule = Timestamp.now().as_secs()
self.last_schedule = Timestamp.now().as_secs() self.result = self.calculate_result(self.request_form)
if not self.personalized: #print(self.result)
self.result = self.calculate_result(self.request_form)
except Exception as e:
print(e)
return 1 return 1
def sync_db(self): def sync_db(self):
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys)
database = NostrDatabase.sqlite(self.db_name)
cli = ClientBuilder().signer(signer).database(database).opts(opts).build()
cli.add_relay("wss://relay.damus.io")
cli.add_relay("wss://nostr.oxtr.dev")
cli.add_relay("wss://relay.nostr.net")
cli.add_relay("wss://relay.nostr.bg")
cli.add_relay("wss://nostr.wine")
cli.add_relay("wss://nostr21.com")
#RELAY_LIST = [ "wss://nostr.wine",
# , "wss://relay.nostr.bg",
# , "wss://relay.nostr.net"
# ]
cli.connect()
timestamp_since = Timestamp.now().as_secs() - self.db_since timestamp_since = Timestamp.now().as_secs() - self.db_since
since = Timestamp.from_secs(timestamp_since) since = Timestamp.from_secs(timestamp_since)
filter1 = Filter().kinds([EventDefinitions.KIND_NOTE, EventDefinitions.KIND_REACTION, EventDefinitions.KIND_ZAP, filter1 = Filter().kinds([definitions.EventDefinitions.KIND_NOTE, definitions.EventDefinitions.KIND_REACTION, definitions.EventDefinitions.KIND_ZAP]).since(since) # Notes, reactions, zaps
definitions.EventDefinitions.KIND_REPOST
]).since(since) # Notes, reactions, zaps
# filter = Filter().author(keys.public_key()) # filter = Filter().author(keys.public_key())
print("[" + self.dvm_config.NIP89.NAME + "] Syncing notes of the last " + str( print("[" + self.dvm_config.IDENTIFIER + "] Syncing notes of the last " + str(self.db_since) + " seconds.. this might take a while..")
self.db_since) + " seconds.. this might take a while..")
dbopts = NegentropyOptions().direction(NegentropyDirection.DOWN) dbopts = NegentropyOptions().direction(NegentropyDirection.DOWN)
self.client.reconcile(filter1, dbopts) cli.reconcile(filter1, dbopts)
filter_delete = Filter().until(Timestamp.from_secs(Timestamp.now().as_secs() - self.db_since)) database.delete(Filter().until(Timestamp.from_secs(
self.client.database().delete(filter_delete) # Clear old events so db doesn't get too full. Timestamp.now().as_secs() - self.db_since))) # Clear old events so db doesn't get too full.
print( print("[" + self.dvm_config.IDENTIFIER + "] Done Syncing Notes of the last " + str(self.db_since) + " seconds..")
"[" + self.dvm_config.NIP89.NAME + "] Done Syncing Notes of the last " + str(self.db_since) + " seconds..")
# We build an example here that we can call by either calling this file directly from the main directory, # 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 # 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 # playground or elsewhere
def build_example(name, identifier, admin_config, options, image, description, update_rate=600, cost=0, def build_example(name, identifier, admin_config, options, image, description, update_rate=600, cost=0, processing_msg=None, update_db=True):
processing_msg=None, update_db=True):
dvm_config = build_default_config(identifier) dvm_config = build_default_config(identifier)
dvm_config.USE_OWN_VENV = False dvm_config.USE_OWN_VENV = False
dvm_config.SHOWLOG = True dvm_config.SHOWLOG = True
@@ -242,6 +247,7 @@ def build_example(name, identifier, admin_config, options, image, description, u
dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg
admin_config.LUD16 = dvm_config.LN_ADDRESS admin_config.LUD16 = dvm_config.LN_ADDRESS
# Add NIP89 # Add NIP89
nip89info = { nip89info = {
"name": name, "name": name,
@@ -267,11 +273,10 @@ def build_example(name, identifier, admin_config, options, image, description, u
nip89config.CONTENT = json.dumps(nip89info) nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularbyTopic(name=name, dvm_config=dvm_config, nip89config=nip89config, return DicoverContentCurrentlyPopularbyTopic(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options) admin_config=admin_config, options=options)
def build_example_subscription(name, identifier, admin_config, options, image, description, processing_msg=None, def build_example_subscription(name, identifier, admin_config, options, image, description, processing_msg=None, update_db=True):
update_db=True):
dvm_config = build_default_config(identifier) dvm_config = build_default_config(identifier)
dvm_config.USE_OWN_VENV = False dvm_config.USE_OWN_VENV = False
dvm_config.SHOWLOG = True dvm_config.SHOWLOG = True
@@ -282,6 +287,7 @@ def build_example_subscription(name, identifier, admin_config, options, image, d
dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg
admin_config.LUD16 = dvm_config.LN_ADDRESS admin_config.LUD16 = dvm_config.LN_ADDRESS
# Add NIP89 # Add NIP89
nip89info = { nip89info = {
"name": name, "name": name,
@@ -319,11 +325,17 @@ def build_example_subscription(name, identifier, admin_config, options, image, d
nip88config.PERK2DESC = "Support NostrDVM & NostrSDK development" nip88config.PERK2DESC = "Support NostrDVM & NostrSDK development"
nip88config.PAYMENT_VERIFIER_PUBKEY = "5b5c045ecdf66fb540bdf2049fe0ef7f1a566fa427a4fe50d400a011b65a3a7e" nip88config.PAYMENT_VERIFIER_PUBKEY = "5b5c045ecdf66fb540bdf2049fe0ef7f1a566fa427a4fe50d400a011b65a3a7e"
# admin_config.FETCH_NIP88 = True
# admin_config.EVENTID = "63a791cdc7bf78c14031616963105fce5793f532bb231687665b14fb6d805fdb"
# admin_config.PRIVKEY = dvm_config.PRIVATE_KEY
return DicoverContentCurrentlyPopularbyTopic(name=name, dvm_config=dvm_config, nip89config=nip89config, return DicoverContentCurrentlyPopularbyTopic(name=name, dvm_config=dvm_config, nip89config=nip89config,
nip88config=nip88config, nip88config=nip88config,
admin_config=admin_config, admin_config=admin_config,
options=options) options=options)
if __name__ == '__main__': if __name__ == '__main__':
process_venv(DicoverContentCurrentlyPopularbyTopic) process_venv(DicoverContentCurrentlyPopularbyTopic)

View File

@@ -1,6 +1,6 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
VERSION = '0.5.5' VERSION = '0.5.6'
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines' 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') LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information')

View File

@@ -19,7 +19,7 @@ from nostr_dvm.utils.nostr_utils import check_and_set_private_key
from nostr_dvm.utils.zap_utils import check_and_set_ln_bits_keys from nostr_dvm.utils.zap_utils import check_and_set_ln_bits_keys
rebbroadcast_NIP89 = False # Announce NIP89 on startup rebbroadcast_NIP89 = False # Announce NIP89 on startup
global_update_rate = 300 # set this high on first sync so db can fully sync before another process trys to. global_update_rate = 120 # set this high on first sync so db can fully sync before another process trys to.
use_logger = True use_logger = True
#git_hash = NostrLibrary().git_hash_version() #git_hash = NostrLibrary().git_hash_version()
@@ -46,6 +46,7 @@ def build_example_nostrband(name, identifier, admin_config, image, about, custom
"amount": "Free", "amount": "Free",
"encryptionSupported": True, "encryptionSupported": True,
"cashuAccepted": True, "cashuAccepted": True,
"relays": dvm_config.RELAY_LIST,
"nip90Params": {} "nip90Params": {}
} }
nip89config = NIP89Config() nip89config = NIP89Config()
@@ -81,6 +82,7 @@ def build_example_topic(name, identifier, admin_config, options, image, descript
"encryptionSupported": True, "encryptionSupported": True,
"cashuAccepted": True, "cashuAccepted": True,
"personalized": False, "personalized": False,
"relays": dvm_config.RELAY_LIST,
"amount": create_amount_tag(cost), "amount": create_amount_tag(cost),
"nip90Params": { "nip90Params": {
"max_results": { "max_results": {
@@ -126,6 +128,7 @@ def build_example_popular(name, identifier, admin_config, options, image, cost=0
"encryptionSupported": True, "encryptionSupported": True,
"cashuAccepted": True, "cashuAccepted": True,
"personalized": False, "personalized": False,
"relays": dvm_config.RELAY_LIST,
"amount": create_amount_tag(cost), "amount": create_amount_tag(cost),
"nip90Params": { "nip90Params": {
"max_results": { "max_results": {
@@ -168,6 +171,7 @@ def build_example_popular_followers(name, identifier, admin_config, options, ima
"encryptionSupported": True, "encryptionSupported": True,
"cashuAccepted": True, "cashuAccepted": True,
"personalized": True, "personalized": True,
"relays": dvm_config.RELAY_LIST,
"amount": create_amount_tag(cost), "amount": create_amount_tag(cost),
"nip90Params": { "nip90Params": {
"max_results": { "max_results": {
@@ -213,6 +217,7 @@ def build_example_top_zapped(name, identifier, admin_config, options, image, cos
"encryptionSupported": True, "encryptionSupported": True,
"cashuAccepted": True, "cashuAccepted": True,
"personalized": False, "personalized": False,
"relays": dvm_config.RELAY_LIST,
"amount": create_amount_tag(cost), "amount": create_amount_tag(cost),
"nip90Params": { "nip90Params": {
"max_results": { "max_results": {
@@ -373,7 +378,7 @@ def playground():
options_top_zapped = { options_top_zapped = {
"db_name": "db/nostr_recent_notes.db", "db_name": "db/nostr_recent_notes.db",
"db_since": 60 * 60 * 4, # 4h since gmt, "db_since": 60 * 60 * 6, # 6h since gmt,
} }
cost = 0 cost = 0
image = "https://image.nostr.build/c6879f458252641d04d0aa65fd7f1e005a4f7362fd407467306edc2f4acdb113.jpg" image = "https://image.nostr.build/c6879f458252641d04d0aa65fd7f1e005a4f7362fd407467306edc2f4acdb113.jpg"