mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-10-06 19:53:41 +02:00
remove double entries
This commit is contained in:
@@ -36,6 +36,7 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
|
||||
search_list = []
|
||||
avoid_list = []
|
||||
must_list = []
|
||||
any_of_list = []
|
||||
personalized = False
|
||||
result = ""
|
||||
database = None
|
||||
@@ -63,11 +64,15 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
|
||||
self.avoid_list = self.options.get("avoid_list")
|
||||
if self.options.get("must_list"):
|
||||
self.must_list = self.options.get("must_list")
|
||||
if self.options.get("any_of_list"):
|
||||
self.any_of_list = self.options.get("any_of_list")
|
||||
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)
|
||||
@@ -173,15 +178,15 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
|
||||
|
||||
for event in events.to_vec():
|
||||
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()).since(since)
|
||||
reactions = await self.database.query(filt)
|
||||
if len(reactions.to_vec()) >= self.min_reactions:
|
||||
ns.finallist[event.id().to_hex()] = len(reactions.to_vec())
|
||||
if any(ele in event.content().lower() for ele in self.any_of_list) or len(self.any_of_list) == 0:
|
||||
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()).since(since)
|
||||
reactions = await self.database.query(filt)
|
||||
if len(reactions.to_vec()) >= self.min_reactions:
|
||||
ns.finallist[event.id().to_hex()] = len(reactions.to_vec())
|
||||
|
||||
result_list = []
|
||||
finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[:int(options["max_results"])]
|
||||
|
@@ -17,7 +17,7 @@ class DVMConfig:
|
||||
PER_UNIT_COST: float = None
|
||||
|
||||
# The relays the dvm is operating on and announces in its inbox relays
|
||||
RELAY_LIST = ["wss://relay.nostrdvm.com",
|
||||
RELAY_LIST = ["wss://relay.nostrdvm.com", "wss://nostr.oxtr.dev"
|
||||
]
|
||||
# DBs to sync with
|
||||
SYNC_DB_RELAY_LIST = ["wss://relay.damus.io",
|
||||
@@ -26,7 +26,6 @@ class DVMConfig:
|
||||
]
|
||||
# announce inbox relays, dm relays and NIP89 announcement to
|
||||
ANNOUNCE_RELAY_LIST = ["wss://relay.primal.net",
|
||||
"wss://relay.damus.io",
|
||||
"wss://nostr.oxtr.dev", "wss://relay.nostrdvm.com"
|
||||
]
|
||||
|
||||
|
@@ -185,20 +185,23 @@ async def send_event_outbox(event: Event, client, dvm_config) -> SendEventOutput
|
||||
if index != 0:
|
||||
if tag.as_vec()[index].rstrip("/") not in dvm_config.AVOID_OUTBOX_RELAY_LIST:
|
||||
try:
|
||||
|
||||
relays = list(set(relays + [tag.as_vec()[index]]))
|
||||
if tag.as_vec()[index].rstrip("/") not in relays and tag.as_vec()[index] not in relays:
|
||||
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
|
||||
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))
|
||||
for relay in inbox_relays:
|
||||
if relay.rstrip("/") not in relays and relay not in relays:
|
||||
relays = list(set(relays + [relay]))
|
||||
|
||||
print(relays)
|
||||
|
||||
# print(relays)
|
||||
#print(dvm_config.RELAY_LIST)
|
||||
|
Reference in New Issue
Block a user