Working on about messages
This commit is contained in:
parent
4fbc22967b
commit
5fa1955b99
12
src/lib.rs
12
src/lib.rs
|
@ -343,16 +343,22 @@ impl Sbot {
|
|||
.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
|
||||
// this code is not real dont look at it
|
||||
let stdout = String::from_utf8(output.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))
|
||||
Some(val) => {
|
||||
let value_as_str = val.as_str();
|
||||
match value_as_str {
|
||||
Some(v) => Ok(Some(v.to_string())),
|
||||
None => Err(SbotCliError::GetAboutMsgs(format!("error parsing {} from about message", key)))
|
||||
}
|
||||
},
|
||||
None => Err(SbotCliError::GetAboutMsgs(format!("error parsing {} from about message", key)))
|
||||
}
|
||||
Ok(value)
|
||||
} else {
|
||||
let stderr = std::str::from_utf8(&output.stderr)?;
|
||||
// TODO: create a more generic error variant
|
||||
|
|
Loading…
Reference in New Issue