Skip to main content

Crate bevy_nostr

Crate bevy_nostr 

Source
Expand description

Bevy plugin for the Nostr protocol

use bevy::prelude::*;
use bevy_nostr::prelude::*;

pub fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(NostrPlugin::default())
        .insert_resource(NostrClientConfig::default())
        .add_systems(Update, setup.run_if(resource_added::<NostrClientConfigured>))
        .add_systems(Update, handle_nostr_events)
        .run();
}

fn setup(mut commands: Commands) {
    // Nostr filter subscription
    commands.trigger(FilterSubscribe::new(
        Filter::new().kind(Kind::TextNote).limit(10),
    ));
}

fn handle_nostr_events(mut reader: MessageReader<NostrEventNotification>) {
    for notif in reader.read() {
        info!("Nostr event: {:?}", notif.event);
    }
}

Modules§

prelude

Structs§

FetchEvents
Bevy event to fetch nostr events matching a nostr::filter::Filter
FilterSubscribe
Filter subscription event
FilterSubscription
FilterSubscriptionName
NostrClient
Nostr client resource
NostrClientConfig
Nostr client configuration resource
NostrClientConfigured
Resource inserted after the client is configured
NostrEventNotification
Nostr event notification message
NostrPlugin
Nostr plugin
SendEventBuilder
Event to send an EventBuilder

Functions§

change_nostr_signer
Change the nostr signer for a NostrClient resource