mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-19 23:36:24 +01:00
add bot example, add legacy code for nip04 support (on lifeline)
This commit is contained in:
@@ -1,11 +1,38 @@
|
||||
from nostr_sdk import Tag, Keys, EventBuilder
|
||||
from nostr_sdk import Tag, Keys, EventBuilder, Kind
|
||||
|
||||
from nostr_dvm.utils.definitions import EventDefinitions
|
||||
from nostr_dvm.utils.nostr_utils import send_event
|
||||
from nostr_dvm.utils.print import bcolors
|
||||
from nostr_dvm.utils.print_utils import bcolors
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async def announce_dm_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(Kind(10050), content, tags).to_event(keys)
|
||||
eventid = await send_event(event, client=client, dvm_config=dvm_config)
|
||||
if (eventid is not None):
|
||||
print(
|
||||
bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced DM relays for " + dvm_config.NIP89.NAME + " (EventID: " + str(
|
||||
eventid.id.to_hex()) + ")" + bcolors.ENDC)
|
||||
else:
|
||||
print(
|
||||
bcolors.RED + "[" + dvm_config.NIP89.NAME + "] Could not announce DM relays for " + dvm_config.NIP89.NAME + bcolors.ENDC)
|
||||
|
||||
|
||||
async def nip65_announce_relays(dvm_config, client):
|
||||
# todo we might want to call the dm relays seperately but for now we do it together with the inbox relays
|
||||
await announce_dm_relays(dvm_config, client)
|
||||
|
||||
tags = []
|
||||
|
||||
for relay in dvm_config.RELAY_LIST:
|
||||
@@ -24,3 +51,4 @@ async def nip65_announce_relays(dvm_config, client):
|
||||
else:
|
||||
print(
|
||||
bcolors.RED + "[" + dvm_config.NIP89.NAME + "] Could not announce NIP 65 for " + dvm_config.NIP89.NAME + bcolors.ENDC)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user