From 5b72de0b2b90df1ad72f16d16002e3bfae31bac1 Mon Sep 17 00:00:00 2001 From: notplants Date: Wed, 22 Dec 2021 14:42:01 -0500 Subject: [PATCH] Add publish_post method --- src/lib.rs | 2 ++ src/sbot.rs | 10 ++++++++++ src/utils.rs | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 6fd638d..2dbc4cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,8 @@ //! } //! ``` +extern crate kuska_ssb; + pub mod error; pub mod sbot; mod utils; diff --git a/src/sbot.rs b/src/sbot.rs index 151071d..557faed 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -113,6 +113,16 @@ impl Sbot { utils::get_async(&mut self.rpc_reader, req_id, utils::publish_res_parse).await } + /// Wrapper for publish which constructs and publish a post message appropriately from a string. + /// + /// # Arguments + /// + /// * `text` - A &str which represents the text to be published in the post + pub async fn publish_post(&mut self, text: &str) -> Result { + let msg = TypedMessage::Post{ text: text.to_string(), mentions: None}; + self.publish(msg).await + } + /* pub async fn publish_post(&mut self, post: Post) -> Result { let req_id = self.client.publish_req_send(post).await?; diff --git a/src/utils.rs b/src/utils.rs index ba3d65b..70c75e6 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -10,7 +10,7 @@ use std::fmt::Debug; use async_std::io::Read; -use kuska_ssb::api::dto::{PublishOut, WhoAmIOut}; +use kuska_ssb::api::dto::{WhoAmIOut}; use kuska_ssb::feed::Feed; use kuska_ssb::rpc::{RecvMsg, RequestNo, RpcReader};