golgi/examples/ssb-client.rs

36 lines
938 B
Rust

use std::process;
use kuska_ssb::api::dto::content::{SubsetQuery, TypedMessage, Post};
use golgi::error::GolgiError;
use golgi::sbot::Sbot;
use golgi::utils::{SsbMessageValue, TypedSsbMessageValue};
async fn run() -> Result<(), GolgiError> {
let mut sbot_client = Sbot::init(None, None).await?;
let id = sbot_client.whoami().await?;
println!("{}", id);
let author = "@L/z54cbc8V1kL1/MiBhpEKuN3QJkSoZYNaukny3ghIs=.ed25519".to_string();
println!("Calling create_history");
let messages : Vec<SsbMessageValue> = sbot_client.create_history_stream(author).await?;
println!("hist: {:?}", messages);
for message in messages {
let t: TypedSsbMessageValue = message.into_typed_message_value()?;
println!("t: {:?}", t);
}
Ok(())
}
#[async_std::main]
async fn main() {
if let Err(e) = run().await {
eprintln!("Application error: {}", e);
process::exit(1);
}
}