Partially adapt bot module to changes due to fetchers modularization
This commit is contained in:
parent
e5862ba0ec
commit
b9a26a7b1c
1 changed files with 12 additions and 10 deletions
22
src/bot.rs
22
src/bot.rs
|
@ -1,8 +1,8 @@
|
|||
use crate::config::{Config, PostBody, SeriesConfig};
|
||||
use crate::jnovel::PostInfo;
|
||||
use crate::lemmy::Lemmy;
|
||||
use crate::fetchers::jnovel::JPostInfo;
|
||||
use crate::lemmy::{Lemmy, PostInfo};
|
||||
use crate::post_history::SeriesHistory;
|
||||
use crate::{jnovel, lemmy, write_error, write_info, write_warn, SharedData};
|
||||
use crate::{fetchers::{jnovel}, lemmy, write_error, write_info, write_warn, SharedData};
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use lemmy_api_common::post::CreatePost;
|
||||
use lemmy_db_schema::newtypes::{CommunityId, LanguageId};
|
||||
|
@ -11,6 +11,7 @@ use std::collections::HashMap;
|
|||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
use tokio::time::sleep;
|
||||
use crate::fetchers::Fetcher;
|
||||
|
||||
pub(crate) async fn run(data: Arc<RwLock<SharedData>>) {
|
||||
let mut last_reload: DateTime<Utc>;
|
||||
|
@ -137,15 +138,16 @@ async fn idle(data: &Arc<RwLock<SharedData>>) {
|
|||
}
|
||||
|
||||
async fn handle_series(series: &SeriesConfig, communities: &HashMap<String, CommunityId>, lemmy: &Lemmy, data: &Arc<RwLock<SharedData>>) -> Result<(), ()> {
|
||||
let mut post_list = match jnovel::check_feed(series.slug.as_str(), series.parted).await {
|
||||
let jnc = jnovel::JFetcherOptions::new(series.slug.clone(), series.parted);
|
||||
let post_list = match jnc.check_feed().await {
|
||||
Ok(data) => data,
|
||||
Err(_) => return Err(()),
|
||||
};
|
||||
|
||||
for (index, post_info) in post_list.clone().iter().enumerate() {
|
||||
for post_info in post_list.clone().iter() {
|
||||
// todo .clone() likely not needed
|
||||
let post_part_info = post_info.get_part_info();
|
||||
let post_lemmy_info = post_info.get_lemmy_info();
|
||||
let post_lemmy_info = post_info.get_info();
|
||||
|
||||
{
|
||||
let read = data.read().await;
|
||||
|
@ -159,8 +161,8 @@ async fn handle_series(series: &SeriesConfig, communities: &HashMap<String, Comm
|
|||
}
|
||||
|
||||
let post_series_config = match post_info {
|
||||
PostInfo::Chapter { .. } => &series.prepub_community,
|
||||
PostInfo::Volume { .. } => &series.volume_community,
|
||||
JPostInfo::Chapter { .. } => &series.prepub_community,
|
||||
JPostInfo::Volume { .. } => &series.volume_community,
|
||||
};
|
||||
|
||||
let community_id = *communities
|
||||
|
@ -256,8 +258,8 @@ async fn handle_series(series: &SeriesConfig, communities: &HashMap<String, Comm
|
|||
drop(read);
|
||||
|
||||
match post_info {
|
||||
PostInfo::Chapter { .. } => part_history.chapter = post_info.get_lemmy_info().title,
|
||||
PostInfo::Volume { .. } => part_history.volume = post_info.get_lemmy_info().title,
|
||||
JPostInfo::Chapter { .. } => part_history.chapter = post_info.get_info().title,
|
||||
JPostInfo::Volume { .. } => part_history.volume = post_info.get_info().title,
|
||||
}
|
||||
|
||||
series_history.set_part(post_part_info.as_string().as_str(), part_history);
|
||||
|
|
Loading…
Reference in a new issue