golgi/examples/ssb-client.rs

36 lines
938 B
Rust
Raw Normal View History

2021-12-02 17:48:16 +00:00
use std::process;
2021-12-28 19:57:30 +00:00
use kuska_ssb::api::dto::content::{SubsetQuery, TypedMessage, Post};
2021-12-02 17:48:16 +00:00
use golgi::error::GolgiError;
use golgi::sbot::Sbot;
2021-12-29 01:35:46 +00:00
use golgi::utils::{SsbMessageValue, TypedSsbMessageValue};
2021-12-02 17:48:16 +00:00
async fn run() -> Result<(), GolgiError> {
let mut sbot_client = Sbot::init(None, None).await?;
let id = sbot_client.whoami().await?;
println!("{}", id);
2021-12-28 15:24:35 +00:00
let author = "@L/z54cbc8V1kL1/MiBhpEKuN3QJkSoZYNaukny3ghIs=.ed25519".to_string();
2021-12-28 19:57:30 +00:00
println!("Calling create_history");
2021-12-29 01:35:46 +00:00
let messages : Vec<SsbMessageValue> = sbot_client.create_history_stream(author).await?;
println!("hist: {:?}", messages);
2021-12-27 21:43:44 +00:00
2021-12-29 01:35:46 +00:00
for message in messages {
let t: TypedSsbMessageValue = message.into_typed_message_value()?;
println!("t: {:?}", t);
2021-12-28 19:57:30 +00:00
}
2021-12-27 21:43:44 +00:00
2021-12-02 17:48:16 +00:00
Ok(())
}
#[async_std::main]
async fn main() {
if let Err(e) = run().await {
eprintln!("Application error: {}", e);
process::exit(1);
}
}