mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-07-08 00:40:00 +02:00
adaptions to sdk 0.11.0
This commit is contained in:
@ -74,22 +74,22 @@ class Bot:
|
|||||||
if (EventDefinitions.KIND_NIP90_EXTRACT_TEXT.as_u64() + 1000 <= nostr_event.kind().as_u64()
|
if (EventDefinitions.KIND_NIP90_EXTRACT_TEXT.as_u64() + 1000 <= nostr_event.kind().as_u64()
|
||||||
<= EventDefinitions.KIND_NIP90_GENERIC.as_u64() + 1000):
|
<= EventDefinitions.KIND_NIP90_GENERIC.as_u64() + 1000):
|
||||||
handle_nip90_response_event(nostr_event)
|
handle_nip90_response_event(nostr_event)
|
||||||
elif nostr_event.kind().as_u64() == EventDefinitions.KIND_FEEDBACK.as_u64():
|
elif nostr_event.kind() == EventDefinitions.KIND_FEEDBACK:
|
||||||
handle_nip90_feedback(nostr_event)
|
handle_nip90_feedback(nostr_event)
|
||||||
|
|
||||||
elif nostr_event.kind().as_u64() == EventDefinitions.KIND_ZAP.as_u64():
|
elif nostr_event.kind() == EventDefinitions.KIND_ZAP:
|
||||||
handle_zap(nostr_event)
|
handle_zap(nostr_event)
|
||||||
|
|
||||||
elif nostr_event.kind().match_enum(KindEnum.ENCRYPTED_DIRECT_MESSAGE()):
|
elif nostr_event.kind() == EventDefinitions.KIND_DM:
|
||||||
try:
|
try:
|
||||||
handle_dm(nostr_event)
|
handle_dm(nostr_event)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error during content NIP04 decryption: {e}")
|
print(f"Error during content NIP04 decryption: {e}")
|
||||||
elif nostr_event.kind().match_enum(KindEnum.GIFT_WRAP()):
|
elif nostr_event.kind() == KindEnum.GIFT_WRAP():
|
||||||
print("Decrypting NIP59 event")
|
print("Decrypting NIP59 event")
|
||||||
try:
|
try:
|
||||||
rumor: UnsignedEvent = nip59_extract_rumor(self.keys, nostr_event)
|
rumor: UnsignedEvent = nip59_extract_rumor(self.keys, nostr_event)
|
||||||
if rumor.kind().match_enum(KindEnum.SEALED_DIRECT()):
|
if rumor.kind() == KindEnum.SEALED_DIRECT():
|
||||||
msg = rumor.content()
|
msg = rumor.content()
|
||||||
print(f"Received new msg [sealed]: {msg}")
|
print(f"Received new msg [sealed]: {msg}")
|
||||||
self.client.send_sealed_msg(rumor.author(), "Nip44 is not supported yet, but coming soon", None)
|
self.client.send_sealed_msg(rumor.author(), "Nip44 is not supported yet, but coming soon", None)
|
||||||
|
@ -272,7 +272,7 @@ class DVM:
|
|||||||
user = get_or_add_user(db=self.dvm_config.DB, npub=sender, client=self.client, config=self.dvm_config)
|
user = get_or_add_user(db=self.dvm_config.DB, npub=sender, client=self.client, config=self.dvm_config)
|
||||||
|
|
||||||
if zapped_event is not None:
|
if zapped_event is not None:
|
||||||
if zapped_event.kind().as_u64() == EventDefinitions.KIND_FEEDBACK.as_u64():
|
if zapped_event.kind() == EventDefinitions.KIND_FEEDBACK:
|
||||||
|
|
||||||
amount = 0
|
amount = 0
|
||||||
job_event = None
|
job_event = None
|
||||||
@ -295,7 +295,7 @@ class DVM:
|
|||||||
|
|
||||||
# if a reaction by us got zapped
|
# if a reaction by us got zapped
|
||||||
print(status)
|
print(status)
|
||||||
if job_event.kind().as_u64() == EventDefinitions.KIND_NIP88_SUBSCRIBE_EVENT.as_u64():
|
if job_event.kind() == EventDefinitions.KIND_NIP88_SUBSCRIBE_EVENT:
|
||||||
send_job_status_reaction(job_event, "subscription-success", client=self.client,
|
send_job_status_reaction(job_event, "subscription-success", client=self.client,
|
||||||
dvm_config=self.dvm_config, user=user)
|
dvm_config=self.dvm_config, user=user)
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ class DVM:
|
|||||||
False, invoice_amount, client=self.client,
|
False, invoice_amount, client=self.client,
|
||||||
dvm_config=self.dvm_config)
|
dvm_config=self.dvm_config)
|
||||||
print("[" + self.dvm_config.NIP89.NAME + "] Invoice was not paid sufficiently")
|
print("[" + self.dvm_config.NIP89.NAME + "] Invoice was not paid sufficiently")
|
||||||
elif zapped_event.kind().as_u64() == EventDefinitions.KIND_NIP88_SUBSCRIBE_EVENT.as_u64():
|
elif zapped_event.kind() == EventDefinitions.KIND_NIP88_SUBSCRIBE_EVENT:
|
||||||
print("new subscription, doing nothing")
|
print("new subscription, doing nothing")
|
||||||
|
|
||||||
elif zapped_event.kind() in EventDefinitions.ANY_RESULT:
|
elif zapped_event.kind() in EventDefinitions.ANY_RESULT:
|
||||||
|
@ -78,9 +78,9 @@ class Subscription:
|
|||||||
keys = self.keys
|
keys = self.keys
|
||||||
|
|
||||||
def handle(self, relay_url, subscription_id, nostr_event: Event):
|
def handle(self, relay_url, subscription_id, nostr_event: Event):
|
||||||
if nostr_event.kind().as_u64() == EventDefinitions.KIND_NIP90_DVM_SUBSCRIPTION.as_u64():
|
if nostr_event.kind() == EventDefinitions.KIND_NIP90_DVM_SUBSCRIPTION:
|
||||||
handle_nwc_request(nostr_event)
|
handle_nwc_request(nostr_event)
|
||||||
elif nostr_event.kind().as_u64() == EventDefinitions.KIND_NIP88_STOP_SUBSCRIPTION_EVENT.as_u64():
|
elif nostr_event.kind() == EventDefinitions.KIND_NIP88_STOP_SUBSCRIPTION_EVENT:
|
||||||
handle_cancel(nostr_event)
|
handle_cancel(nostr_event)
|
||||||
|
|
||||||
def handle_msg(self, relay_url, msg):
|
def handle_msg(self, relay_url, msg):
|
||||||
|
@ -67,7 +67,7 @@ class TextSummarizationHuggingChat(DVMTaskInterface):
|
|||||||
print("Event not found")
|
print("Event not found")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
if evt.kind().as_u64() == EventDefinitions.KIND_NIP90_RESULT_CONTENT_DISCOVERY:
|
if evt.kind() == EventDefinitions.KIND_NIP90_RESULT_CONTENT_DISCOVERY:
|
||||||
result_list = json.loads(evt.content())
|
result_list = json.loads(evt.content())
|
||||||
prompt = ""
|
prompt = ""
|
||||||
for tag in result_list:
|
for tag in result_list:
|
||||||
|
@ -68,7 +68,7 @@ class SummarizationUnleashedChat(DVMTaskInterface):
|
|||||||
print("Event not found")
|
print("Event not found")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
if evt.kind().as_u64() == EventDefinitions.KIND_NIP90_RESULT_CONTENT_DISCOVERY:
|
if evt.kind() == EventDefinitions.KIND_NIP90_RESULT_CONTENT_DISCOVERY:
|
||||||
result_list = json.loads(evt.content())
|
result_list = json.loads(evt.content())
|
||||||
prompt = ""
|
prompt = ""
|
||||||
for tag in result_list:
|
for tag in result_list:
|
||||||
|
@ -12,7 +12,7 @@ from nostr_dvm.utils.nostr_utils import get_event_by_id, get_referenced_event_by
|
|||||||
|
|
||||||
def get_task(event, client, dvm_config):
|
def get_task(event, client, dvm_config):
|
||||||
try:
|
try:
|
||||||
if event.kind().as_u64() == EventDefinitions.KIND_NIP90_GENERIC.as_u64(): # use this for events that have no id yet, inclufr j tag
|
if event.kind() == EventDefinitions.KIND_NIP90_GENERIC: # use this for events that have no id yet, inclufr j tag
|
||||||
for tag in event.tags():
|
for tag in event.tags():
|
||||||
if tag.as_vec()[0] == 'j':
|
if tag.as_vec()[0] == 'j':
|
||||||
return tag.as_vec()[1]
|
return tag.as_vec()[1]
|
||||||
@ -26,7 +26,7 @@ def get_task(event, client, dvm_config):
|
|||||||
return "unknown job: " + event.as_json()
|
return "unknown job: " + event.as_json()
|
||||||
|
|
||||||
# This looks a bit more complicated, but we do several tasks for text-extraction in the future
|
# This looks a bit more complicated, but we do several tasks for text-extraction in the future
|
||||||
elif event.kind().as_u64() == EventDefinitions.KIND_NIP90_EXTRACT_TEXT.as_u64():
|
elif event.kind() == EventDefinitions.KIND_NIP90_EXTRACT_TEXT:
|
||||||
for tag in event.tags():
|
for tag in event.tags():
|
||||||
if tag.as_vec()[0] == "i":
|
if tag.as_vec()[0] == "i":
|
||||||
if tag.as_vec()[2] == "url":
|
if tag.as_vec()[2] == "url":
|
||||||
@ -57,7 +57,7 @@ def get_task(event, client, dvm_config):
|
|||||||
return "unknown type"
|
return "unknown type"
|
||||||
else:
|
else:
|
||||||
return "unknown job"
|
return "unknown job"
|
||||||
elif event.kind().as_u64() == EventDefinitions.KIND_NIP90_GENERATE_IMAGE.as_u64():
|
elif event.kind() == EventDefinitions.KIND_NIP90_GENERATE_IMAGE:
|
||||||
has_image_tag = False
|
has_image_tag = False
|
||||||
has_text_tag = False
|
has_text_tag = False
|
||||||
for tag in event.tags():
|
for tag in event.tags():
|
||||||
|
2
setup.py
2
setup.py
@ -15,7 +15,7 @@ setup(
|
|||||||
long_description=LONG_DESCRIPTION,
|
long_description=LONG_DESCRIPTION,
|
||||||
packages=find_packages(include=['nostr_dvm', 'nostr_dvm.*']),
|
packages=find_packages(include=['nostr_dvm', 'nostr_dvm.*']),
|
||||||
|
|
||||||
install_requires=["nostr-sdk==0.10.0",
|
install_requires=["nostr-sdk==0.11.0",
|
||||||
"bech32",
|
"bech32",
|
||||||
"pycryptodome==3.20.0",
|
"pycryptodome==3.20.0",
|
||||||
"python-dotenv==1.0.0",
|
"python-dotenv==1.0.0",
|
||||||
|
Reference in New Issue
Block a user