A simple python Data Vending Machine (DVM) implementation on nostr
Project description
ezdvm
Easily run any python code behind a DVM on Nostr. Just pick a kind (for basic text-to-text use 5050) and put the code you want to run in the do_work() function. Then run the DVM.
Install from pip
pip install ezdvm
Install from local repo for development on ezdvm
git clone https://github.com/dtdannen/ezdvm.git
cd ezdvm/
python3.12 -m venv venv
source venv/bin/activate
pip install -e .
Create your own DVM
Steps:
- Choose the job request kind in the init function
- Run any python code inside the do_work() function. The
eventarg is the original job request from the user, in the form ofnostr-sdk event, for python examples see here: https://github.com/rust-nostr/nostr/tree/master/bindings/nostr-sdk-ffi/bindings-python/examples
from ezdvm import EZDVM
class HelloWorldDVM(EZDVM):
def __init__(self):
# choose the job request kinds you will listen and respond to
super().__init__(kinds=[5050])
async def do_work(self, event):
return "Hello World!"
if __name__ == "__main__":
hello_world_dvm = HelloWorldDVM()
hello_world_dvm.add_relay("wss://relay.damus.io")
hello_world_dvm.add_relay("wss://relay.primal.net")
hello_world_dvm.add_relay("wss://nos.lol")
hello_world_dvm.add_relay("wss://nostr-pub.wellorder.net")
hello_world_dvm.start()
Testing
Once it's running on your machine, if you are using kind 5050 you can test it here: https://dvmdash.live/playground/
Note that currently you have to use a NIP-07 extension to login first
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ezdvm-0.1.2.tar.gz.
File metadata
- Download URL: ezdvm-0.1.2.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
703cfbf12e660f6dc209e31b3f56dcd5c8bf07569800c7d73cf36d7e6170974f
|
|
| MD5 |
7df309aad805723d4e842feb42df6961
|
|
| BLAKE2b-256 |
107423d245706b3ca2cf042424c5ba3dc35d829a6c470fa66026a99b510f2655
|
File details
Details for the file ezdvm-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ezdvm-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fb5302bb5fe03c3aa1ca7697b39b00e041522037c3332e3adff74bd91425cd5
|
|
| MD5 |
9f0b1af420d9d5d87aa4db50bf03151d
|
|
| BLAKE2b-256 |
d334717c7e4afe0a42545e70db8084eb4a18f8fd212c01d5ba2370339a48333a
|