2022-12-26 17:19:51 +00:00
|
|
|
#![cfg_attr(not(feature = "toml"), allow(dead_code))]
|
|
|
|
#![cfg_attr(not(feature = "toml"), allow(unused_imports))]
|
|
|
|
mod register;
|
|
|
|
|
|
|
|
use mastodon_async::{Language, Result, StatusBuilder, Visibility};
|
|
|
|
|
|
|
|
#[cfg(feature = "toml")]
|
2022-12-30 14:59:39 +00:00
|
|
|
async fn run() -> Result<()> {
|
2022-12-26 17:19:51 +00:00
|
|
|
let mastodon = register::get_mastodon_data().await?;
|
|
|
|
let status = StatusBuilder::new()
|
|
|
|
.status(register::read_line(
|
|
|
|
"Enter a status to post privately (enter to send): ",
|
|
|
|
)?)
|
2022-12-28 14:34:35 +00:00
|
|
|
.visibility(Visibility::Unlisted)
|
2022-12-26 17:19:51 +00:00
|
|
|
.language(Language::Eng)
|
|
|
|
.build()?;
|
|
|
|
|
|
|
|
let status = mastodon.new_status(status).await?;
|
|
|
|
|
|
|
|
print!("Status posted");
|
|
|
|
if let Some(url) = status.url {
|
|
|
|
// this is the expected thing to happen
|
|
|
|
println!(", visible when logged in at: {}\n", url);
|
|
|
|
} else {
|
|
|
|
println!(". For some reason, the status URL was not returned from the server.");
|
|
|
|
println!("Maybe try here? {}/{}", status.account.url, status.id);
|
|
|
|
}
|
|
|
|
if register::bool_input("delete this post? (Y/n)", true)? {
|
|
|
|
mastodon.delete_status(&status.id).await?;
|
|
|
|
println!("ok, done")
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-12-30 14:59:39 +00:00
|
|
|
#[cfg(all(feature = "toml", feature = "mt"))]
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<()> {
|
|
|
|
run().await
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(all(feature = "toml", not(feature = "mt")))]
|
|
|
|
#[tokio::main(flavor = "current_thread")]
|
|
|
|
async fn main() -> Result<()> {
|
|
|
|
run().await
|
|
|
|
}
|
|
|
|
|
2022-12-26 17:19:51 +00:00
|
|
|
#[cfg(not(feature = "toml"))]
|
|
|
|
fn main() {
|
|
|
|
println!(
|
|
|
|
"examples require the `toml` feature, run this command for this example:\n\ncargo run \
|
|
|
|
--example post_status --features toml\n"
|
|
|
|
);
|
|
|
|
}
|