From 5e806d08e8d5fb6e46fb10b8a201d1a70d62484b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Feb 2026 12:29:52 +0000 Subject: [PATCH] feat(bot): Publish profile to discovery relays on startup Bot now publishes a kind 0 profile event with name "sancho" and about "a grimoire assistant" to discovery relays when starting up. Discovery relays: - relay.damus.io - nos.lol - relay.nostr.band - purplepag.es - The group relay https://claude.ai/code/session_01X4HWkMGrghBv2RfY89L5Lz --- bot/src/index.ts | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/bot/src/index.ts b/bot/src/index.ts index 5ddea57..d1882b8 100644 --- a/bot/src/index.ts +++ b/bot/src/index.ts @@ -18,6 +18,15 @@ const BOT_PRIVATE_KEY = const RELAY_URL = process.env.RELAY_URL || "wss://groups.0xchat.com"; const GROUP_ID = process.env.GROUP_ID || "NkeVhXuWHGKKJCpn"; +// Discovery relays for publishing profile +const DISCOVERY_RELAYS = [ + "wss://relay.damus.io", + "wss://nos.lol", + "wss://relay.nostr.band", + "wss://purplepag.es", + RELAY_URL, // Also publish to the group relay +]; + // Derive bot pubkey from private key const botSecretKey = hexToBytes(BOT_PRIVATE_KEY); const botPubkey = getPublicKey(botSecretKey); @@ -142,10 +151,45 @@ async function handleMention(event: NostrEvent): Promise { } } +/** + * Publish bot profile to discovery relays + */ +async function publishProfile(): Promise { + const profile = { + name: "sancho", + about: "a grimoire assistant", + picture: "", + nip05: "", + }; + + const eventTemplate = { + kind: 0, + created_at: Math.floor(Date.now() / 1000), + tags: [], + content: JSON.stringify(profile), + }; + + const signedEvent = finalizeEvent(eventTemplate, botSecretKey); + + console.log("Publishing profile to discovery relays..."); + + const results = await Promise.allSettled( + pool.publish(DISCOVERY_RELAYS, signedEvent), + ); + + const successful = results.filter((r) => r.status === "fulfilled").length; + console.log( + `Profile published to ${successful}/${DISCOVERY_RELAYS.length} relays\n`, + ); +} + /** * Start the bot */ async function main(): Promise { + // Publish profile first + await publishProfile(); + console.log("Connecting to relay and subscribing to group...\n"); // Subscribe to group messages