mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-06-27 09:00:57 +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 the dvm supports individual results, recalculate it every time for the request
|
||||||
if self.personalized:
|
if self.personalized:
|
||||||
return await self.calculate_result(request_form)
|
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:
|
else:
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
@ -109,36 +109,27 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
|||||||
ns = SimpleNamespace()
|
ns = SimpleNamespace()
|
||||||
|
|
||||||
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 = await NostrDatabase.sqlite(self.db_name)
|
database = await NostrDatabase.sqlite(self.db_name)
|
||||||
#cli = ClientBuilder().database(database).signer(signer).opts(opts).build()
|
|
||||||
#await cli.connect()
|
|
||||||
|
|
||||||
# Negentropy reconciliation
|
timestamp_since = Timestamp.now().as_secs() - self.db_since
|
||||||
# Query events from database
|
since = Timestamp.from_secs(timestamp_since)
|
||||||
timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since
|
|
||||||
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 = await database.query([filter1])
|
events = await database.query([filter1])
|
||||||
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
|
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
|
||||||
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_since:
|
||||||
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 = await database.query([filt])
|
reactions = await 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:
|
||||||
#await cli.shutdown()
|
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
result_list = []
|
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]))
|
# 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())
|
||||||
#await cli.shutdown()
|
|
||||||
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
|
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
|
||||||
print("[" + self.dvm_config.NIP89.NAME + "] Filtered " + str(
|
print("[" + self.dvm_config.NIP89.NAME + "] Filtered " + str(
|
||||||
len(result_list)) + " fitting events.")
|
len(result_list)) + " fitting events.")
|
||||||
|
# await cli.shutdown()
|
||||||
return json.dumps(result_list)
|
return json.dumps(result_list)
|
||||||
|
|
||||||
|
|
||||||
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():
|
||||||
@ -174,6 +166,8 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
|||||||
self.last_schedule = Timestamp.now().as_secs()
|
self.last_schedule = Timestamp.now().as_secs()
|
||||||
self.result = await self.calculate_result(self.request_form)
|
self.result = await self.calculate_result(self.request_form)
|
||||||
return 1
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
async def sync_db(self):
|
async def sync_db(self):
|
||||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_LONG_TIMEOUT)))
|
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()
|
ns = SimpleNamespace()
|
||||||
|
|
||||||
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 = await NostrDatabase.sqlite(self.db_name)
|
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
|
timestamp_since = Timestamp.now().as_secs() - self.db_since
|
||||||
since = Timestamp.from_secs(timestamp_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 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 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):
|
if not any(ele in event.content().lower() for ele in self.avoid_list):
|
||||||
|
|
||||||
filt = Filter().kinds(
|
filt = Filter().kinds(
|
||||||
[definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION,
|
[definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION,
|
||||||
definitions.EventDefinitions.KIND_REPOST,
|
definitions.EventDefinitions.KIND_REPOST,
|
||||||
|
2
setup.py
2
setup.py
@ -1,6 +1,6 @@
|
|||||||
from setuptools import setup, find_packages
|
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'
|
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')
|
||||||
|
|
||||||
|
@ -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.
|
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
|
||||||
|
|
||||||
AVOID_PAID_OUTBOX_RELAY_LIST = ["wss://nostrelay.yeghro.site", "wss://nostr.wine", "wss://filter.nostr.wine",
|
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://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",
|
"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://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://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.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://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://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",
|
"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://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.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://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://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://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://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://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://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-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