diff --git a/src/bot/main.rs b/src/bot/main.rs index fd91a2b..1288014 100644 --- a/src/bot/main.rs +++ b/src/bot/main.rs @@ -155,11 +155,10 @@ async fn run(args: BotConfig, client: Client) -> anyhow::Result<()> { Ok(()) } -/// The main entrypoint for bot. -/// -/// This function starts bot, performs login and -/// starts endless loop. -pub async fn start(args: BotConfig, web_code: Arc>>) -> anyhow::Result<()> { +pub async fn bot_life( + args: BotConfig, + web_code: Arc>>, +) -> anyhow::Result<()> { log::info!("Connecting to Telegram..."); let client = Client::connect(Config { session: Session::load_file_or_create(args.session_file.as_str())?, @@ -189,3 +188,21 @@ pub async fn start(args: BotConfig, web_code: Arc>>) -> an Ok(()) } + +/// The main entrypoint for bot. +/// +/// This function starts bot, performs login and +/// starts endless loop. +pub async fn start(args: BotConfig, web_code: Arc>>) -> anyhow::Result<()> { + loop { + match bot_life(args.clone(), web_code.clone()).await { + Err(err) => { + log::error!("{err}"); + } + Ok(_) => { + log::info!("Lol, messages are ended."); + } + } + tokio::time::sleep(Duration::from_secs(1)).await; + } +}