mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-09-25 20:06:38 +02:00
adjustments for updating nostr sdk to 0.0.5
(but some delays appear)
This commit is contained in:
2
main.py
2
main.py
@@ -12,7 +12,7 @@ from utils.dvmconfig import DVMConfig
|
||||
|
||||
def run_nostr_dvm_with_local_config():
|
||||
# We extract the Publickey from our bot, so the DVMs know who they should listen and react to.
|
||||
bot_publickey = Keys.from_sk_str(os.getenv("BOT_PRIVATE_KEY")).public_key().to_hex()
|
||||
bot_publickey = Keys.from_sk_str(os.getenv("BOT_PRIVATE_KEY")).public_key()
|
||||
|
||||
# Spawn some DVMs in the playground and run them
|
||||
# You can add arbitrary DVMs there and instantiate them here
|
||||
|
@@ -9,7 +9,7 @@ ffmpegio-core==0.8.5
|
||||
idna==3.4
|
||||
inquirer==3.1.3
|
||||
install==1.3.5
|
||||
nostr-sdk==0.0.4
|
||||
nostr-sdk==0.0.5
|
||||
numpy==1.26.2
|
||||
packaging==23.2
|
||||
pandas==2.1.3
|
||||
|
@@ -212,7 +212,8 @@ def fetch_user_metadata(sender, client) -> (str, str, str):
|
||||
nip05 = ""
|
||||
lud16 = ""
|
||||
try:
|
||||
profile_filter = Filter().kind(0).author(sender).limit(1)
|
||||
pk = PublicKey.from_hex(sender)
|
||||
profile_filter = Filter().kind(0).author(pk).limit(1)
|
||||
events = client.get_events_of([profile_filter], timedelta(seconds=3))
|
||||
if len(events) > 0:
|
||||
ev = events[0]
|
||||
|
@@ -1,15 +1,19 @@
|
||||
from datetime import timedelta
|
||||
from nostr_sdk import Keys, Filter, Client, Alphabet, EventId, Options, Event
|
||||
from nostr_sdk import Keys, Filter, Client, Alphabet, EventId, Options, Event, PublicKey
|
||||
|
||||
|
||||
def get_event_by_id(event_id: str, client: Client, config=None) -> Event | None:
|
||||
split = event_id.split(":")
|
||||
if len(split) == 3:
|
||||
id_filter = Filter().author(split[1]).custom_tag(Alphabet.D, [split[2]])
|
||||
pk = PublicKey.from_hex(split[1])
|
||||
id_filter = Filter().author(pk).custom_tag(Alphabet.D, [split[2]])
|
||||
events = client.get_events_of([id_filter], timedelta(seconds=config.RELAY_TIMEOUT))
|
||||
else:
|
||||
if str(event_id).startswith('note'):
|
||||
event_id = EventId.from_bech32(event_id).to_hex()
|
||||
event_id = EventId.from_bech32(event_id)
|
||||
else:
|
||||
event_id = EventId.from_hex(event_id)
|
||||
|
||||
id_filter = Filter().id(event_id).limit(1)
|
||||
events = client.get_events_of([id_filter], timedelta(seconds=config.RELAY_TIMEOUT))
|
||||
if len(events) > 0:
|
||||
|
Reference in New Issue
Block a user