update to 1.1.0

This commit is contained in:
dbth 2025-02-06 21:34:02 +01:00
parent c95b0836be
commit de58d17f73
9 changed files with 27 additions and 19 deletions

View File

@ -185,7 +185,7 @@ class DicoverContentCurrentlyPopularGallery(DVMTaskInterface):
reactions = await databasegallery.query(filt)
reactions2 = await databasegallery.query(filter_nip22)
reactions.merge(reactions2)
reactions = reactions.merge(reactions2)
#print("Reactions:" + str(len(reactions.to_vec())))

View File

@ -163,7 +163,7 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
for word in self.search_list[1:]:
filter = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since).search(word)
evts = await self.database.query(filter)
events.merge(evts)
events = events.merge(evts)

View File

@ -139,7 +139,7 @@ class Discoverlatestperfollower(DVMTaskInterface):
filter1 = (Filter().author(user).kind(Kind(1))
.limit(1))
events = await cli.fetch_events(filter1, relay_timeout_long)
event_from_authors.merge(events)
event_from_authors = event_from_authors.merge(events)
except Exception as e:
print(e)

View File

@ -23,8 +23,6 @@ Params: None
"""
# TODO: This is currently broken after SDK update.
class DiscoverInactiveFollows(DVMTaskInterface):
KIND: Kind = EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY
@ -129,7 +127,7 @@ class DiscoverInactiveFollows(DVMTaskInterface):
for j in range(i+1, i + st):
filter1 = Filter().author(PublicKey.parse(users[j])).since(notactivesince).limit(1)
events = await cli.fetch_events(filter1, relay_timeout_long)
event_from_authors.merge(events)
event_from_authors = event_from_authors.merge(events)
for author in event_from_authors.to_vec():
instance.dic[author.author().to_hex()] = "True"

View File

@ -116,7 +116,7 @@ class DiscoverNonFollowers(DVMTaskInterface):
for i in range(i+1, i + st):
filter1 = Filter().author(PublicKey.parse(users[i])).kind(Kind(3))
follower = await cli.fetch_events(filter1, relay_timeout)
followers.merge(follower)
followers = followers.merge(follower)
if len(followers.to_vec()) > 0:
result_list = []

View File

@ -181,27 +181,36 @@ async def send_event_outbox(event: Event, client, dvm_config) -> SendEventOutput
relays = dvm_config.RELAY_LIST
for tag in event.tags().to_vec():
if tag.as_vec()[0] == 'relays':
print(tag.as_vec())
for index, param in enumerate(tag.as_vec()):
if index != 0:
if tag.as_vec()[index].rstrip("/") not in dvm_config.AVOID_OUTBOX_RELAY_LIST:
try:
relays.append(tag.as_vec()[index])
relays = list(set(relays + [tag.as_vec()[index]]))
except:
print("[" + dvm_config.NIP89.NAME + "] " + tag.as_vec()[
index] + " couldn't be added to outbox relays")
break
#print(relays)
# 3. If we couldn't find relays, we look in the receivers inbox
if len(relays) == len(dvm_config.RELAY_LIST):
relays = await get_inbox_relays(event, client, dvm_config)
inbox_relays = []
if relays == dvm_config.RELAY_LIST:
print("[" + dvm_config.NIP89.NAME + "] No relay tags found, replying to inbox relays")
inbox_relays = await get_inbox_relays(event, client, dvm_config)
relays = list(set(relays + inbox_relays))
# print(relays)
#print(dvm_config.RELAY_LIST)
# 4. If we don't find inbox relays (e.g. because the user didn't announce them, we just send to our default relays
if len(relays) == len(dvm_config.RELAY_LIST):
if relays == dvm_config.RELAY_LIST and dvm_config != inbox_relays:
print("[" + dvm_config.NIP89.NAME + "] No Inbox found, replying to generic relays")
relays = await get_main_relays(event, client, dvm_config)
main_relays = await get_main_relays(event, client, dvm_config)
relays = list(set(relays + main_relays))
# 5. Otherwise, we create a new Outbox client with the inbox relays and send the event there
# 5. Otherwise, we create a new Outbox client with the inbox relays and send the event there
relaylimits = RelayLimits.disable()
connection = Connection().addr("127.0.0.1:9050").target(ConnectionTarget.ONION)
opts = Options().relay_limits(relaylimits).connection(connection)
@ -229,7 +238,8 @@ async def send_event_outbox(event: Event, client, dvm_config) -> SendEventOutput
# 5. Fallback, if we couldn't send the event to any relay, we try to send to generic relays instead.
if event_response is None:
relays = await get_main_relays(event, client, dvm_config)
main_relays = await get_main_relays(event, client, dvm_config)
relays = list(set(relays + main_relays))
if len(relays) == 0:
return None
for relay in relays:

View File

@ -2,7 +2,7 @@
# even trying to send to them, avoiding potential errors or delays on the way.
AVOID_OUTBOX_RELAY_LIST = ["wss://nos.lol", "wss://nostr.fmt.wiz.biz", "wss://nostrelay.yeghro.site", "wss://nostr.wine",
AVOID_OUTBOX_RELAY_LIST = ["wss://nostr.fmt.wiz.biz", "wss://nostrelay.yeghro.site", "wss://nostr.wine",
"wss://filter.nostr.wine", "wss://relay.lightwork.space", "wss://onchain.pub",
"wss://nostr21.com", "wss://nostr.bitcoiner.social", "wss://nostr.orangepill.dev",
"wss://brb.io", "wss://relay.nostr.ch", "wss://nostr.rock", "wss://nostr.sandwich.farm",

View File

@ -1,6 +1,6 @@
from setuptools import setup, find_packages
VERSION = '1.0.9'
VERSION = '1.1.0'
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information')

View File

@ -152,7 +152,7 @@ def playground(announce=False):
opts = Options().relay_limits(relaylimits)
signer = NostrSigner.keys(keys)
cli = ClientBuilder().signer(signer).opts(opts).build()
for relay in dvm.dvm_config.RELAY_LIST:
for relay in dvm.dvm_config.ANNOUNCE_RELAY_LIST:
await cli.add_relay(relay)
# ropts = RelayOptions().ping(False)
# await cli.add_relay_with_opts("wss://nostr.band", ropts)
@ -160,7 +160,6 @@ def playground(announce=False):
await cli.connect()
#pip install -U https://github.com/mrgick/duckduckgo-chat-ai/archive/master.zip
author = PublicKey.parse(options["request_event_author"])
print(options["request_event_author"])
filterauth = Filter().kind(definitions.EventDefinitions.KIND_NOTE).author(author).limit(100)
event_struct = await cli.fetch_events(filterauth, relay_timeout)
@ -211,7 +210,8 @@ def playground(announce=False):
for keyword in keywords[1:]:
filter = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since).search(" " + keyword.lstrip().rstrip() + " ")
evts = await database.query(filter)
events.merge(evts)
events = events.merge(evts)