add NIP65 relay announcement, add blastr option to send_event function

This commit is contained in:
Believethehype
2024-06-03 17:04:08 +02:00
parent dd1ba27708
commit f3d894e4dc
5 changed files with 58 additions and 28 deletions

View File

@@ -0,0 +1,21 @@
from nostr_sdk import Tag, Keys, EventBuilder
from nostr_dvm.utils.definitions import EventDefinitions
from nostr_dvm.utils.nostr_utils import send_event
from nostr_dvm.utils.print import bcolors
def nip65_announce_relays(dvm_config, client):
tags = []
for relay in dvm_config.RELAY_LIST:
r_tag = Tag.parse(["r", relay])
tags.append(r_tag)
keys = Keys.parse(dvm_config.NIP89.PK)
content = ""
event = EventBuilder(EventDefinitions.KIND_RELAY_ANNOUNCEMENT, content, tags).to_event(keys)
eventid = send_event(event, client=client, dvm_config=dvm_config, blastr=True)
print(bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced NIP 65 for " + dvm_config.NIP89.NAME +" (EventID: " + eventid.to_hex() +")" + bcolors.ENDC)