Initial commit

This commit is contained in:
VC
2023-11-07 14:19:40 +01:00
commit e8c2d35e21
9 changed files with 2644 additions and 0 deletions

30
src/lib.rs Normal file
View File

@@ -0,0 +1,30 @@
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;
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 {
println!("{:?}", &toot.content);
}
}