|
@@ -8,12 +8,14 @@ use teloxide::{DownloadError, RequestError};
|
|
|
use thiserror::Error;
|
|
use thiserror::Error;
|
|
|
use tokio::fs::File;
|
|
use tokio::fs::File;
|
|
|
|
|
|
|
|
|
|
+#[cfg(feature = "telegram")]
|
|
|
#[tokio::main]
|
|
#[tokio::main]
|
|
|
pub async fn bot() {
|
|
pub async fn bot() {
|
|
|
run().await;
|
|
run().await;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// Possible error while receiving a file
|
|
/// Possible error while receiving a file
|
|
|
|
|
+#[cfg(feature = "telegram")]
|
|
|
#[derive(Debug, Error, From)]
|
|
#[derive(Debug, Error, From)]
|
|
|
enum FileReceiveError {
|
|
enum FileReceiveError {
|
|
|
/// Download process error
|
|
/// Download process error
|
|
@@ -27,6 +29,7 @@ enum FileReceiveError {
|
|
|
Io(#[source] std::io::Error),
|
|
Io(#[source] std::io::Error),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#[cfg(feature = "telegram")]
|
|
|
async fn download_file(downloader: &Bot, file_id: &str) -> Result<String, FileReceiveError> {
|
|
async fn download_file(downloader: &Bot, file_id: &str) -> Result<String, FileReceiveError> {
|
|
|
let TgFile {
|
|
let TgFile {
|
|
|
file_id, file_path, ..
|
|
file_id, file_path, ..
|
|
@@ -37,6 +40,7 @@ async fn download_file(downloader: &Bot, file_id: &str) -> Result<String, FileRe
|
|
|
Ok(filepath)
|
|
Ok(filepath)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#[cfg(feature = "telegram")]
|
|
|
async fn run() {
|
|
async fn run() {
|
|
|
teloxide::enable_logging!();
|
|
teloxide::enable_logging!();
|
|
|
log::info!("Starting dices_bot...");
|
|
log::info!("Starting dices_bot...");
|