golgi/examples/ssb-client.rs

41 lines
1.1 KiB
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 15:59:05 +00:00
use golgi::messages::{SsbMessageValue, SsbMessageContent};
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-29 15:59:05 +00:00
let post_msg_ref = sbot_client
.publish_description("this is a description")
.await?;
println!("description: {}", post_msg_ref);
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 {
2021-12-29 15:59:05 +00:00
let content: SsbMessageContent = message.into_ssb_message_content()?;
println!("content: {:?}", content);
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);
}
}