mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-07-01 19:00:39 +02:00
add test functions, minor fix
This commit is contained in:
@ -156,7 +156,7 @@ class Bot:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# Parse inputs to params
|
# Parse inputs to params
|
||||||
tags = build_params(decrypted_text, nostr_event, index)
|
tags = build_params(decrypted_text, sender, index)
|
||||||
p_tag = Tag.parse(['p', self.dvm_config.SUPPORTED_DVMS[index].PUBLIC_KEY])
|
p_tag = Tag.parse(['p', self.dvm_config.SUPPORTED_DVMS[index].PUBLIC_KEY])
|
||||||
|
|
||||||
if self.dvm_config.SUPPORTED_DVMS[index].SUPPORTS_ENCRYPTION:
|
if self.dvm_config.SUPPORTED_DVMS[index].SUPPORTS_ENCRYPTION:
|
||||||
@ -534,7 +534,7 @@ class Bot:
|
|||||||
info, None).to_event(self.keys)
|
info, None).to_event(self.keys)
|
||||||
send_event(evt, client=self.client, dvm_config=dvm_config)
|
send_event(evt, client=self.client, dvm_config=dvm_config)
|
||||||
|
|
||||||
def build_params(decrypted_text, nostr_event, index):
|
def build_params(decrypted_text, author, index):
|
||||||
tags = []
|
tags = []
|
||||||
splitzero = decrypted_text.split(' -')
|
splitzero = decrypted_text.split(' -')
|
||||||
split = splitzero[0].split(' ')
|
split = splitzero[0].split(' ')
|
||||||
@ -542,7 +542,7 @@ class Bot:
|
|||||||
if len(split) == 1:
|
if len(split) == 1:
|
||||||
remaining_text = decrypted_text.replace(split[0], "")
|
remaining_text = decrypted_text.replace(split[0], "")
|
||||||
params = remaining_text.split(" -")
|
params = remaining_text.split(" -")
|
||||||
tag = Tag.parse(["param", "user", nostr_event.author().to_hex()])
|
tag = Tag.parse(["param", "user", author])
|
||||||
tags.append(tag)
|
tags.append(tag)
|
||||||
for i in params:
|
for i in params:
|
||||||
print(i)
|
print(i)
|
||||||
|
@ -6,7 +6,7 @@ import dotenv
|
|||||||
from nostr_sdk import Keys
|
from nostr_sdk import Keys
|
||||||
|
|
||||||
from nostr_dvm.subscription import Subscription
|
from nostr_dvm.subscription import Subscription
|
||||||
from nostr_dvm.tasks import content_discovery_currently_popular, discovery_censor_wot
|
from nostr_dvm.tasks import content_discovery_currently_popular, discovery_censor_wot, discovery_inactive_follows
|
||||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
from nostr_dvm.utils.backend_utils import keep_alive
|
from nostr_dvm.utils.backend_utils import keep_alive
|
||||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||||
@ -24,7 +24,10 @@ def playground():
|
|||||||
admin_config.REBROADCAST_NIP89 = False
|
admin_config.REBROADCAST_NIP89 = False
|
||||||
admin_config.UPDATE_PROFILE = False
|
admin_config.UPDATE_PROFILE = False
|
||||||
|
|
||||||
discovery_test_sub = discovery_censor_wot.build_example("Censorship", "discovery_censor", admin_config)
|
#discovery_test_sub = discovery_censor_wot.build_example("Censorship", "discovery_censor", admin_config)
|
||||||
|
#discovery_test_sub.run()
|
||||||
|
|
||||||
|
discovery_test_sub = discovery_inactive_follows.build_example("Inactive Followings", "discovery_inactive", admin_config)
|
||||||
discovery_test_sub.run()
|
discovery_test_sub.run()
|
||||||
|
|
||||||
|
|
@ -5,7 +5,7 @@ from threading import Thread
|
|||||||
|
|
||||||
import dotenv
|
import dotenv
|
||||||
from nostr_sdk import Keys, Client, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt, \
|
from nostr_sdk import Keys, Client, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt, \
|
||||||
nip04_encrypt, NostrSigner, PublicKey, Event
|
nip04_encrypt, NostrSigner, PublicKey, Event, Kind
|
||||||
|
|
||||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||||
from nostr_dvm.utils.nostr_utils import send_event, check_and_set_private_key
|
from nostr_dvm.utils.nostr_utils import send_event, check_and_set_private_key
|
||||||
@ -122,6 +122,32 @@ def nostr_client_test_censor_filter(users):
|
|||||||
return event.as_json()
|
return event.as_json()
|
||||||
|
|
||||||
|
|
||||||
|
def nostr_client_test_inactive_filter(user):
|
||||||
|
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||||
|
|
||||||
|
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
|
||||||
|
]
|
||||||
|
|
||||||
|
relaysTag = Tag.parse(relay_list)
|
||||||
|
alttag = Tag.parse(["alt", "This is a NIP90 DVM AI task to find people that are inactive"])
|
||||||
|
paramTag = Tag.parse(["param", "user", user])
|
||||||
|
paramTag2 = Tag.parse(["param", "since_days", "120"])
|
||||||
|
|
||||||
|
tags = [relaysTag, alttag, paramTag, paramTag2]
|
||||||
|
|
||||||
|
|
||||||
|
event = EventBuilder(EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY, str("Give me inactive users"),
|
||||||
|
tags).to_event(keys)
|
||||||
|
|
||||||
|
signer = NostrSigner.keys(keys)
|
||||||
|
client = Client(signer)
|
||||||
|
for relay in relay_list:
|
||||||
|
client.add_relay(relay)
|
||||||
|
client.connect()
|
||||||
|
config = DVMConfig
|
||||||
|
send_event(event, client=client, dvm_config=config)
|
||||||
|
return event.as_json()
|
||||||
|
|
||||||
def nostr_client_test_tts(prompt):
|
def nostr_client_test_tts(prompt):
|
||||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||||
|
|
||||||
@ -201,8 +227,13 @@ def nostr_client():
|
|||||||
dm_zap_filter = Filter().pubkey(pk).kinds([EventDefinitions.KIND_DM,
|
dm_zap_filter = Filter().pubkey(pk).kinds([EventDefinitions.KIND_DM,
|
||||||
EventDefinitions.KIND_ZAP]).since(
|
EventDefinitions.KIND_ZAP]).since(
|
||||||
Timestamp.now()) # events to us specific
|
Timestamp.now()) # events to us specific
|
||||||
dvm_filter = (Filter().kinds([EventDefinitions.KIND_NIP90_RESULT_TRANSLATE_TEXT,
|
kinds = [EventDefinitions.KIND_NIP90_GENERIC]
|
||||||
EventDefinitions.KIND_FEEDBACK]).since(Timestamp.now())) # public events
|
SUPPORTED_KINDS = [Kind(6301)]
|
||||||
|
|
||||||
|
for kind in SUPPORTED_KINDS:
|
||||||
|
if kind not in kinds:
|
||||||
|
kinds.append(kind)
|
||||||
|
dvm_filter = (Filter().kinds(kinds).since(Timestamp.now()))
|
||||||
client.subscribe([dm_zap_filter, dvm_filter], None)
|
client.subscribe([dm_zap_filter, dvm_filter], None)
|
||||||
|
|
||||||
# nostr_client_test_translation("This is the result of the DVM in spanish", "text", "es", 20, 20)
|
# nostr_client_test_translation("This is the result of the DVM in spanish", "text", "es", 20, 20)
|
||||||
@ -211,7 +242,8 @@ def nostr_client():
|
|||||||
# nostr_client_test_image("a beautiful purple ostrich watching the sunset")
|
# nostr_client_test_image("a beautiful purple ostrich watching the sunset")
|
||||||
# nostr_client_test_search_profile("dontbelieve")
|
# nostr_client_test_search_profile("dontbelieve")
|
||||||
wot = ["99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64"]
|
wot = ["99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64"]
|
||||||
nostr_client_test_censor_filter(wot)
|
#nostr_client_test_censor_filter(wot)
|
||||||
|
nostr_client_test_inactive_filter("99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64")
|
||||||
|
|
||||||
# nostr_client_test_tts("Hello, this is a test. Mic check one, two.")
|
# nostr_client_test_tts("Hello, this is a test. Mic check one, two.")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user