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()?;
|
.output()?;
|
||||||
if output.status.success() {
|
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
|
// 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 stdout = String::from_utf8(output.stdout)?;
|
||||||
let ssb_message : SsbMessageValue = serde_json::from_str(&stdout).map_err(|err| {
|
let ssb_message : SsbMessageValue = serde_json::from_str(&stdout).map_err(|err| {
|
||||||
SbotCliError::GetAboutMsgs(format!("error deserializing ssb message while getting about message: {}", err))
|
SbotCliError::GetAboutMsgs(format!("error deserializing ssb message while getting about message: {}", err))
|
||||||
})?;
|
})?;
|
||||||
let value = ssb_message.content.get(key);
|
let value = ssb_message.content.get(key);
|
||||||
match value {
|
match value {
|
||||||
Some(val) => Ok(val),
|
Some(val) => {
|
||||||
None => SbotCliError::GetAboutMsgs(format!("error parsing {} from about message: {}", key, err))
|
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 {
|
} else {
|
||||||
let stderr = std::str::from_utf8(&output.stderr)?;
|
let stderr = std::str::from_utf8(&output.stderr)?;
|
||||||
// TODO: create a more generic error variant
|
// TODO: create a more generic error variant
|
||||||
|
Loading…
x
Reference in New Issue
Block a user