mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-18 22:56:30 +01:00
use a shared db for content dvms
This commit is contained in:
@@ -47,11 +47,19 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
||||
|
||||
self.last_schedule = Timestamp.now().as_secs()
|
||||
|
||||
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"))
|
||||
|
||||
|
||||
use_logger = False
|
||||
if use_logger:
|
||||
init_logger(LogLevel.DEBUG)
|
||||
|
||||
if self.dvm_config.UPDATE_DATABASE:
|
||||
self.sync_db()
|
||||
|
||||
if not self.personalized:
|
||||
self.result = self.calculate_result(self.request_form)
|
||||
|
||||
@@ -117,16 +125,16 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
||||
# Negentropy reconciliation
|
||||
# Query events from database
|
||||
timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since
|
||||
lasthour = Timestamp.from_secs(timestamp_hour_ago)
|
||||
since = Timestamp.from_secs(timestamp_hour_ago)
|
||||
|
||||
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(lasthour)
|
||||
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since)
|
||||
events = cli.database().query([filter1])
|
||||
ns.finallist = {}
|
||||
for event in events:
|
||||
if event.created_at().as_secs() > timestamp_hour_ago:
|
||||
filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REPOST,
|
||||
definitions.EventDefinitions.KIND_REACTION,
|
||||
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(lasthour)
|
||||
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
|
||||
reactions = cli.database().query([filt])
|
||||
if len(reactions) >= self.min_reactions:
|
||||
ns.finallist[event.id().to_hex()] = len(reactions)
|
||||
@@ -156,6 +164,7 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
||||
return 0
|
||||
else:
|
||||
if Timestamp.now().as_secs() >= self.last_schedule + dvm_config.SCHEDULE_UPDATES_SECONDS:
|
||||
if self.dvm_config.UPDATE_DATABASE:
|
||||
self.sync_db()
|
||||
self.last_schedule = Timestamp.now().as_secs()
|
||||
self.result = self.calculate_result(self.request_form)
|
||||
@@ -193,11 +202,12 @@ 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, processing_msg=None):
|
||||
def build_example(name, identifier, admin_config, options, processing_msg=None, update_db=True):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
dvm_config.SHOWLOG = True
|
||||
dvm_config.SCHEDULE_UPDATES_SECONDS = 600 # Every 10 minutes
|
||||
dvm_config.UPDATE_DATABASE = update_db
|
||||
# Activate these to use a subscription based model instead
|
||||
# dvm_config.SUBSCRIPTION_REQUIRED = True
|
||||
# dvm_config.SUBSCRIPTION_DAILY_COST = 1
|
||||
@@ -234,14 +244,15 @@ def build_example(name, identifier, admin_config, processing_msg=None):
|
||||
#admin_config.REBROADCAST_NIP89 = False
|
||||
|
||||
return DicoverContentCurrentlyPopular(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||
admin_config=admin_config)
|
||||
admin_config=admin_config, options=options)
|
||||
|
||||
|
||||
def build_example_subscription(name, identifier, admin_config, processing_msg=None):
|
||||
def build_example_subscription(name, identifier, admin_config, options, processing_msg=None, update_db=True):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
dvm_config.SHOWLOG = True
|
||||
dvm_config.SCHEDULE_UPDATES_SECONDS = 600 # Every 10 minutes
|
||||
dvm_config.SCHEDULE_UPDATES_SECONDS = 180 # Every 3 minutes
|
||||
dvm_config.UPDATE_DATABASE = update_db
|
||||
# Activate these to use a subscription based model instead
|
||||
# dvm_config.SUBSCRIPTION_DAILY_COST = 1
|
||||
dvm_config.FIX_COST = 0
|
||||
@@ -295,7 +306,7 @@ def build_example_subscription(name, identifier, admin_config, processing_msg=No
|
||||
# admin_config.PRIVKEY = dvm_config.PRIVATE_KEY
|
||||
|
||||
return DicoverContentCurrentlyPopular(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||
nip88config=nip88config,
|
||||
nip88config=nip88config, options=options,
|
||||
admin_config=admin_config)
|
||||
|
||||
|
||||
|
||||
@@ -40,10 +40,16 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
|
||||
|
||||
self.last_schedule = Timestamp.now().as_secs()
|
||||
|
||||
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"))
|
||||
|
||||
use_logger = False
|
||||
if use_logger:
|
||||
init_logger(LogLevel.DEBUG)
|
||||
|
||||
if self.dvm_config.UPDATE_DATABASE:
|
||||
self.sync_db()
|
||||
|
||||
def is_input_supported(self, tags, client=None, dvm_config=None):
|
||||
@@ -101,7 +107,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
|
||||
cli = ClientBuilder().database(database).signer(signer).opts(opts).build()
|
||||
cli.add_relay("wss://relay.damus.io")
|
||||
cli.add_relay("wss://nos.lol")
|
||||
cli.add_relay("wss://pablof7z.nostr1.com")
|
||||
cli.add_relay("wss://nostr.mom")
|
||||
|
||||
ropts = RelayOptions().ping(False)
|
||||
cli.add_relay_with_opts("wss://nostr.band", ropts)
|
||||
@@ -115,8 +121,8 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
|
||||
|
||||
# Negentropy reconciliation
|
||||
# Query events from database
|
||||
timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since
|
||||
lasthour = Timestamp.from_secs(timestamp_hour_ago)
|
||||
timestamp_since = Timestamp.now().as_secs() - self.db_since
|
||||
since = Timestamp.from_secs(timestamp_since)
|
||||
|
||||
|
||||
result_list = []
|
||||
@@ -136,15 +142,15 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
|
||||
following = PublicKey.parse(tag.as_vec()[1])
|
||||
followings.append(following)
|
||||
|
||||
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).authors(followings).since(lasthour)
|
||||
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).authors(followings).since(since)
|
||||
events = cli.database().query([filter1])
|
||||
|
||||
ns.finallist = {}
|
||||
for event in events:
|
||||
if event.created_at().as_secs() > timestamp_hour_ago:
|
||||
#if event.created_at().as_secs() > timestamp_since:
|
||||
filt = Filter().kinds(
|
||||
[definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION, definitions.EventDefinitions.KIND_REPOST,
|
||||
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(lasthour)
|
||||
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
|
||||
reactions = cli.database().query([filt])
|
||||
if len(reactions) >= self.min_reactions:
|
||||
ns.finallist[event.id().to_hex()] = len(reactions)
|
||||
@@ -177,6 +183,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
|
||||
|
||||
else:
|
||||
if Timestamp.now().as_secs() >= self.last_schedule + dvm_config.SCHEDULE_UPDATES_SECONDS:
|
||||
if self.dvm_config.UPDATE_DATABASE:
|
||||
self.sync_db()
|
||||
self.last_schedule = Timestamp.now().as_secs()
|
||||
return 1
|
||||
@@ -211,11 +218,12 @@ 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, processing_msg=None):
|
||||
def build_example(name, identifier, admin_config, options, processing_msg=None, update_db=True):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
dvm_config.SHOWLOG = True
|
||||
dvm_config.SCHEDULE_UPDATES_SECONDS = 600 # Every 10 minutes
|
||||
dvm_config.UPDATE_DATABASE = update_db
|
||||
# Activate these to use a subscription based model instead
|
||||
# dvm_config.SUBSCRIPTION_REQUIRED = True
|
||||
# dvm_config.SUBSCRIPTION_DAILY_COST = 1
|
||||
@@ -250,15 +258,16 @@ def build_example(name, identifier, admin_config, processing_msg=None):
|
||||
# admin_config.UPDATE_PROFILE = 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,
|
||||
admin_config=admin_config)
|
||||
|
||||
|
||||
def build_example_subscription(name, identifier, admin_config, processing_msg=None):
|
||||
def build_example_subscription(name, identifier, admin_config, options, processing_msg=None, update_db=True):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
dvm_config.SHOWLOG = True
|
||||
dvm_config.SCHEDULE_UPDATES_SECONDS = 600 # Every 10 minutes
|
||||
dvm_config.SCHEDULE_UPDATES_SECONDS = 180 # Every 3 minutes
|
||||
dvm_config.UPDATE_DATABASE = update_db
|
||||
# Activate these to use a subscription based model instead
|
||||
# dvm_config.SUBSCRIPTION_DAILY_COST = 1
|
||||
dvm_config.FIX_COST = 0
|
||||
@@ -305,7 +314,7 @@ def build_example_subscription(name, identifier, admin_config, processing_msg=No
|
||||
# admin_config.PRIVKEY = dvm_config.PRIVATE_KEY
|
||||
|
||||
return DicoverContentCurrentlyPopularFollowers(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||
nip88config=nip88config,
|
||||
nip88config=nip88config, options=options,
|
||||
admin_config=admin_config)
|
||||
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
|
||||
if use_logger:
|
||||
init_logger(LogLevel.DEBUG)
|
||||
|
||||
if self.dvm_config.UPDATE_DATABASE:
|
||||
self.sync_db()
|
||||
if not self.personalized:
|
||||
self.result = self.calculate_result(self.request_form)
|
||||
@@ -149,8 +150,10 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
|
||||
|
||||
# Negentropy reconciliation
|
||||
# Query events from database
|
||||
timestamp_since = Timestamp.now().as_secs() - self.db_since
|
||||
since = Timestamp.from_secs(timestamp_since)
|
||||
|
||||
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE)
|
||||
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since)
|
||||
|
||||
events = cli.database().query([filter1])
|
||||
print(len(events))
|
||||
@@ -160,10 +163,11 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
|
||||
if all(ele in event.content().lower() for ele in self.must_list):
|
||||
if any(ele in event.content().lower() for ele in self.search_list):
|
||||
if not any(ele in event.content().lower() for ele in self.avoid_list):
|
||||
|
||||
filt = Filter().kinds(
|
||||
[definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION,
|
||||
definitions.EventDefinitions.KIND_REPOST,
|
||||
definitions.EventDefinitions.KIND_NOTE]).event(event.id())
|
||||
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
|
||||
reactions = cli.database().query([filt])
|
||||
if len(reactions) >= self.min_reactions:
|
||||
ns.finallist[event.id().to_hex()] = len(reactions)
|
||||
@@ -183,6 +187,7 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
|
||||
return 0
|
||||
else:
|
||||
if Timestamp.now().as_secs() >= self.last_schedule + dvm_config.SCHEDULE_UPDATES_SECONDS:
|
||||
if self.dvm_config.UPDATE_DATABASE:
|
||||
self.sync_db()
|
||||
self.last_schedule = Timestamp.now().as_secs()
|
||||
self.result = self.calculate_result(self.request_form)
|
||||
@@ -198,12 +203,22 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
|
||||
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_hour_ago = Timestamp.now().as_secs() - self.db_since
|
||||
lasthour = Timestamp.from_secs(timestamp_hour_ago)
|
||||
timestamp_since = Timestamp.now().as_secs() - self.db_since
|
||||
since = Timestamp.from_secs(timestamp_since)
|
||||
|
||||
filter1 = Filter().kinds([definitions.EventDefinitions.KIND_NOTE, definitions.EventDefinitions.KIND_REACTION, definitions.EventDefinitions.KIND_ZAP]).since(lasthour) # Notes, reactions, zaps
|
||||
filter1 = Filter().kinds([definitions.EventDefinitions.KIND_NOTE, definitions.EventDefinitions.KIND_REACTION, definitions.EventDefinitions.KIND_ZAP]).since(since) # Notes, reactions, zaps
|
||||
|
||||
# filter = Filter().author(keys.public_key())
|
||||
print("[" + self.dvm_config.IDENTIFIER + "] Syncing notes of the last " + str(self.db_since) + " seconds.. this might take a while..")
|
||||
@@ -218,11 +233,12 @@ 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):
|
||||
def build_example(name, identifier, admin_config, options, image, description, processing_msg=None, update_db=True):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
dvm_config.SHOWLOG = True
|
||||
dvm_config.SCHEDULE_UPDATES_SECONDS = 600 # Every 10 minutes
|
||||
dvm_config.UPDATE_DATABASE = update_db
|
||||
# Activate these to use a subscription based model instead
|
||||
# dvm_config.SUBSCRIPTION_REQUIRED = True
|
||||
# dvm_config.SUBSCRIPTION_DAILY_COST = 1
|
||||
@@ -258,11 +274,12 @@ def build_example(name, identifier, admin_config, options, image, description, p
|
||||
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):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
dvm_config.SHOWLOG = True
|
||||
dvm_config.SCHEDULE_UPDATES_SECONDS = 600 # Every 10 minutes
|
||||
dvm_config.UPDATE_DATABASE = update_db
|
||||
# Activate these to use a subscription based model instead
|
||||
dvm_config.FIX_COST = 0
|
||||
dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg
|
||||
|
||||
@@ -18,7 +18,7 @@ class DVMConfig:
|
||||
|
||||
RELAY_LIST = ["wss://relay.damus.io", "wss://nos.lol", "wss://nostr.wine",
|
||||
"wss://nostr.mom", "wss://nostr.oxtr.dev", "wss://relay.nostr.bg",
|
||||
"wss://relay.f7z.io", "wss://pablof7z.nostr1.com", "wss://relay.nostr.net", "wss://140.f7z.io",
|
||||
"wss://relay.f7z.io", "wss://relay.nostr.net"
|
||||
]
|
||||
|
||||
RELAY_TIMEOUT = 5
|
||||
@@ -38,6 +38,7 @@ class DVMConfig:
|
||||
SEND_FEEDBACK_EVENTS = True
|
||||
SHOW_RESULT_BEFORE_PAYMENT: bool = False # if this is true show results even when not paid right after autoprocess
|
||||
SCHEDULE_UPDATES_SECONDS = 0
|
||||
UPDATE_DATABASE = True # DVMs that use a db manage their db by default. If a dvm should use the same db as another DVM, deactive it for those who do.
|
||||
CUSTOM_PROCESSING_MESSAGE = None
|
||||
|
||||
|
||||
|
||||
2
setup.py
2
setup.py
@@ -1,6 +1,6 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
VERSION = '0.4.0'
|
||||
VERSION = '0.4.1'
|
||||
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')
|
||||
|
||||
|
||||
@@ -16,11 +16,14 @@ from nostr_dvm.utils.zap_utils import check_and_set_ln_bits_keys
|
||||
|
||||
|
||||
def playground():
|
||||
# Generate an optional Admin Config, in this case, whenever we give our DVMs this config, they will (re)broadcast
|
||||
# their NIP89 announcement
|
||||
# You can create individual admins configs and hand them over when initializing the dvm,
|
||||
# for example to whilelist users or add to their balance.
|
||||
# If you use this global config, options will be set for all dvms that use it.
|
||||
# Popular NOSTR.band
|
||||
admin_config_trending_nostr_band = AdminConfig()
|
||||
custom_processing_msg = "Looking for trending notes on nostr.band.."
|
||||
trending_nb = discovery_trending_notes_nostrband.build_example("Trending Notes on nostr.band",
|
||||
"trending_notes_nostrband",
|
||||
admin_config_trending_nostr_band,
|
||||
custom_processing_msg)
|
||||
trending_nb.run()
|
||||
|
||||
# Popular Garden&Plants
|
||||
admin_config_plants = AdminConfig()
|
||||
@@ -44,18 +47,23 @@ def playground():
|
||||
"retail", "bakery", "synth", "slaughterhouse", "hamas", "dog days", "ww3", "socialmedia",
|
||||
"nintendo", "signature", "deepfake", "congressman", "cypherpunk", "minister", "dissentwatch",
|
||||
"inkblot", "covid", "robot", "pandemic", "bethesda", "zap farming", " defi ", " minister ",
|
||||
"nostr-hotter-site", " ai ", "palestine", "https://boards.4chan", "https://techcrunch.com", "https://screenrant.com"],
|
||||
"db_name": "db/nostr_recent_notes_plants.db",
|
||||
"db_since": 10 * 60 * 60, # 10h
|
||||
"nostr-hotter-site", " ai ", "palestine", "https://boards.4chan", "https://techcrunch.com",
|
||||
"https://screenrant.com"],
|
||||
"db_name": "db/nostr_recent_notes.db",
|
||||
"db_since": 10 * 60 * 60, # 10h since gmt
|
||||
"personalized": False}
|
||||
|
||||
image = "https://image.nostr.build/a816f3f5e98e91e8a47d50f4cd7a2c17545f556d9bb0a6086a659b9abdf7ab68.jpg"
|
||||
description = "I show recent notes about plants and gardening"
|
||||
custom_processing_msg = ["Finding the best notes for you.. #blooming", "Looking for some positivity.. #touchgrass", "Looking for #goodvibes.."]
|
||||
custom_processing_msg = ["Finding the best notes for you.. #blooming", "Looking for some positivity.. #touchgrass",
|
||||
"Looking for #goodvibes.."]
|
||||
update_db = False
|
||||
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)
|
||||
admin_config_plants, options_plants,
|
||||
image,
|
||||
description, custom_processing_msg,
|
||||
update_db)
|
||||
discovery_test_sub.run()
|
||||
|
||||
# Popular Animals (Fluffy frens)
|
||||
@@ -63,8 +71,10 @@ def playground():
|
||||
admin_config_animals.REBROADCAST_NIP89 = False
|
||||
admin_config_animals.UPDATE_PROFILE = False
|
||||
options_animal = {
|
||||
"search_list": ["catstr", "pawstr", "dogstr", " cat ", " cats ", "🐾", "🐈", "🐕" , " dog ", " dogs ", " fluffy ", "animal",
|
||||
" duck", " lion ", " lions ", " fox ", " foxes ", " koala ", " koalas ", "capybara", "squirrel", "monkey", "panda", "alpaca", " otter"],
|
||||
"search_list": ["catstr", "pawstr", "dogstr", " cat ", " cats ", "🐾", "🐈", "🐕", " dog ", " dogs ", " fluffy ",
|
||||
"animal",
|
||||
" duck", " lion ", " lions ", " fox ", " foxes ", " koala ", " koalas ", "capybara", "squirrel",
|
||||
"monkey", "panda", "alpaca", " otter"],
|
||||
"avoid_list": ["porn", "smoke", "nsfw", "bitcoin", "bolt12", "bolt11", "github", "currency", "utxo",
|
||||
"encryption", "government", "airpod", "ipad", "iphone", "android", "warren",
|
||||
"moderna", "pfizer",
|
||||
@@ -74,63 +84,73 @@ def playground():
|
||||
"retail", "bakery", "synth", "slaughterhouse", "hamas", "dog days", "ww3", "socialmedia",
|
||||
"nintendo", "signature", "deepfake", "congressman", "fried chicken", "cypherpunk",
|
||||
"chef", "cooked", "foodstr", "minister", "dissentwatch", "inkblot", "covid", "robot", "pandemic",
|
||||
" dies ", "bethesda", " defi ", " minister ", "nostr-hotter-site", " ai ", "palestine", " hit by a", "https://boards.4chan", "https://techcrunch.com", "https://screenrant.com"],
|
||||
|
||||
" dies ", "bethesda", " defi ", " minister ", "nostr-hotter-site", " ai ", "palestine", "animalistic",
|
||||
" hit by a", "https://boards.4chan", "https://techcrunch.com", "https://screenrant.com"],
|
||||
|
||||
"must_list": ["http"],
|
||||
"db_name": "db/nostr_recent_notes_animals.db",
|
||||
"db_since": 48 * 60 * 60, # 48h,
|
||||
"db_name": "db/nostr_recent_notes.db",
|
||||
"db_since": 48 * 60 * 60, # 48h since gmt,
|
||||
"personalized": False}
|
||||
|
||||
image = "https://image.nostr.build/f609311532c470f663e129510a76c9a1912ae9bc4aaaf058e5ba21cfb512c88e.jpg"
|
||||
description = "I show recent notes about animals"
|
||||
|
||||
custom_processing_msg = ["Looking for fluffy frens...", "Let's see if we find some animals for you..", "Looking for the goodest bois and girls.."]
|
||||
|
||||
custom_processing_msg = ["Looking for fluffy frens...", "Let's see if we find some animals for you..",
|
||||
"Looking for the goodest bois and girls.."]
|
||||
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)
|
||||
admin_config_animals, options_animal,
|
||||
image,
|
||||
description, custom_processing_msg,
|
||||
update_db)
|
||||
discovery_animals.run()
|
||||
|
||||
# Popular Followers
|
||||
admin_config_followers = AdminConfig()
|
||||
admin_config_followers.REBROADCAST_NIP89 = False
|
||||
admin_config_followers.UPDATE_PROFILE = False
|
||||
custom_processing_msg = ["Looking for popular notes from npubs you follow..", "Let's see what npubs you follow have been up to..", "Processing a personalized feed, just for you.."]
|
||||
custom_processing_msg = ["Looking for popular notes from npubs you follow..",
|
||||
"Let's see what npubs you follow have been up to..",
|
||||
"Processing a personalized feed, just for you.."]
|
||||
update_db = False
|
||||
options_followers_popular = {
|
||||
"db_name": "db/nostr_recent_notes.db",
|
||||
"db_since": 2 * 60 * 60, # 2h since gmt,
|
||||
}
|
||||
|
||||
discovery_followers = content_discovery_currently_popular_followers.build_example("Currently Popular Notes from npubs you follow",
|
||||
discovery_followers = content_discovery_currently_popular_followers.build_example(
|
||||
"Currently Popular Notes from npubs you follow",
|
||||
"discovery_content_followers",
|
||||
admin_config_followers,
|
||||
custom_processing_msg)
|
||||
admin_config=admin_config_followers,
|
||||
options=options_followers_popular,
|
||||
processing_msg=custom_processing_msg,
|
||||
update_db=update_db)
|
||||
discovery_followers.run()
|
||||
|
||||
# Popular Global
|
||||
admin_config_global_popular = AdminConfig()
|
||||
admin_config_global_popular.REBROADCAST_NIP89 = False
|
||||
admin_config_global_popular.UPDATE_PROFILE = False
|
||||
custom_processing_msg = ["Looking for popular notes on the Nostr..", "Let's see what's trending on Nostr..", "Finding the best notes for you.."]
|
||||
|
||||
custom_processing_msg = ["Looking for popular notes on the Nostr..", "Let's see what's trending on Nostr..",
|
||||
"Finding the best notes for you.."]
|
||||
update_db = False
|
||||
|
||||
options_global_popular = {
|
||||
"db_name": "db/nostr_recent_notes.db",
|
||||
"db_since": 60 * 60, # 1h since gmt,
|
||||
}
|
||||
discovery_global = content_discovery_currently_popular.build_example("Currently Popular Notes DVM",
|
||||
"discovery_content_test",
|
||||
admin_config_global_popular,
|
||||
custom_processing_msg)
|
||||
admin_config=admin_config_global_popular,
|
||||
options=options_global_popular,
|
||||
processing_msg=custom_processing_msg,
|
||||
update_db=update_db)
|
||||
discovery_global.run()
|
||||
|
||||
|
||||
# discovery_test_sub = content_discovery_currently_popular.build_example_subscription("Currently Popular Notes DVM (with Subscriptions)", "discovery_content_test", admin_config)
|
||||
# discovery_test_sub.run()
|
||||
|
||||
|
||||
#Popular NOSTR.band
|
||||
admin_config_trending_nostr_band = AdminConfig()
|
||||
custom_processing_msg = "Looking for trending notes on nostr.band.."
|
||||
trending_nb = discovery_trending_notes_nostrband.build_example("Trending Notes on nostr.band",
|
||||
"trending_notes_nostrband", admin_config_trending_nostr_band, custom_processing_msg)
|
||||
trending_nb.run()
|
||||
|
||||
|
||||
# Subscription Manager DVM
|
||||
subscription_config = DVMConfig()
|
||||
subscription_config.PRIVATE_KEY = check_and_set_private_key("dvm_subscription")
|
||||
|
||||
Reference in New Issue
Block a user