mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-06-27 00:50:56 +02:00
bump, cleanup
This commit is contained in:
parent
76f32276c7
commit
e2af2c82c5
@ -99,7 +99,7 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
||||
# if the dvm supports individual results, recalculate it every time for the request
|
||||
if self.personalized:
|
||||
return await self.calculate_result(request_form)
|
||||
# else return the result that gets updated once every scheduled 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:
|
||||
return self.result
|
||||
|
||||
@ -109,36 +109,27 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
||||
ns = SimpleNamespace()
|
||||
|
||||
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 = await NostrDatabase.sqlite(self.db_name)
|
||||
#cli = ClientBuilder().database(database).signer(signer).opts(opts).build()
|
||||
#await cli.connect()
|
||||
|
||||
# Negentropy reconciliation
|
||||
# Query events from database
|
||||
timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since
|
||||
since = Timestamp.from_secs(timestamp_hour_ago)
|
||||
timestamp_since = Timestamp.now().as_secs() - self.db_since
|
||||
since = Timestamp.from_secs(timestamp_since)
|
||||
|
||||
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since)
|
||||
|
||||
events = await database.query([filter1])
|
||||
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
|
||||
print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
|
||||
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_REPOST,
|
||||
definitions.EventDefinitions.KIND_REACTION,
|
||||
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
|
||||
reactions = await database.query([filt])
|
||||
|
||||
if len(reactions) >= self.min_reactions:
|
||||
ns.finallist[event.id().to_hex()] = len(reactions)
|
||||
if len(ns.finallist) == 0:
|
||||
#await cli.shutdown()
|
||||
return self.result
|
||||
|
||||
result_list = []
|
||||
@ -147,12 +138,13 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
||||
# print(EventId.parse(entry[0]).to_bech32() + "/" + EventId.parse(entry[0]).to_hex() + ": " + str(entry[1]))
|
||||
e_tag = Tag.parse(["e", entry[0]])
|
||||
result_list.append(e_tag.as_vec())
|
||||
#await cli.shutdown()
|
||||
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
|
||||
print("[" + self.dvm_config.NIP89.NAME + "] Filtered " + str(
|
||||
len(result_list)) + " fitting events.")
|
||||
# await cli.shutdown()
|
||||
return json.dumps(result_list)
|
||||
|
||||
|
||||
def post_process(self, result, event):
|
||||
"""Overwrite the interface function to return a social client readable format, if requested"""
|
||||
for tag in event.tags():
|
||||
@ -174,6 +166,8 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
||||
self.last_schedule = Timestamp.now().as_secs()
|
||||
self.result = await self.calculate_result(self.request_form)
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
async def sync_db(self):
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_LONG_TIMEOUT)))
|
||||
|
@ -130,19 +130,8 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
|
||||
ns = SimpleNamespace()
|
||||
|
||||
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 = await NostrDatabase.sqlite(self.db_name)
|
||||
#cli = ClientBuilder().database(database).signer(signer).opts(opts).build()
|
||||
|
||||
#await cli.connect()
|
||||
|
||||
# Negentropy reconciliation
|
||||
# Query events from database
|
||||
timestamp_since = Timestamp.now().as_secs() - self.db_since
|
||||
since = Timestamp.from_secs(timestamp_since)
|
||||
|
||||
@ -157,7 +146,6 @@ 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,
|
||||
|
2
setup.py
2
setup.py
@ -1,6 +1,6 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
VERSION = '0.6.11'
|
||||
VERSION = '0.6.12'
|
||||
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')
|
||||
|
||||
|
@ -31,13 +31,13 @@ update_profile = False
|
||||
global_update_rate = 120 # set this high on first sync so db can fully sync before another process trys to.
|
||||
use_logger = True
|
||||
|
||||
AVOID_PAID_OUTBOX_RELAY_LIST = ["wss://nostrelay.yeghro.site", "wss://nostr.wine", "wss://filter.nostr.wine",
|
||||
"wss://nostr21.com", "wss://nostr.bitcoiner.social", "wss://nostr.orangepill.dev",
|
||||
"wss://relay.lnpay.me", "wss://relay.snort.social", "wss://relay.minds.com/nostr/v1/ws",
|
||||
AVOID_PAID_OUTBOX_RELAY_LIST = ["wss://nostrelay.yeghro.site", "wss://nostr.wine", "wss://filter.nostr.wine", "wss://relay.current.fyi",
|
||||
"wss://nostr21.com", "wss://nostr.bitcoiner.social", "wss://nostr.orangepill.dev", "wss://brb.io",
|
||||
"wss://relay.lnpay.me", "wss://relay.snort.social", "wss://relay.minds.com/nostr/v1/ws", "ws://elitedesk:4848",
|
||||
"wss://nostr-pub.semisol.dev", "wss://mostr.mostr.pub", "wss://relay.mostr.pub", "wss://minds.com",
|
||||
"wss://yabu.me", "wss://relay.yozora.world", "wss://filter.nostr.wine/?global=all", "wss://eden.nostr.land",
|
||||
"wss://relay.orangepill.ovh", "wss://nostr.jcloud.es", "wss://af.purplerelay.com", "wss://za.purplerelay.com",
|
||||
"wss://relay.nostrich.land", "wss://relay.nostrplebs.com", "wss://relay.nostrich.land",
|
||||
"wss://relay.nostrich.land", "wss://relay.nostrplebs.com", "wss://relay.nostrich.land", "ws://elitedesk.local:4848",
|
||||
"wss://rss.nos.social", "wss://atlas.nostr.land", "wss://puravida.nostr.land", "wss://nostr.inosta.cc",
|
||||
"wss://relay.orangepill.dev", "wss://no.str.cr", "wss://nostr.milou.lol", "wss://relay.nostr.com.au",
|
||||
"wss://puravida.nostr.land", "wss://atlas.nostr.land", "wss://nostr-pub.wellorder.net", "wss://eelay.current.fyi",
|
||||
@ -45,12 +45,14 @@ AVOID_PAID_OUTBOX_RELAY_LIST = ["wss://nostrelay.yeghro.site", "wss://nostr.wine
|
||||
"wss://bitcoiner.social", "wss://relay.stoner.com", "wss://nostr.l00p.org", "wss://relay.nostr.ro", "wss://nostr.kollider.xyz",
|
||||
"wss://relay.valera.co", "wss://relay.austrich.net", "wss://relay.nostrich.de", "wss://nostr.azte.co", "wss://nostr-relay.schnitzel.world",
|
||||
"wss://relay.nostriches.org", "wss://happytavern.co", "wss://onlynotes.lol", "wss://offchain.pub", "wss://purplepag.es", "wss://relay.plebstr.com",
|
||||
"wss://poster.place/relay", "wss://relayable.org", "wss://bbb.santos.lol", "wss://relay.bitheaven.social", "wss://theforest.nostr1.com",
|
||||
"wss://relay.nostrati.com", "wss://purplerelay.com", "wss://hist.nostr.land", "wss://creatr.nostr.wine", "ws://localhost:4869",
|
||||
"wss://poster.place/relay", "wss://relayable.org", "wss://bbb.santos.lol", "wss://relay.bitheaven.social", "wss://theforest.nostr1.com", "wss://at.nostrworks.com",
|
||||
"wss://relay.nostrati.com", "wss://purplerelay.com", "wss://hist.nostr.land", "wss://creatr.nostr.wine", "ws://localhost:4869", "wss://pleb.cloud", "wss://nos.lol",
|
||||
"wss://pyramid.fiatjaf.com", "wss://relay.nos.social", "wss://nostr.thank.eu", "wss://inbox.nostr.wine", "wss://relay.pleb.to", "wss://welcome.nostr.wine",
|
||||
"wss://relay.nostrview.com", "wss://nostr.land", "wss://eu.purplerelay.com", "wss://xmr.usenostr.org", "wss://nostr-relay.app", "ws://umbrel:4848", "wss://umbrel:4848",
|
||||
"wss://fiatjaf.com", "wss://nostr-relay.wlvs.space", "wss://relayer.fiatjaf.com",
|
||||
"wss://nostr-01.bolt.observer", "wss://nostr1.tunnelsats.com", "wss://relay.nostr.ch", "wss://relay.nostr.io"
|
||||
"wss://fiatjaf.com", "wss://nostr-relay.wlvs.space", "wss://relayer.fiatjaf.com", "wss://nostr.yuv.al", "wss://relay.nostr.band", "wss://nostr.massmux.com",
|
||||
"wss://nostr-01.bolt.observer", "wss://nostr1.tunnelsats.com", "wss://relay.nostr.ch", "wss://relay.nostr.io", "wss://nostr.thank.eu", "wss://nostr.bitcoinplebs.de",
|
||||
"wss://adult.18plus.social", "wss://bostr.online", "wss://relay.current.fyi", "wss://nosdrive.app/relay", "wss://studio314.nostr1.com", "wss://relay.nostrbr.online"
|
||||
|
||||
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user