golgi/examples/ssb-client.rs

61 lines
1.6 KiB
Rust
Raw Normal View History

2021-12-02 17:48:16 +00:00
use std::process;
2022-02-08 09:54:21 +00:00
use golgi::{messages::SsbMessageContent, GolgiError, Sbot};
2021-12-02 17:48:16 +00:00
async fn run() -> Result<(), GolgiError> {
2022-02-07 12:44:36 +00:00
let mut sbot_client = Sbot::connect(None, None).await?;
2021-12-02 17:48:16 +00:00
let id = sbot_client.whoami().await?;
2022-01-05 20:08:51 +00:00
println!("whoami: {}", id);
2021-12-02 17:48:16 +00:00
2022-01-14 17:41:15 +00:00
let name = SsbMessageContent::About {
about: id.clone(),
name: Some("golgi".to_string()),
title: None,
branch: None,
image: None,
description: None,
location: None,
start_datetime: None,
};
let name_msg_ref = sbot_client.publish(name).await?;
println!("name_msg_ref: {}", name_msg_ref);
2021-12-29 16:38:03 +00:00
let post = SsbMessageContent::Post {
text: "golgi go womp womp".to_string(),
mentions: None,
};
let post_msg_ref = sbot_client.publish(post).await?;
2022-01-05 20:08:51 +00:00
println!("post_msg_ref: {}", post_msg_ref);
2021-12-29 16:38:03 +00:00
2022-01-05 18:58:48 +00:00
let post_msg_ref = sbot_client
2022-01-05 20:08:51 +00:00
.publish_description("this is a description7")
2022-01-05 18:58:48 +00:00
.await?;
2021-12-29 15:59:05 +00:00
println!("description: {}", post_msg_ref);
2022-01-05 20:08:51 +00:00
let author: String = id.clone();
println!("author: {:?}", author);
let description = sbot_client.get_description(&author).await?;
println!("found description: {:?}", description);
let post = SsbMessageContent::Post {
text: "golgi go womp womp2".to_string(),
mentions: None,
};
let post_msg_ref = sbot_client.publish(post).await?;
println!("post_msg_ref2: {}", post_msg_ref);
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);
}
}