@ -155,11 +155,10 @@ async fn run(args: BotConfig, client: Client) -> anyhow::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The main entrypoint for bot.
|
pub async fn bot_life(
|
||||||
///
|
args: BotConfig,
|
||||||
/// This function starts bot, performs login and
|
web_code: Arc<RwLock<Option<String>>>,
|
||||||
/// starts endless loop.
|
) -> anyhow::Result<()> {
|
||||||
pub async fn start(args: BotConfig, web_code: Arc<RwLock<Option<String>>>) -> anyhow::Result<()> {
|
|
||||||
log::info!("Connecting to Telegram...");
|
log::info!("Connecting to Telegram...");
|
||||||
let client = Client::connect(Config {
|
let client = Client::connect(Config {
|
||||||
session: Session::load_file_or_create(args.session_file.as_str())?,
|
session: Session::load_file_or_create(args.session_file.as_str())?,
|
||||||
@ -189,3 +188,21 @@ pub async fn start(args: BotConfig, web_code: Arc<RwLock<Option<String>>>) -> an
|
|||||||
|
|
||||||
Ok(())
|
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<RwLock<Option<String>>>) -> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user