From b0205b53a50b4f68ae62f2c8fbbb1c13ec896560 Mon Sep 17 00:00:00 2001 From: Google AI Agent Date: Mon, 30 Mar 2026 21:14:19 +0000 Subject: [PATCH] feat: add NostrPublisher to broadcast Timmy soul --- nexus/nostr_publisher.py | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 nexus/nostr_publisher.py diff --git a/nexus/nostr_publisher.py b/nexus/nostr_publisher.py new file mode 100644 index 0000000..185c45e --- /dev/null +++ b/nexus/nostr_publisher.py @@ -0,0 +1,55 @@ + +import asyncio +import websockets +import json +import time +import os +from nostr_identity import NostrIdentity + +# ═══════════════════════════════════════════ +# NOSTR SOVEREIGN PUBLISHER +# ═══════════════════════════════════════════ + +RELAYS = [ + "wss://relay.damus.io", + "wss://nos.lol", + "wss://relay.snort.social" +] + +async def publish_soul(identity, soul_content): + event = { + "pubkey": identity.pubkey, + "created_at": int(time.time()), + "kind": 1, # Text note + "tags": [["t", "TimmyFoundation"], ["t", "SovereignAI"]], + "content": soul_content + } + signed_event = identity.sign_event(event) + message = json.dumps(["EVENT", signed_event]) + + for relay in RELAYS: + try: + print(f"Publishing to {relay}...") + async with websockets.connect(relay, timeout=10) as ws: + await ws.send(message) + print(f"Successfully published to {relay}") + except Exception as e: + print(f"Failed to publish to {relay}: {e}") + +async def main(): + # Load SOUL.md + soul_path = os.path.join(os.path.dirname(__file__), "../SOUL.md") + if os.path.exists(soul_path): + with open(soul_path, "r") as f: + soul_content = f.read() + else: + soul_content = "Sovereignty and service always. #Timmy" + + # Initialize Identity (In production, load from secure storage) + identity = NostrIdentity() + print(f"Timmy's Nostr Identity: npub1{identity.pubkey}") + + await publish_soul(identity, soul_content) + +if __name__ == "__main__": + asyncio.run(main())