mirror of
https://framagit.org/veretcle/oolatoocs.git
synced 2025-07-20 20:41:17 +02:00
Initial commit
This commit is contained in:
30
src/lib.rs
Normal file
30
src/lib.rs
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user