mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-21 01:21:19 +02:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
92d5fdffad | ||
![]() |
331adec60f | ||
![]() |
9a341310da | ||
![]() |
2c77a0e5fc | ||
![]() |
032e3cf8dd | ||
![]() |
a854243cf6 | ||
![]() |
b33ffa4401 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -2103,7 +2103,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scootaloo"
|
name = "scootaloo"
|
||||||
version = "0.9.2"
|
version = "0.9.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "scootaloo"
|
name = "scootaloo"
|
||||||
version = "0.9.2"
|
version = "0.9.4"
|
||||||
authors = ["VC <veretcle+framagit@mateu.be>"]
|
authors = ["VC <veretcle+framagit@mateu.be>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
15
src/lib.rs
15
src/lib.rs
@@ -19,14 +19,13 @@ mod state;
|
|||||||
pub use state::{init_db, migrate_db};
|
pub use state::{init_db, migrate_db};
|
||||||
use state::{read_state, write_state, TweetToToot};
|
use state::{read_state, write_state, TweetToToot};
|
||||||
|
|
||||||
use elefren::{prelude::*, status_builder::StatusBuilder};
|
use elefren::{prelude::*, status_builder::StatusBuilder, Language};
|
||||||
|
use futures::StreamExt;
|
||||||
use log::info;
|
use log::info;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::{spawn, sync::Mutex};
|
use tokio::{spawn, sync::Mutex};
|
||||||
|
|
||||||
use futures::StreamExt;
|
|
||||||
|
|
||||||
const DEFAULT_RATE_LIMIT: usize = 4;
|
const DEFAULT_RATE_LIMIT: usize = 4;
|
||||||
const DEFAULT_PAGE_SIZE: i32 = 200;
|
const DEFAULT_PAGE_SIZE: i32 = 200;
|
||||||
|
|
||||||
@@ -57,7 +56,6 @@ pub async fn run(config: Config) {
|
|||||||
|
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
info!("Starting treating {}", &mastodon_config.twitter_screen_name);
|
info!("Starting treating {}", &mastodon_config.twitter_screen_name);
|
||||||
|
|
||||||
// retrieve the last tweet ID for the username
|
// retrieve the last tweet ID for the username
|
||||||
let lconn = task_conn.lock().await;
|
let lconn = task_conn.lock().await;
|
||||||
let last_tweet_id = read_state(&lconn, &mastodon_config.twitter_screen_name, None)?
|
let last_tweet_id = read_state(&lconn, &mastodon_config.twitter_screen_name, None)?
|
||||||
@@ -78,6 +76,7 @@ pub async fn run(config: Config) {
|
|||||||
|
|
||||||
for tweet in &feed {
|
for tweet in &feed {
|
||||||
info!("Treating Tweet {} inside feed", tweet.id);
|
info!("Treating Tweet {} inside feed", tweet.id);
|
||||||
|
|
||||||
let lconn = task_conn.lock().await;
|
let lconn = task_conn.lock().await;
|
||||||
// initiate the toot_reply_id var and retrieve the corresponding toot_id
|
// initiate the toot_reply_id var and retrieve the corresponding toot_id
|
||||||
let toot_reply_id: Option<String> = tweet.in_reply_to_user_id.and_then(|_| {
|
let toot_reply_id: Option<String> = tweet.in_reply_to_user_id.and_then(|_| {
|
||||||
@@ -106,10 +105,18 @@ pub async fn run(config: Config) {
|
|||||||
|
|
||||||
status_builder.status(&status_text).media_ids(status_medias);
|
status_builder.status(&status_text).media_ids(status_medias);
|
||||||
|
|
||||||
|
// theard if necessary
|
||||||
if let Some(i) = toot_reply_id {
|
if let Some(i) = toot_reply_id {
|
||||||
status_builder.in_reply_to(&i);
|
status_builder.in_reply_to(&i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// language if any
|
||||||
|
if let Some(l) = &tweet.lang {
|
||||||
|
if let Some(r) = Language::from_639_1(l) {
|
||||||
|
status_builder.language(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// can be activated for test purposes
|
// can be activated for test purposes
|
||||||
// status_builder.visibility(elefren::status_builder::Visibility::Private);
|
// status_builder.visibility(elefren::status_builder::Visibility::Private);
|
||||||
|
|
||||||
|
@@ -15,10 +15,7 @@ fn main() {
|
|||||||
.short('c')
|
.short('c')
|
||||||
.long("config")
|
.long("config")
|
||||||
.value_name("CONFIG_FILE")
|
.value_name("CONFIG_FILE")
|
||||||
.help(&format!(
|
.help("TOML config file for scootaloo")
|
||||||
"TOML config file for scootaloo (default {})",
|
|
||||||
DEFAULT_CONFIG_PATH
|
|
||||||
))
|
|
||||||
.num_args(1)
|
.num_args(1)
|
||||||
.default_value(DEFAULT_CONFIG_PATH)
|
.default_value(DEFAULT_CONFIG_PATH)
|
||||||
.display_order(1),
|
.display_order(1),
|
||||||
@@ -28,7 +25,7 @@ fn main() {
|
|||||||
.short('l')
|
.short('l')
|
||||||
.long("loglevel")
|
.long("loglevel")
|
||||||
.value_name("LOGLEVEL")
|
.value_name("LOGLEVEL")
|
||||||
.help("Log level. Valid values are: Off, Warn, Error, Info, Debug")
|
.help("Log level")
|
||||||
.num_args(1)
|
.num_args(1)
|
||||||
.value_parser(["Off", "Warn", "Error", "Info", "Debug"])
|
.value_parser(["Off", "Warn", "Error", "Info", "Debug"])
|
||||||
.display_order(2),
|
.display_order(2),
|
||||||
|
Reference in New Issue
Block a user