mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-03-17 13:21:48 +01:00
update to 1.1.0
This commit is contained in:
parent
c95b0836be
commit
de58d17f73
@ -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())))
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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 = []
|
||||
|
@ -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:
|
||||
|
@ -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",
|
||||
|
2
setup.py
2
setup.py
@ -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')
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user