nostr_channel
diapason.channels.nostr_channel
¶
NostrChannel — Nostr protocol adapter via pynostr.
NostrChannel
¶
Bases: BaseChannel
Nostr decentralized messaging channel adapter.
Uses the Nostr protocol via pynostr.
Parameters¶
private_key:
Nostr private key (hex or nsec format). Falls back to
NOSTR_PRIVATE_KEY env var.
relays:
Comma-separated list of relay URLs. Falls back to NOSTR_RELAYS
env var. Default: wss://relay.damus.io.
bus:
Optional event bus for publishing channel events.
connect()
¶
Validate credentials and mark as connected.
disconnect()
¶
Mark as disconnected.
list_channels()
¶
Return available channel identifiers.
on_message(handler)
¶
Register a callback for incoming messages.
send(channel, content, *, conversation_id='', metadata=None)
¶
Publish a Nostr event (kind 1 note or kind 4 DM).
Parameters¶
channel: For public notes, this is ignored or used as a tag. For encrypted DMs, this is the recipient public key (hex or npub). content: Note or message content.
status()
¶
Return the current connection status.