This script monitors the word of the day it will write a note to Nostr using the defined relays
- Clone the repository
- Preparation of Python Environment
- Configuring the Bot
- Running the Script
- Running as a Service
- For More Help
To setup bot, you'll first need to clone the repository
git clone https://github.com/companion256/WordOfTheDayBot.gitChange to the folder where the code is cloned to
cd WordOfTheDayBotIf you need to update the bot's code, pull the latest changes
git pullTo use this script, you'll need to run it with python 3.9 or higher and with the nostr, requests and bech32 packages installed.
First, create a virtual environment (or activate a common one)
python3 -m venv ~/.pyenv/wordofthedaybotActivate it
source ~/.pyenv/wordofthedaybot/bin/activateInstall Dependencies
python3 -m pip install -r requirements.txtA subdirectory for storing data will be created if one does not exist on first run of the script. Otherwise you can create and copy the sample configuration as follows:
mkdir -p data
cp -n sample-config.json data/config.jsonWithin this directory, a configuration file named config.json is read. If this file does not exist, one will be created using the sample-config.json.
The server configuration file is divided into a few key sections.
Edit the configuration
nano data/config.jsonThe nostr configuration section has these keys
| key | description |
|---|---|
| nsec | The nsec for identity |
| profile | The metadata fields for the bot's profile |
| relays | The list of relays the bot uses |
The most critical to define here is the nsec. You should generate an nsec on your own, and not use an existing one such as that for your personal usage.
The profile section contains fields that map to a nostr profile. The picture and banner should be URLs pointing to an image publicly available. The lud16 field is the lightning address that should be associated with the bot. A nip05 can optionally be set for external DNS verification as a nostr address.
The relays section contains the list of relays that the bot will use to read events and direct messages, as well as publish profiles (kind 0 metadata), direct message responses (kind 4), replies (kind 1). Each relay is configured with a url, and permissions for whether it can be read from or written to.
Once configured, run the bot using the previously established virtual environment
~/.pyenv/WordOfTheDayBot/bin/python main.pyPress Control+C to stop the bot process when satisfied its running properly.
You can install a service to run the bot in the background. You will need to do this as sudo, and know the name of the user for which the code was installed under.
Copy the service file
sudo cp nostr-word-of-the-day-bot.service /etc/systemd/system/nostr-word-of-the-day-bot.serviceEdit the contents
sudo nano -l /etc/systemd/system/nostr-word-of-the-day-bot.serviceOn lines 10, 11, and 12 change the username if you installed to a different user than admin.
Save (CTRL+O) and Exit (CTRL+X).
Enable and start the service
sudo systemctl enable nostr-word-of-the-day-bot.service
sudo systemctl start nostr-word-of-the-day-bot.serviceFor further assistance or customizations, reach out to the developer on Nostr
- NIP05: jay@thebitcoincompanion.com
- NPUB: npub1l8zv3fhdntxq00u3nmrxvmrwpenpgway8y67z663t92x6hd98w3qkfkw83