mirror of
https://framagit.org/veretcle/oolatoocs.git
synced 2025-07-20 12:31:18 +02:00
ready to roll
This commit is contained in:
17
src/lib.rs
17
src/lib.rs
@@ -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 can’t 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
20
src/twitter.rs
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user