mirror of
https://framagit.org/veretcle/oolatoocs.git
synced 2025-07-20 12:31:18 +02:00
37 lines
938 B
Rust
37 lines
938 B
Rust
mod config;
|
|
pub use config::{parse_toml, Config};
|
|
|
|
mod state;
|
|
pub use state::init_db;
|
|
use state::read_state;
|
|
|
|
mod mastodon;
|
|
use mastodon::get_mastodon_timeline_since;
|
|
pub use mastodon::register;
|
|
|
|
mod utils;
|
|
use utils::strip_everything;
|
|
|
|
use rusqlite::Connection;
|
|
|
|
#[tokio::main]
|
|
pub async fn run(config: &Config) {
|
|
let conn = Connection::open(&config.oolatoocs.db_path)
|
|
.unwrap_or_else(|e| panic!("Cannot open DB: {}", e));
|
|
|
|
let last_toot_id = read_state(&conn, None)
|
|
.unwrap_or_else(|e| panic!("Cannot get last toot id: {}", e))
|
|
.map(|r| r.toot_id);
|
|
|
|
let timeline = get_mastodon_timeline_since(&config.mastodon, last_toot_id)
|
|
.await
|
|
.unwrap_or_else(|e| panic!("Cannot get instance: {}", e));
|
|
|
|
for toot in timeline {
|
|
let Ok(tweet_content) = strip_everything(&toot.content, &toot.tags) else {
|
|
continue;
|
|
};
|
|
println!("{:?}", tweet_content);
|
|
}
|
|
}
|