mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-07-19 09:42:33 +02:00
add deletion tutorial, improve logs
This commit is contained in:
@ -53,9 +53,12 @@ async def fetch_nip89_parameters_for_deletion(keys, eventid, client, dvmconfig,
|
|||||||
return
|
return
|
||||||
|
|
||||||
if event.author().to_hex() == keys.public_key().to_hex():
|
if event.author().to_hex() == keys.public_key().to_hex():
|
||||||
await nip89_delete_announcement(event.id().to_hex(), keys, d_tag, client, dvmconfig)
|
|
||||||
if pow:
|
if pow:
|
||||||
await nip89_delete_announcement_pow(event.id().to_hex(), keys, d_tag, client, dvmconfig)
|
await nip89_delete_announcement_pow(event.id().to_hex(), keys, d_tag, client, dvmconfig)
|
||||||
|
else:
|
||||||
|
print("Delete with POW, this might take a while, please wait until finished")
|
||||||
|
await nip89_delete_announcement(event.id().to_hex(), keys, d_tag, client, dvmconfig)
|
||||||
|
|
||||||
print("NIP89 announcement deleted from known relays!")
|
print("NIP89 announcement deleted from known relays!")
|
||||||
else:
|
else:
|
||||||
print("Privatekey does not belong to event")
|
print("Privatekey does not belong to event")
|
||||||
@ -66,7 +69,7 @@ async def nip89_delete_announcement(eid: str, keys: Keys, dtag: str, client: Cli
|
|||||||
a_tag = Tag.parse(
|
a_tag = Tag.parse(
|
||||||
["a", str(EventDefinitions.KIND_ANNOUNCEMENT.as_u16()) + ":" + keys.public_key().to_hex() + ":" + dtag])
|
["a", str(EventDefinitions.KIND_ANNOUNCEMENT.as_u16()) + ":" + keys.public_key().to_hex() + ":" + dtag])
|
||||||
event = EventBuilder(Kind(5), "").tags([e_tag, a_tag]).sign_with_keys(keys)
|
event = EventBuilder(Kind(5), "").tags([e_tag, a_tag]).sign_with_keys(keys)
|
||||||
print(f"POW event: {event.as_json()}")
|
print(f"Deletion event: {event.as_json()}")
|
||||||
await send_event(event, client, config)
|
await send_event(event, client, config)
|
||||||
|
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -1,6 +1,6 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
VERSION = '1.0.2'
|
VERSION = '1.0.3'
|
||||||
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
|
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
|
||||||
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information')
|
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information')
|
||||||
|
|
||||||
|
@ -79,10 +79,13 @@ def playground(announce=False):
|
|||||||
# Add NIP89
|
# Add NIP89
|
||||||
nip89info = {
|
nip89info = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
"image": "https://i.nostr.build/I8fJo0n355cbNEbS.png",
|
||||||
"picture": "https://i.nostr.build/I8fJo0n355cbNEbS.png", # "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
|
"picture": "https://i.nostr.build/I8fJo0n355cbNEbS.png", # "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
|
||||||
"about": "I create a personalized feed based on topics you were writing about recently",
|
"about": "I create a personalized feed based on topics you were writing about recently",
|
||||||
"supportsEncryption": True,
|
"supportsEncryption": True,
|
||||||
"acceptsNutZaps": dvm_config.ENABLE_NUTZAP,
|
"acceptsNutZaps": dvm_config.ENABLE_NUTZAP,
|
||||||
|
"personalized": True,
|
||||||
|
"amount": "free",
|
||||||
"nip90Params": {
|
"nip90Params": {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,6 +106,7 @@ def playground(announce=False):
|
|||||||
async def process_request(options, prompt):
|
async def process_request(options, prompt):
|
||||||
result = ""
|
result = ""
|
||||||
try:
|
try:
|
||||||
|
# pip install -U https://github.com/mrgick/duckduckgo-chat-ai/archive/master.zip
|
||||||
from duck_chat import DuckChat
|
from duck_chat import DuckChat
|
||||||
async with DuckChat(model=ModelType.GPT4o) as chat:
|
async with DuckChat(model=ModelType.GPT4o) as chat:
|
||||||
query = prompt
|
query = prompt
|
||||||
|
61
tutorials/10_delete_nip89.py
Normal file
61
tutorials/10_delete_nip89.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
|
||||||
|
# Welcome Back. So you were playing around with a DVM and announced it to the world, but now you rather would like
|
||||||
|
# to remove it, because you don't want to run it anymore or you did it by accident. In this tutorial we look at how to
|
||||||
|
# remove NIP89 announcements, so our DVM doesn't appear in clients anymore.
|
||||||
|
# Check the main function for more instructions.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
from nostr_sdk import EventId, Keys, Client, NostrSigner
|
||||||
|
|
||||||
|
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||||
|
from nostr_dvm.utils.nip89_utils import fetch_nip89_parameters_for_deletion
|
||||||
|
|
||||||
|
# Method to delete the NIP89, don't worry, you don't have to touch this, take a look in the main function.
|
||||||
|
async def delete_nip_89(event_id, private_key, relay_list, pow=True):
|
||||||
|
event_id = EventId.parse(event_id).to_hex()
|
||||||
|
keys = Keys.parse(private_key)
|
||||||
|
dvm_config = DVMConfig()
|
||||||
|
dvm_config.RELAY_LIST = relay_list
|
||||||
|
|
||||||
|
|
||||||
|
client = Client(NostrSigner.keys(keys))
|
||||||
|
for relay in dvm_config.RELAY_LIST:
|
||||||
|
await client.add_relay(relay)
|
||||||
|
await client.connect()
|
||||||
|
|
||||||
|
await fetch_nip89_parameters_for_deletion(keys, event_id, client, dvm_config, pow)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
# What do you need to delete an event?
|
||||||
|
|
||||||
|
# First, you need the event id of the announcement. You can copy the json of the announcement from various clients,
|
||||||
|
# like Amethyst or you should also see it at noogle.lol/nip89. Copy the json to a text editor and in the first line
|
||||||
|
# you should see an entry "id":"someid". Copy the id and enter it in the event_id field below:
|
||||||
|
evend_id = "6f91dce309e....."
|
||||||
|
|
||||||
|
# The second thing you need is the private key of the DVM the announcement was made for.
|
||||||
|
# NostrDVM stores all your keys in the .env file. Open the .env file and search for
|
||||||
|
# DVM_PRIVATE_KEY_{IDENTIFIER_OF_YOUR_DVM}. Enter it below in the field private_key:
|
||||||
|
|
||||||
|
private_key = "6221e3181....."
|
||||||
|
|
||||||
|
# You can either use Proof of Work to send the delete event or not. Some relays require you to use POW in order to write.
|
||||||
|
# Sending a POW event might take up to a couple of minutes, so if you decide to use it, have some patience in the progress.
|
||||||
|
# If you know the relays you published your announcements to do not require POW, you can also set it to False which speeds up the progress.
|
||||||
|
pow = True
|
||||||
|
|
||||||
|
# And finally set the relay list you want to send the deletion request to. Ideally, you use the same relays that you use
|
||||||
|
# in your DVM's config. Maybe announcements also got propagated to other relays, so you might need to play around a bit until it's gone everywhere.
|
||||||
|
RELAY_LIST = ["wss://relay.primal.net",
|
||||||
|
"wss://nostr.mom",
|
||||||
|
"wss://nostr.oxtr.dev",
|
||||||
|
]
|
||||||
|
|
||||||
|
# That's it. Once you entered the info, run the script and if your private key matches the ID and the event can be found it should be deleted.
|
||||||
|
# Otherwise you'll get a warning
|
||||||
|
asyncio.run(delete_nip_89(evend_id, private_key, RELAY_LIST, pow))
|
Reference in New Issue
Block a user