use nostralink::prelude::*;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<(), RdfStoreError> {
let args: Vec<String> = std::env::args().collect();
let store_path = if args.len() > 1 {
PathBuf::from(args[1].clone())
} else {
PathBuf::from("rdf_store")
};
let store = RdfEventsStore::open(store_path)?;
let keys = Keys::generate();
let client = Client::builder().database(store).signer(keys).build();
client.add_relay("wss://relay.damus.io").await?;
client.add_relay("wss://nos.lol").await?;
client.connect().await;
client
.subscribe(
Filter::new()
.kind(Kind::TextNote)
.limit(100)
.since(Timestamp::now() - 3600),
None,
)
.await?;
client
.handle_notifications(|notification| async {
if let RelayPoolNotification::Event {
relay_url: _,
subscription_id: _,
event,
} = notification
{
let ttl = ttlify_event(&event).await
.map_err(|_| RdfStoreError::LDErr(LDError::TTLSerializationError))?;
println!("{ttl}");
}
Ok(false)
})
.await?;
Ok(())
}