Nostr. Event. Comment
(Nostr Lib v0.2.1)
(event)
(nip22)
View Source
Comment (Kind 1111)
Threading comments for any Nostr event or external content. This is different
from NIP-10 replies to kind:1 notes - use Nostr.Event.Note.reply/3 for those.
Tag Scopes
Comments use uppercase tags for ROOT scope (the original item being commented on) and lowercase tags for PARENT scope (the direct parent in a thread).
Root Scope (uppercase):
E- Event ID referenceA- Addressable event reference (kind:pubkey:d-tag)I- External content identifier (URL, ISBN, etc.)K- Root item kind (integer for events, string like "web" for external)P- Root author pubkey
Parent Scope (lowercase):
e,a,i- Same as above but for direct parentk- Parent kind (e.g., "1111" for replies to comments)p- Parent author pubkey
For top-level comments, root and parent reference the same item. For replies to comments, root stays the original item, parent is the comment.
Defined in NIP 22 https://github.com/nostr-protocol/nips/blob/master/22.md
Summary
Functions
Creates a top-level comment on an addressable event.
Creates a top-level comment on an event.
Creates a top-level comment on external content.
Parses a kind 1111 event into a Comment struct.
Creates a reply to another comment.
Types
Functions
Creates a top-level comment on an addressable event.
Arguments
content- Comment textaddress- Address in format "kind:pubkey:d-tag"event_kind- Kind of the addressable eventevent_author- Pubkey of the event authoropts- Optional arguments (same ascomment_on_event/5)
Example
Comment.comment_on_address(
"Interesting perspective",
"30023:pubkey123:my-article",
30023,
"pubkey123..."
)
Creates a top-level comment on an event.
Arguments
content- Comment textevent_id- ID of the event being commented onevent_kind- Kind of the event being commented onevent_author- Pubkey of the event authoropts- Optional arguments
Options
:relay- Relay hint for the target event:pubkey- Comment author pubkey:created_at- Event timestamp:quotes- List of quoted event tuples{event_id, relay, pubkey}:mentions- List of mentioned pubkey tuples{pubkey, relay}
Example
Comment.comment_on_event(
"Great article!",
"abc123...",
30023,
"author_pubkey...",
relay: "wss://relay.example.com"
)
Creates a top-level comment on external content.
Arguments
content- Comment textidentifier- External identifier (URL, ISBN, podcast GUID, etc.)kind_type- Type string (e.g., "web", "podcast:item:guid", "isbn")opts- Optional arguments
Options
:hint- Hint for the identifier (e.g., URL for web content):pubkey- Comment author pubkey:created_at- Event timestamp:quotes- List of quoted event tuples:mentions- List of mentioned pubkey tuples
Example
Comment.comment_on_external(
"This is a great resource!",
"https://example.com/article",
"web"
)
@spec parse(Nostr.Event.t()) :: t()
Parses a kind 1111 event into a Comment struct.
Creates a reply to another comment.
The root scope is inherited from the parent comment, while parent scope references the comment being replied to.
Arguments
content- Reply textparent- TheCommentstruct being replied toopts- Optional arguments
Options
:relay- Relay hint for the parent comment:pubkey- Reply author pubkey:created_at- Event timestamp:quotes- List of quoted event tuples:mentions- List of mentioned pubkey tuples
Example
Comment.reply("I agree!", parent_comment, relay: "wss://relay.example.com")