diff --git a/src/lib.rs b/src/lib.rs index 6f6c471..cd1e24d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,7 +80,6 @@ pub struct PeerRelationship { blocking: bool } - /// SBOT METHODS /// An `sbotcli` instance with associated methods for querying a Go sbot server. @@ -338,14 +337,21 @@ impl Sbot { let output = Command::new(&self.sbotcli_path) .arg("bytype") .arg("--limit") - .arg("10") + .arg("1") .arg("--reverse") .arg("about") .output()?; if output.status.success() { + // TODO: figure out how to take a stream of messages, and filter down to just ones with the value we are looking for let stdout = String::from_utf8(output.stdout)?; - let regex_string = format!(r#""{}": "(.*)""#, key); - let value = utils::regex_finder(®ex_string, &stdout)?; + let ssb_message : SsbMessageValue = serde_json::from_str(&stdout).map_err(|err| { + SbotCliError::GetAboutMsgs(format!("error deserializing ssb message while getting about message: {}", err)) + })?; + let value = ssb_message.content.get(key); + match value { + Some(val) => Ok(val), + None => SbotCliError::GetAboutMsgs(format!("error parsing {} from about message: {}", key, err)) + } Ok(value) } else { let stderr = std::str::from_utf8(&output.stderr)?;