pub mod nips; pub mod functions; // Das neue Modul registrieren use anyhow::Result; use nostr_sdk::prelude::*; // Wir importieren die Funktionen, um Tipparbeit zu sparen use crate::functions::{new, messages, relays, get_contacts, create_contact}; pub struct EasyNostr { client: Client, } impl EasyNostr { /// Erstellt eine neue Instanz pub async fn new(private_key: &str) -> Result { // Aufruf der Logik in functions/new.rs let client = new::new_client(private_key).await?; Ok(Self { client }) } /// Sendet eine verschlüsselte DM (NIP-17 Wrapper) pub async fn send_private_message(&self, receiver_pubkey: &str, message: &str) -> Result { messages::send_private_message(&self.client, receiver_pubkey, message).await } /// Fügt Relays hinzu und verbindet pub async fn add_relays(&self, urls: Vec<&str>) -> Result<()> { relays::add_relays(&self.client, urls).await } /// Lädt die Kontaktliste (NIP-02) pub async fn get_contacts(&self) -> Result> { get_contacts::get_contacts(&self.client).await } /// Erstellt oder aktualisiert einen Kontakt pub async fn create_contact(&self, npub: &str, nickname: Option) -> Result { create_contact::create_contact(&self.client, npub, nickname).await } }