This repository contains two Python scripts designed to synchronize events between the Fediverse and Nostr platforms. The scripts are:
sync_fediverse_to_nos.pynews_sync.py
This script fetches events from a Nostr relay for a list of public keys and republishes them to another Nostr relay. It uses a multi-threaded approach to handle multiple public keys concurrently, ensuring efficient processing.
- Read Public Keys: The script reads public keys from
matching_nhex.txt. - Fetch Events: For each public key, it connects to a Nostr relay and fetches events.
- Publish Events: The fetched events are then published to another Nostr relay.
- Progress Tracking: The script uses a progress bar to show the synchronization progress.
- Sync Position: It saves the last processed position to
sync_position.txtto resume from where it left off in case of interruptions.
This script fetches recent events from a Nostr relay for a predefined list of publishers and republishes them to a news relay.
- Fetch Events: Connects to a Nostr relay and fetches recent events for a list of predefined publishers.
- Publish Events: Publishes the fetched events to a news relay.
- Timestamp Management: It saves the timestamp of the last run to
news_sync_timestamp.txtto fetch only new events in subsequent runs. - Progress Tracking: Uses a progress bar to show the progress of fetching and publishing events.
-
Clone the Repository:
git clone https://github.com/yourusername/fediverse-nostr-sync.git cd fediverse-nostr-sync -
Create a Virtual Environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies:
pip install -r requirements.txt
Ensure
requirements.txtincludes:websocket-client tqdm
-
Prepare the Public Keys: Ensure
matching_nhex.txtcontains the public keys you want to process, one per line. -
Run the Script:
python sync_fediverse_to_nos.py
The script will start processing from the last saved position in
sync_position.txt.
-
Run the Script:
python news_sync.py
The script will fetch and publish events based on the last run timestamp saved in
news_sync_timestamp.txt.
- Ensure you have a stable internet connection as the scripts rely on WebSocket connections to Nostr relays.
- Adjust the
RELAY_URLandNEWS_URLin the scripts if you need to connect to different relays. - The scripts are designed to handle errors gracefully, but ensure your environment is set up correctly to avoid issues.
This project is licensed under the MIT License. See the LICENSE file for details.