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§
Structs§
- Fetch
Events - Bevy event to fetch nostr events matching a
nostr::filter::Filter - Filter
Subscribe - Filter subscription event
- Filter
Subscription - Filter
Subscription Name - Nostr
Client - Nostr client resource
- Nostr
Client Config - Nostr client configuration resource
- Nostr
Client Configured - Resource inserted after the client is configured
- Nostr
Event Notification - Nostr event notification message
- Nostr
Plugin - Nostr plugin
- Send
Event Builder - Event to send an EventBuilder
Functions§
- change_
nostr_ signer - Change the nostr signer for a
NostrClientresource