ready to roll

This commit is contained in:
VC
2023-11-08 10:00:34 +01:00
parent 5126083dc4
commit bf70072376
2 changed files with 33 additions and 4 deletions

View File

@@ -3,7 +3,8 @@ pub use config::{parse_toml, Config};
mod state;
pub use state::init_db;
use state::read_state;
#[allow(unused_imports)]
use state::{read_state, write_state};
mod mastodon;
use mastodon::get_mastodon_timeline_since;
@@ -12,6 +13,10 @@ pub use mastodon::register;
mod utils;
use utils::strip_everything;
mod twitter;
#[allow(unused_imports)]
use twitter::{post_tweet, upload_media};
use rusqlite::Connection;
#[tokio::main]
@@ -29,9 +34,13 @@ pub async fn run(config: &Config) {
for toot in timeline {
let Ok(tweet_content) = strip_everything(&toot.content, &toot.tags) else {
continue;
continue; // skip in case we cant strip something
};
println!("Toot: {}", toot.id);
println!("{:?}", tweet_content);
// if we wanted to cut toot in half, now would be the right time to do so
// treating medias (nothing for now)
let _tweet_id = post_tweet(&tweet_content, &[])
.await
.unwrap_or_else(|e| panic!("Cannot Tweet {}: {}", toot.id, e));
return;
}
}

20
src/twitter.rs Normal file
View File

@@ -0,0 +1,20 @@
use serde::{Deserialize, Serialize};
use std::error::Error;
#[derive(Serialize, Debug)]
pub struct Tweet {}
#[derive(Deserialize, Debug)]
pub struct TweetResponse {}
/// This function uploads media from Mastodon to Twitter and returns the media id from Twitter
#[allow(dead_code)]
pub async fn upload_media(_u: &str) -> Result<u64, Box<dyn Error>> {
Ok(0)
}
/// This posts Tweets with all the associated medias
#[allow(dead_code)]
pub async fn post_tweet(_content: &str, _medias: &[u64]) -> Result<u64, Box<dyn Error>> {
Ok(0)
}