Files
easy-nostr/src/nips/nip01.rs
2025-12-19 20:25:39 +01:00

20 lines
576 B
Rust

use anyhow::Result;
use nostr_sdk::prelude::*;
/// A simplified structure for a Text Post (Kind 1)
/// Contains the ID, Author, content, and timestamp.
#[derive(Debug, Clone)]
pub struct Post {
pub id: EventId,
pub author: PublicKey,
pub content: String,
pub created_at: Timestamp,
}
/// Publishes a text note (Kind 1) to the connected relays.
pub async fn publish_text(client: &Client, content: &str) -> Result<EventId> {
let builder = EventBuilder::text_note(content);
let output = client.send_event_builder(builder).await?;
Ok(*output.id())
}