mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Fix
This commit is contained in:
@@ -11,7 +11,7 @@ use teloxide::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
types::*,
|
types::*,
|
||||||
};
|
};
|
||||||
use tokio::time::sleep;
|
use tokio::time::{self};
|
||||||
use tokio_util::compat::FuturesAsyncReadCompatExt;
|
use tokio_util::compat::FuturesAsyncReadCompatExt;
|
||||||
use tracing::log;
|
use tracing::log;
|
||||||
|
|
||||||
@@ -507,7 +507,11 @@ async fn wait_archive(
|
|||||||
task_id: String,
|
task_id: String,
|
||||||
message: Message,
|
message: Message,
|
||||||
) -> BotHandlerInternal {
|
) -> BotHandlerInternal {
|
||||||
|
let mut interval = time::interval(Duration::from_secs(5));
|
||||||
|
|
||||||
let task = loop {
|
let task = loop {
|
||||||
|
interval.tick().await;
|
||||||
|
|
||||||
let task = match get_task(task_id.clone()).await {
|
let task = match get_task(task_id.clone()).await {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -535,8 +539,6 @@ async fn wait_archive(
|
|||||||
.reply_markup(get_check_keyboard(task.id))
|
.reply_markup(get_check_keyboard(task.id))
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
sleep(Duration::from_secs(5)).await;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if task.status != TaskStatus::Complete {
|
if task.status != TaskStatus::Complete {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use tokio::sync::RwLock;
|
|||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use teloxide::adaptors::throttle::Limits;
|
use teloxide::adaptors::throttle::Limits;
|
||||||
use teloxide::types::{BotCommand, UpdateKind};
|
use teloxide::types::{BotCommand, UpdateKind};
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration, self};
|
||||||
use tower_http::trace::TraceLayer;
|
use tower_http::trace::TraceLayer;
|
||||||
|
|
||||||
use teloxide::prelude::*;
|
use teloxide::prelude::*;
|
||||||
@@ -300,21 +300,19 @@ impl BotsManager {
|
|||||||
|
|
||||||
manager.start_axum_server().await;
|
manager.start_axum_server().await;
|
||||||
|
|
||||||
let mut i = 0;
|
let mut interval = time::interval(Duration::from_secs(5));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if !running.load(Ordering::SeqCst) {
|
for _i in 0..30 {
|
||||||
manager.stop_all().await;
|
interval.tick().await;
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if i == 0 {
|
if !running.load(Ordering::SeqCst) {
|
||||||
manager.check().await;
|
manager.stop_all().await;
|
||||||
|
return;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(Duration::from_secs(1)).await;
|
manager.check().await;
|
||||||
|
|
||||||
i = (i + 1) % 30;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user